22
33/* @internal */
44namespace ts {
5+ const ambientModuleSymbolRegex = /^".+"$/;
6+
57 let nextSymbolId = 1;
68 let nextNodeId = 1;
79 let nextMergeId = 1;
@@ -100,6 +102,7 @@ namespace ts {
100102 getAliasedSymbol: resolveAlias,
101103 getEmitResolver,
102104 getExportsOfModule: getExportsOfModuleAsArray,
105+ getAmbientModules,
103106
104107 getJsxElementAttributesType,
105108 getJsxIntrinsicTagNames,
@@ -143,6 +146,7 @@ namespace ts {
143146
144147 const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
145148 const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
149+ const resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
146150
147151 const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
148152
@@ -3346,7 +3350,13 @@ namespace ts {
33463350 // Otherwise, fall back to 'any'.
33473351 else {
33483352 if (compilerOptions.noImplicitAny) {
3349- error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol));
3353+ if (setter) {
3354+ error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
3355+ }
3356+ else {
3357+ Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
3358+ error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
3359+ }
33503360 }
33513361 type = anyType;
33523362 }
@@ -5372,7 +5382,7 @@ namespace ts {
53725382 while (i > 0) {
53735383 i--;
53745384 if (isSubtypeOfAny(types[i], types)) {
5375- types.splice(i, 1 );
5385+ orderedRemoveItemAt(types, i );
53765386 }
53775387 }
53785388 }
@@ -8752,7 +8762,7 @@ namespace ts {
87528762 // The location isn't a reference to the given symbol, meaning we're being asked
87538763 // a hypothetical question of what type the symbol would have if there was a reference
87548764 // to it at the given location. Since we have no control flow information for the
8755- // hypotherical reference (control flow information is created and attached by the
8765+ // hypothetical reference (control flow information is created and attached by the
87568766 // binder), we simply return the declared type of the symbol.
87578767 return getTypeOfSymbol(symbol);
87588768 }
@@ -12223,10 +12233,10 @@ namespace ts {
1222312233 // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work
1222412234 // to correctly fill the candidatesOutArray.
1222512235 const cached = links.resolvedSignature;
12226- if (cached && cached !== anySignature && !candidatesOutArray) {
12236+ if (cached && cached !== resolvingSignature && !candidatesOutArray) {
1222712237 return cached;
1222812238 }
12229- links.resolvedSignature = anySignature ;
12239+ links.resolvedSignature = resolvingSignature ;
1223012240 const result = resolveSignature(node, candidatesOutArray);
1223112241 // If signature resolution originated in control flow type analysis (for example to compute the
1223212242 // assigned type in a flow assignment) we don't cache the result as it may be based on temporary
@@ -12238,7 +12248,7 @@ namespace ts {
1223812248 function getResolvedOrAnySignature(node: CallLikeExpression) {
1223912249 // If we're already in the process of resolving the given signature, don't resolve again as
1224012250 // that could cause infinite recursion. Instead, return anySignature.
12241- return getNodeLinks(node).resolvedSignature === anySignature ? anySignature : getResolvedSignature(node);
12251+ return getNodeLinks(node).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(node);
1224212252 }
1224312253
1224412254 function getInferredClassType(symbol: Symbol) {
@@ -20013,5 +20023,15 @@ namespace ts {
2001320023 return true;
2001420024 }
2001520025 }
20026+
20027+ function getAmbientModules(): Symbol[] {
20028+ const result: Symbol[] = [];
20029+ for (const sym in globals) {
20030+ if (ambientModuleSymbolRegex.test(sym)) {
20031+ result.push(globals[sym]);
20032+ }
20033+ }
20034+ return result;
20035+ }
2001620036 }
2001720037}
0 commit comments