-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request]Tell the compiler the type #23250
Comments
try{
...
}catch(e: TypeError){
...
} |
And, |
@kgtkr for your example it's probably better to use a type guard, since try {
// ...
}
catch (e) {
if (e instanceof TypeError) {
// e is TypeError here
}
else {
throw e;
}
} If you are suggesting a more general proposal, is there something here not already covered by #10421 (type assertion statements at block scope), or just plain type assertions? |
It was a duplicate of #10421 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Background
Currently, it is not possible to tell the compiler the type of the variable.
Although it can be solved by creating new variables, extra overhead occurs.
Proposal
Example
Current
Better
The text was updated successfully, but these errors were encountered: