Fix getIntrinsicAttributesTypeFromJsxOpeningLikeElement

Use `getIndexTypeOfType`+`getDeclaredTypeOfSymbol` instead of `getIndexInfoOfSymbol`.

Fixes #34730.
This commit is contained in:
Eli Barzilay 2019-11-16 04:13:51 -05:00
parent cfefe841b7
commit 20b246c83a
5 changed files with 41 additions and 1 deletions

View file

@ -22563,7 +22563,8 @@ namespace ts {
return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
}
else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) {
return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, IndexKind.String)!.type;
return links.resolvedJsxElementAttributesType =
getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), IndexKind.String)!;
}
else {
return links.resolvedJsxElementAttributesType = errorType;

View file

@ -0,0 +1,10 @@
//// [index.tsx]
declare namespace JSX {
interface IntrinsicElements extends Record<string, any> {}
}
<a />;
//// [index.jsx]
<a />;

View file

@ -0,0 +1,12 @@
=== tests/cases/compiler/index.tsx ===
declare namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
interface IntrinsicElements extends Record<string, any> {}
>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 0, 23))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
}
<a />;
>a : Symbol(JSX.IntrinsicElements, Decl(index.tsx, 0, 23))

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/index.tsx ===
declare namespace JSX {
interface IntrinsicElements extends Record<string, any> {}
}
<a />;
><a /> : error
>a : any

View file

@ -0,0 +1,8 @@
// @jsx: preserve
// @filename: index.tsx
declare namespace JSX {
interface IntrinsicElements extends Record<string, any> {}
}
<a />;