Skip to content

Commit 957b948

Browse files
author
Kanchalai Tanglertsampan
committed
Split get attributes of intrinsic element and custom element
1 parent d2f7764 commit 957b948

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/compiler/checker.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11115,11 +11115,10 @@ namespace ts {
1111511115
}
1111611116

1111711117
/**
11118-
* Get the attributes type which is the type that indicate which attributes are valid on the given JSXOpeningLikeElement.
11119-
* @param node a JSXOpeningLikeElement node
11120-
* @return an attributes type of the given node
11118+
*
11119+
* @param node
1112111120
*/
11122-
function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type {
11121+
function getIntrinsicJsxElementAttributesType(node: JsxOpeningElement): Type {
1112311122
const links = getNodeLinks(node);
1112411123
if (!links.resolvedJsxElementAttributesType) {
1112511124
if (isJsxIntrinsicIdentifier(node.tagName)) {
@@ -11134,14 +11133,31 @@ namespace ts {
1113411133
return links.resolvedJsxElementAttributesType = unknownType;
1113511134
}
1113611135
}
11137-
else {
11136+
}
11137+
return links.resolvedJsxElementAttributesType;
11138+
}
11139+
11140+
function getCustomJsxElementAttributesType(node: JsxOpeningElement): Type {
11141+
const links = getNodeLinks(node);
11142+
if (!links.resolvedJsxElementAttributesType) {
11143+
if (!isJsxIntrinsicIdentifier(node.tagName)) {
1113811144
const elemClassType = getJsxGlobalElementClassType();
1113911145
return links.resolvedJsxElementAttributesType = resolveJsxElementAttributesType(node, undefined, elemClassType);
1114011146
}
1114111147
}
1114211148
return links.resolvedJsxElementAttributesType;
1114311149
}
1114411150

11151+
/**
11152+
* Get the attributes type which is the type that indicate which attributes are valid on the given JSXOpeningLikeElement.
11153+
* @param node a JSXOpeningLikeElement node
11154+
* @return an attributes type of the given node
11155+
*/
11156+
function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type {
11157+
const intrinsicAttributesType = getIntrinsicJsxElementAttributesType(node);
11158+
return intrinsicAttributesType ? intrinsicAttributesType : getCustomJsxElementAttributesType(node);
11159+
}
11160+
1114511161
/**
1114611162
* Given a JSX attribute, returns the symbol for the corresponds property
1114711163
* of the element attributes type. Will return unknownSymbol for attributes

0 commit comments

Comments
 (0)