-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix 8549: Using variable as Jsx tagname #9337
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
Changes from 1 commit
24f3f18
49957a1
1369108
2e39d1a
d5976a5
e117d02
7a3f88a
0e17ac8
cc4a5c7
ae38ea5
d07b27e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9628,8 +9628,9 @@ namespace ts { | |
| /** | ||
| * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name | ||
| */ | ||
| function isJsxIntrinsicIdentifier(tagName: LeftHandSideExpression) { | ||
| if (tagName.kind === SyntaxKind.PropertyAccessExpression) { | ||
| function isJsxIntrinsicIdentifier(tagName: JsxTagNameExpression) { | ||
| // TODO (yuisu): comment | ||
| if (tagName.kind === SyntaxKind.PropertyAccessExpression || tagName.kind === SyntaxKind.ThisKeyword) { | ||
| return false; | ||
| } | ||
| else { | ||
|
|
@@ -9830,7 +9831,7 @@ namespace ts { | |
| return anyType; | ||
| } | ||
| else if (elemType.flags & TypeFlags.StringLiteral) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finish sentence in comment |
||
| // If the elemType is a stringLiteral type, we can then provide a check and give | ||
| // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type | ||
| const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); | ||
| if (intrinsicElementsType !== unknownType) { | ||
| const stringLiteralTypeName = (<StringLiteralType>elemType).text; | ||
|
|
@@ -9843,9 +9844,9 @@ namespace ts { | |
| return indexSignatureType; | ||
| } | ||
| error(node, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements) | ||
| // If we need to report an error, we already done so here. So just return any to prevent any more error downstream | ||
| return anyType; | ||
| } | ||
| // If we need to report an error, we already done so here. So just return any to prevent any more error downstream | ||
| return anyType; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look like you return Why not make it if (intrinsicElementsType === unknownType) {
return unknownType;
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is actually intended that if |
||
| } | ||
|
|
||
| // Get the element instance type (the result of newing or invoking this tag) | ||
|
|
||
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.
The
elsecase here needs to be hardened since it assumestagName: Identifier