1
- /// <reference path="moduleNameResolver.ts"/>
1
+ /// <reference path="moduleNameResolver.ts"/>
2
2
/// <reference path="binder.ts"/>
3
3
4
4
/* @internal */
@@ -590,7 +590,7 @@ namespace ts {
590
590
return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(<SourceFile>node);
591
591
}
592
592
593
- function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol {
593
+ function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol {
594
594
if (meaning) {
595
595
const symbol = symbols.get(name);
596
596
if (symbol) {
@@ -3362,7 +3362,8 @@ namespace ts {
3362
3362
const type = checkDeclarationInitializer(declaration);
3363
3363
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
3364
3364
}
3365
- else if (isJsxAttribute(declaration)) {
3365
+
3366
+ if (isJsxAttribute(declaration)) {
3366
3367
// if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true.
3367
3368
// I.e <Elem attr /> is sugar for <Elem attr={true} />
3368
3369
return trueType;
@@ -7003,7 +7004,8 @@ namespace ts {
7003
7004
// If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive.
7004
7005
return (<JsxAttribute>node).initializer && isContextSensitive((<JsxAttribute>node).initializer);
7005
7006
case SyntaxKind.JsxExpression:
7006
- return isContextSensitive((<JsxExpression>node).expression);
7007
+ // It is possible to that node.expression is undefined (e.g <div x={} />)
7008
+ return (<JsxExpression>node).expression && isContextSensitive((<JsxExpression>node).expression);
7007
7009
}
7008
7010
7009
7011
return false;
@@ -13258,10 +13260,7 @@ namespace ts {
13258
13260
return false;
13259
13261
}
13260
13262
}
13261
- if (checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage)) {
13262
- return true;
13263
- }
13264
- return false;
13263
+ return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage);
13265
13264
}
13266
13265
13267
13266
function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map<RelationComparisonResult>, excludeArgument: boolean[], reportErrors: boolean) {
@@ -13350,7 +13349,7 @@ namespace ts {
13350
13349
return undefined;
13351
13350
}
13352
13351
else if (isJsxOpeningLikeElement(node)) {
13353
- args = node.attributes.properties.length > 0 ? [node.attributes] : [] ;
13352
+ args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray ;
13354
13353
}
13355
13354
else {
13356
13355
args = node.arguments || emptyArray;
@@ -14164,23 +14163,7 @@ namespace ts {
14164
14163
*/
14165
14164
function getResolvedJsxStatelessFunctionSignature(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature {
14166
14165
Debug.assert(!(elementType.flags & TypeFlags.Union));
14167
- const links = getNodeLinks(openingLikeElement);
14168
- // If getResolvedSignature has already been called, we will have cached the resolvedSignature.
14169
- // However, it is possible that either candidatesOutArray was not passed in the first time,
14170
- // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work
14171
- // to correctly fill the candidatesOutArray.
14172
- const cached = links.resolvedSignature;
14173
- if (cached && cached !== resolvingSignature && !candidatesOutArray) {
14174
- return cached;
14175
- }
14176
- links.resolvedSignature = resolvingSignature;
14177
-
14178
14166
const callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray);
14179
- links.resolvedSignature = callSignature;
14180
- // If signature resolution originated in control flow type analysis (for example to compute the
14181
- // assigned type in a flow assignment) we don't cache the result as it may be based on temporary
14182
- // types from the control flow analysis.
14183
- links.resolvedSignature = flowLoopStart === flowLoopCount ? callSignature : cached;
14184
14167
return callSignature;
14185
14168
}
14186
14169
@@ -14198,8 +14181,7 @@ namespace ts {
14198
14181
const types = (elementType as UnionType).types;
14199
14182
let result: Signature;
14200
14183
for (const type of types) {
14201
- // This is mainly to fill in all the candidates if there is one.
14202
- result = result && resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray);
14184
+ result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray);
14203
14185
}
14204
14186
14205
14187
return result;
@@ -14227,6 +14209,7 @@ namespace ts {
14227
14209
return resolveDecorator(<Decorator>node, candidatesOutArray);
14228
14210
case SyntaxKind.JsxOpeningElement:
14229
14211
case SyntaxKind.JsxSelfClosingElement:
14212
+ // This code-path is called by language service
14230
14213
return resolveStatelessJsxOpeningLikeElement(<JsxOpeningLikeElement>node, checkExpression((<JsxOpeningLikeElement>node).tagName), candidatesOutArray);
14231
14214
}
14232
14215
Debug.fail("Branch in 'resolveSignature' should be unreachable.");
0 commit comments