-
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
…ntsType of Jsx
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9825,6 +9825,29 @@ namespace ts { | |
| })); | ||
| } | ||
|
|
||
| // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type | ||
| if (elemType.flags & TypeFlags.String) { | ||
| return anyType; | ||
| } | ||
| else if (elemType.flags & TypeFlags.StringLiteral) { | ||
| // If the elemType is a stringLiteral type, we can then provide a check and give | ||
| const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); | ||
| if (intrinsicElementsType !== unknownType) { | ||
| const stringLiteralTypeName = (<StringLiteralType>elemType).text; | ||
| const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); | ||
| if (intrinsicProp) { | ||
| return getTypeOfSymbol(intrinsicProp); | ||
| } | ||
| const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); | ||
| if (indexSignatureType) { | ||
| 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; | ||
| } | ||
| } | ||
|
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) | ||
| const elemInstanceType = getJsxElementInstanceType(node, elemType); | ||
|
|
||
|
|
||
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.
Finish sentence in comment