-
Notifications
You must be signed in to change notification settings - Fork 13k
Correctly check types in type assertions #9170
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
Conversation
@@ -5027,6 +5027,7 @@ namespace ts { | |||
function getTypeFromTupleTypeNode(node: TupleTypeNode): Type { | |||
const links = getNodeLinks(node); | |||
if (!links.resolvedType) { | |||
checkTupleType(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not the right fix. This function is simply for materializing the type, it isn't for the actual checking. The real problem is that checkAssertion
never calls checkSourceElement
on node.type
. You can prove that to yourself by observing that this doesn't generate an error either:
var x = <{ a: number, a: number }>undefined; // No duplicate identifier error
So, remove the line above and instead put a call to checkSourceElement(node.type)
in checkAssertion
.
Fixed. |
👍 |
var y = <(a : string = "") => any>(undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
👍 |
Fixes #9103.