@@ -2219,7 +2219,7 @@ namespace ts {
22192219 const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
22202220 if (sourceFile) {
22212221 if (sourceFile.symbol) {
2222- if (resolvedModule.isExternalLibraryImport && !extensionIsTypeScript (resolvedModule.extension)) {
2222+ if (resolvedModule.isExternalLibraryImport && !extensionIsTS (resolvedModule.extension)) {
22232223 errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
22242224 }
22252225 // merged symbol is module declaration symbol combined with all augmentations
@@ -2240,7 +2240,7 @@ namespace ts {
22402240 }
22412241
22422242 // May be an untyped module. If so, ignore resolutionDiagnostic.
2243- if (resolvedModule && !resolutionExtensionIsTypeScriptOrJson (resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
2243+ if (resolvedModule && !resolutionExtensionIsTSOrJson (resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
22442244 if (isForAugmentation) {
22452245 const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
22462246 error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
@@ -2273,7 +2273,7 @@ namespace ts {
22732273 error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
22742274 }
22752275 else {
2276- const tsExtension = tryExtractTypeScriptExtension (moduleReference);
2276+ const tsExtension = tryExtractTSExtension (moduleReference);
22772277 if (tsExtension) {
22782278 const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
22792279 error(errorNode, diag, tsExtension, removeExtension(moduleReference, tsExtension));
@@ -3351,7 +3351,7 @@ namespace ts {
33513351 if (symbol) {
33523352 const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class;
33533353 id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
3354- if (isJavascriptConstructor (symbol.valueDeclaration)) {
3354+ if (isJSConstructor (symbol.valueDeclaration)) {
33553355 // Instance and static types share the same symbol; only add 'typeof' for the static side.
33563356 const isInstanceType = type === getInferredClassType(symbol) ? SymbolFlags.Type : SymbolFlags.Value;
33573357 return symbolToTypeNode(symbol, context, isInstanceType);
@@ -5563,7 +5563,7 @@ namespace ts {
55635563 const constraint = getBaseConstraintOfType(type);
55645564 return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint);
55655565 }
5566- return isJavascriptConstructorType (type);
5566+ return isJSConstructorType (type);
55675567 }
55685568
55695569 function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments | undefined {
@@ -5573,7 +5573,7 @@ namespace ts {
55735573 function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode> | undefined, location: Node): ReadonlyArray<Signature> {
55745574 const typeArgCount = length(typeArgumentNodes);
55755575 const isJavascript = isInJSFile(location);
5576- if (isJavascriptConstructorType (type) && !typeArgCount) {
5576+ if (isJSConstructorType (type) && !typeArgCount) {
55775577 return getSignaturesOfType(type, SignatureKind.Call);
55785578 }
55795579 return filter(getSignaturesOfType(type, SignatureKind.Construct),
@@ -5668,8 +5668,8 @@ namespace ts {
56685668 else if (baseConstructorType.flags & TypeFlags.Any) {
56695669 baseType = baseConstructorType;
56705670 }
5671- else if (isJavascriptConstructorType (baseConstructorType) && !baseTypeNode.typeArguments) {
5672- baseType = getJavascriptClassType (baseConstructorType.symbol) || anyType;
5671+ else if (isJSConstructorType (baseConstructorType) && !baseTypeNode.typeArguments) {
5672+ baseType = getJSClassType (baseConstructorType.symbol) || anyType;
56735673 }
56745674 else {
56755675 // The class derives from a "class-like" constructor function, check that we have at least one construct signature
@@ -10176,7 +10176,7 @@ namespace ts {
1017610176 }
1017710177 }
1017810178 let outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true);
10179- if (isJavascriptConstructor (declaration)) {
10179+ if (isJSConstructor (declaration)) {
1018010180 const templateTagParameters = getTypeParametersFromDeclaration(declaration as DeclarationWithTypeParameters);
1018110181 outerTypeParameters = addRange(outerTypeParameters, templateTagParameters);
1018210182 }
@@ -10862,13 +10862,13 @@ namespace ts {
1086210862 }
1086310863
1086410864 if (!ignoreReturnTypes) {
10865- const targetReturnType = (target.declaration && isJavascriptConstructor (target.declaration)) ?
10866- getJavascriptClassType (target.declaration.symbol)! : getReturnTypeOfSignature(target);
10865+ const targetReturnType = (target.declaration && isJSConstructor (target.declaration)) ?
10866+ getJSClassType (target.declaration.symbol)! : getReturnTypeOfSignature(target);
1086710867 if (targetReturnType === voidType) {
1086810868 return result;
1086910869 }
10870- const sourceReturnType = (source.declaration && isJavascriptConstructor (source.declaration)) ?
10871- getJavascriptClassType (source.declaration.symbol)! : getReturnTypeOfSignature(source);
10870+ const sourceReturnType = (source.declaration && isJSConstructor (source.declaration)) ?
10871+ getJSClassType (source.declaration.symbol)! : getReturnTypeOfSignature(source);
1087210872
1087310873 // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions
1087410874 const targetTypePredicate = getTypePredicateOfSignature(target);
@@ -12132,8 +12132,8 @@ namespace ts {
1213212132 return Ternary.True;
1213312133 }
1213412134
12135- const sourceIsJSConstructor = source.symbol && isJavascriptConstructor (source.symbol.valueDeclaration);
12136- const targetIsJSConstructor = target.symbol && isJavascriptConstructor (target.symbol.valueDeclaration);
12135+ const sourceIsJSConstructor = source.symbol && isJSConstructor (source.symbol.valueDeclaration);
12136+ const targetIsJSConstructor = target.symbol && isJSConstructor (target.symbol.valueDeclaration);
1213712137
1213812138 const sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === SignatureKind.Construct) ?
1213912139 SignatureKind.Call : kind);
@@ -15821,7 +15821,7 @@ namespace ts {
1582115821 if (isInJS && className) {
1582215822 const classSymbol = checkExpression(className).symbol;
1582315823 if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) {
15824- const classType = getJavascriptClassType (classSymbol);
15824+ const classType = getJSClassType (classSymbol);
1582515825 if (classType) {
1582615826 return getFlowTypeOfReference(node, classType);
1582715827 }
@@ -15834,7 +15834,7 @@ namespace ts {
1583415834 else if (isInJS &&
1583515835 (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) &&
1583615836 getJSDocClassTag(container)) {
15837- const classType = getJavascriptClassType (container.symbol);
15837+ const classType = getJSClassType (container.symbol);
1583815838 if (classType) {
1583915839 return getFlowTypeOfReference(node, classType);
1584015840 }
@@ -19851,7 +19851,7 @@ namespace ts {
1985119851 if (callSignatures.length) {
1985219852 const signature = resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp);
1985319853 if (!noImplicitAny) {
19854- if (signature.declaration && !isJavascriptConstructor (signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
19854+ if (signature.declaration && !isJSConstructor (signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
1985519855 error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
1985619856 }
1985719857 if (getThisTypeOfSignature(signature) === voidType) {
@@ -20134,7 +20134,7 @@ namespace ts {
2013420134 * Indicates whether a declaration can be treated as a constructor in a JavaScript
2013520135 * file.
2013620136 */
20137- function isJavascriptConstructor (node: Declaration | undefined): boolean {
20137+ function isJSConstructor (node: Declaration | undefined): boolean {
2013820138 if (node && isInJSFile(node)) {
2013920139 // If the node has a @class tag, treat it like a constructor.
2014020140 if (getJSDocClassTag(node)) return true;
@@ -20150,22 +20150,22 @@ namespace ts {
2015020150 return false;
2015120151 }
2015220152
20153- function isJavascriptConstructorType (type: Type) {
20153+ function isJSConstructorType (type: Type) {
2015420154 if (type.flags & TypeFlags.Object) {
2015520155 const resolved = resolveStructuredTypeMembers(<ObjectType>type);
20156- return resolved.callSignatures.length === 1 && isJavascriptConstructor (resolved.callSignatures[0].declaration);
20156+ return resolved.callSignatures.length === 1 && isJSConstructor (resolved.callSignatures[0].declaration);
2015720157 }
2015820158 return false;
2015920159 }
2016020160
20161- function getJavascriptClassType (symbol: Symbol): Type | undefined {
20161+ function getJSClassType (symbol: Symbol): Type | undefined {
2016220162 let inferred: Type | undefined;
20163- if (isJavascriptConstructor (symbol.valueDeclaration)) {
20163+ if (isJSConstructor (symbol.valueDeclaration)) {
2016420164 inferred = getInferredClassType(symbol);
2016520165 }
2016620166 const assigned = getAssignedClassType(symbol);
2016720167 const valueType = getTypeOfSymbol(symbol);
20168- if (valueType.symbol && !isInferredClassType(valueType) && isJavascriptConstructor (valueType.symbol.valueDeclaration)) {
20168+ if (valueType.symbol && !isInferredClassType(valueType) && isJSConstructor (valueType.symbol.valueDeclaration)) {
2016920169 inferred = getInferredClassType(valueType.symbol);
2017020170 }
2017120171 return assigned && inferred ?
@@ -20180,14 +20180,14 @@ namespace ts {
2018020180 isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
2018120181 isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
2018220182 if (assignmentSymbol) {
20183- const prototype = forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype );
20183+ const prototype = forEach(assignmentSymbol.declarations, getAssignedJSPrototype );
2018420184 if (prototype) {
2018520185 return checkExpression(prototype);
2018620186 }
2018720187 }
2018820188 }
2018920189
20190- function getAssignedJavascriptPrototype (node: Node) {
20190+ function getAssignedJSPrototype (node: Node) {
2019120191 if (!node.parent) {
2019220192 return false;
2019320193 }
@@ -20248,7 +20248,7 @@ namespace ts {
2024820248 if (!funcSymbol && node.expression.kind === SyntaxKind.Identifier) {
2024920249 funcSymbol = getResolvedSymbol(node.expression as Identifier);
2025020250 }
20251- const type = funcSymbol && getJavascriptClassType (funcSymbol);
20251+ const type = funcSymbol && getJSClassType (funcSymbol);
2025220252 if (type) {
2025320253 return signature.target ? instantiateType(type, signature.mapper) : type;
2025420254 }
@@ -20897,7 +20897,7 @@ namespace ts {
2089720897 return undefined;
2089820898 }
2089920899 if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
20900- !(isJavascriptConstructor (func) && aggregatedTypes.some(t => t.symbol === func.symbol))) {
20900+ !(isJSConstructor (func) && aggregatedTypes.some(t => t.symbol === func.symbol))) {
2090120901 // Javascript "callable constructors", containing eg `if (!(this instanceof A)) return new A()` should not add undefined
2090220902 pushIfUnique(aggregatedTypes, undefinedType);
2090320903 }
@@ -25811,7 +25811,7 @@ namespace ts {
2581125811 // that the base type is a class or interface type (and not, for example, an anonymous object type).
2581225812 // (Javascript constructor functions have this property trivially true since their return type is ignored.)
2581325813 const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
25814- if (forEach(constructors, sig => !isJavascriptConstructor (sig.declaration) && getReturnTypeOfSignature(sig) !== baseType)) {
25814+ if (forEach(constructors, sig => !isJSConstructor (sig.declaration) && getReturnTypeOfSignature(sig) !== baseType)) {
2581525815 error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type);
2581625816 }
2581725817 }
0 commit comments