@@ -165,7 +165,7 @@ namespace ts {
165165 }
166166 };
167167
168- let JsxNames = {
168+ const JsxNames = {
169169 JSX: "JSX",
170170 IntrinsicElements: "IntrinsicElements",
171171 ElementClass: "ElementClass",
@@ -5578,6 +5578,7 @@ namespace ts {
55785578 case SyntaxKind.JsxAttribute:
55795579 case SyntaxKind.JsxSpreadAttribute:
55805580 case SyntaxKind.JsxOpeningElement:
5581+ case SyntaxKind.JsxExpression:
55815582 return forEachChild(node, isAssignedIn);
55825583 }
55835584 return false;
@@ -6774,8 +6775,7 @@ namespace ts {
67746775 return false;
67756776 }
67766777 else {
6777- let firstChar = (<Identifier>tagName).text.charAt(0);
6778- return firstChar.toLowerCase() === firstChar;
6778+ return isIntrinsicJsxName((<Identifier>tagName).text);
67796779 }
67806780 }
67816781
@@ -6836,10 +6836,7 @@ namespace ts {
68366836 /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present.
68376837 function getJsxIntrinsicElementsType() {
68386838 if (!jsxIntrinsicElementsType) {
6839- let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, undefined);
6840- let intrinsicsSymbol = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.IntrinsicElements, SymbolFlags.Type);
6841- let intrinsicsType = intrinsicsSymbol && getDeclaredTypeOfSymbol(intrinsicsSymbol);
6842- jsxIntrinsicElementsType = intrinsicsType || unknownType;
6839+ jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType;
68436840 }
68446841 return jsxIntrinsicElementsType;
68456842 }
@@ -6977,18 +6974,23 @@ namespace ts {
69776974 let attribProperties = attribPropType && getPropertiesOfType(attribPropType);
69786975
69796976 if (attribProperties) {
6977+ // Element Attributes has zero properties, so the element attributes type will be the class instance type
69806978 if (attribProperties.length === 0) {
69816979 return '';
69826980 }
6981+ // Element Attributes has one property, so the element attributes type will be the type of the corresponding
6982+ // property of the class instance type
69836983 else if (attribProperties.length === 1) {
69846984 return attribProperties[0].name;
69856985 }
6986+ // More than one property on ElementAttributesProperty is an error
69866987 else {
69876988 error(attribsPropTypeSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer);
69886989 return undefined;
69896990 }
69906991 }
69916992 else {
6993+ // No interface exists, so the element attributes type will be an implicit any
69926994 return undefined;
69936995 }
69946996 }
@@ -7044,7 +7046,7 @@ namespace ts {
70447046 return links.resolvedJsxType = getIndexTypeOfSymbol(sym, IndexKind.String);
70457047 }
70467048 else {
7047- // Resolution failed
7049+ // Resolution failed, so we don't know
70487050 return links.resolvedJsxType = anyType;
70497051 }
70507052 }
@@ -7063,16 +7065,12 @@ namespace ts {
70637065 return prop || unknownSymbol;
70647066 }
70657067
7068+ let jsxElementClassType: Type = undefined;
70667069 function getJsxGlobalElementClassType(): Type {
7067- let jsxNS = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined);
7068- if (jsxNS) {
7069- let sym = getSymbol(jsxNS.exports, JsxNames.ElementClass, SymbolFlags.Type);
7070- let elemClassType = sym && getDeclaredTypeOfSymbol(sym);
7071- return elemClassType;
7072- }
7073- else {
7074- return undefined;
7070+ if(!jsxElementClassType) {
7071+ jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass);
70757072 }
7073+ return jsxElementClassType;
70767074 }
70777075
70787076 /// Returns all the properties of the Jsx.IntrinsicElements interface
@@ -7137,8 +7135,7 @@ namespace ts {
71377135 return checkExpression(node.expression);
71387136 }
71397137 else {
7140- /// <Foo enabled /> is shorthand for <Foo enabled={true} />
7141- return booleanType;
7138+ return unknownType;
71427139 }
71437140 }
71447141
0 commit comments