Repository navigation
Conversation
value.constructor.name names the class that constructed the value, as in Node: - A TypeScript program class without subclasses answers its name at compile time, as C.name does. Instances of classes with subclasses read constructor and name through the instance's checked-dynamic view. - An error-typed value tests the program's error classes that extend its static class, most derived first, and otherwise answers the native error's class (RangeError, DOMException, ...). An assigned name property does not change the result. - An untyped value reads constructor and then name. A value that holds a native error answers the error's class, so a caught RangeError answers "RangeError" instead of undefined. A value whose constructor is undefined or null throws Node's TypeError for the name read. Previously the TypeScript form was refused with SC2020.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+7164
to
+7172
| ScrError *error = scr_errdyn_err_of(value); | ||
| if (error) { | ||
| ScrStr *class_name = scr_error_class_name(error); | ||
| scr_error_release(error); | ||
| ScrDyn *out = scr_dyn_new_str(class_name); | ||
| scr_str_release(class_name); | ||
| return out; | ||
| } | ||
| if (constructor->kind == SCR_DYN_UNDEF || constructor->kind == SCR_DYN_NULL) { |
Contributor
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
value.constructor.namecompiles in TypeScript for class instances and errors, and names the class that constructed the value as Node does. Program classes without subclasses fold to a constant.RangeError,DOMException) instead ofundefined.