@@ -2219,7 +2219,7 @@ namespace ts {
2219
2219
const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
2220
2220
if (sourceFile) {
2221
2221
if (sourceFile.symbol) {
2222
- if (resolvedModule.isExternalLibraryImport && !extensionIsTypeScript (resolvedModule.extension)) {
2222
+ if (resolvedModule.isExternalLibraryImport && !extensionIsTS (resolvedModule.extension)) {
2223
2223
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
2224
2224
}
2225
2225
// merged symbol is module declaration symbol combined with all augmentations
@@ -2240,7 +2240,7 @@ namespace ts {
2240
2240
}
2241
2241
2242
2242
// 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) {
2244
2244
if (isForAugmentation) {
2245
2245
const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
2246
2246
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
@@ -2273,7 +2273,7 @@ namespace ts {
2273
2273
error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
2274
2274
}
2275
2275
else {
2276
- const tsExtension = tryExtractTypeScriptExtension (moduleReference);
2276
+ const tsExtension = tryExtractTSExtension (moduleReference);
2277
2277
if (tsExtension) {
2278
2278
const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
2279
2279
error(errorNode, diag, tsExtension, removeExtension(moduleReference, tsExtension));
@@ -3351,7 +3351,7 @@ namespace ts {
3351
3351
if (symbol) {
3352
3352
const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class;
3353
3353
id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
3354
- if (isJavascriptConstructor (symbol.valueDeclaration)) {
3354
+ if (isJSConstructor (symbol.valueDeclaration)) {
3355
3355
// Instance and static types share the same symbol; only add 'typeof' for the static side.
3356
3356
const isInstanceType = type === getInferredClassType(symbol) ? SymbolFlags.Type : SymbolFlags.Value;
3357
3357
return symbolToTypeNode(symbol, context, isInstanceType);
@@ -5563,7 +5563,7 @@ namespace ts {
5563
5563
const constraint = getBaseConstraintOfType(type);
5564
5564
return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint);
5565
5565
}
5566
- return isJavascriptConstructorType (type);
5566
+ return isJSConstructorType (type);
5567
5567
}
5568
5568
5569
5569
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments | undefined {
@@ -5573,7 +5573,7 @@ namespace ts {
5573
5573
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode> | undefined, location: Node): ReadonlyArray<Signature> {
5574
5574
const typeArgCount = length(typeArgumentNodes);
5575
5575
const isJavascript = isInJSFile(location);
5576
- if (isJavascriptConstructorType (type) && !typeArgCount) {
5576
+ if (isJSConstructorType (type) && !typeArgCount) {
5577
5577
return getSignaturesOfType(type, SignatureKind.Call);
5578
5578
}
5579
5579
return filter(getSignaturesOfType(type, SignatureKind.Construct),
@@ -5668,8 +5668,8 @@ namespace ts {
5668
5668
else if (baseConstructorType.flags & TypeFlags.Any) {
5669
5669
baseType = baseConstructorType;
5670
5670
}
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;
5673
5673
}
5674
5674
else {
5675
5675
// The class derives from a "class-like" constructor function, check that we have at least one construct signature
@@ -10176,7 +10176,7 @@ namespace ts {
10176
10176
}
10177
10177
}
10178
10178
let outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true);
10179
- if (isJavascriptConstructor (declaration)) {
10179
+ if (isJSConstructor (declaration)) {
10180
10180
const templateTagParameters = getTypeParametersFromDeclaration(declaration as DeclarationWithTypeParameters);
10181
10181
outerTypeParameters = addRange(outerTypeParameters, templateTagParameters);
10182
10182
}
@@ -10862,13 +10862,13 @@ namespace ts {
10862
10862
}
10863
10863
10864
10864
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);
10867
10867
if (targetReturnType === voidType) {
10868
10868
return result;
10869
10869
}
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);
10872
10872
10873
10873
// The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions
10874
10874
const targetTypePredicate = getTypePredicateOfSignature(target);
@@ -12132,8 +12132,8 @@ namespace ts {
12132
12132
return Ternary.True;
12133
12133
}
12134
12134
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);
12137
12137
12138
12138
const sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === SignatureKind.Construct) ?
12139
12139
SignatureKind.Call : kind);
@@ -15821,7 +15821,7 @@ namespace ts {
15821
15821
if (isInJS && className) {
15822
15822
const classSymbol = checkExpression(className).symbol;
15823
15823
if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) {
15824
- const classType = getJavascriptClassType (classSymbol);
15824
+ const classType = getJSClassType (classSymbol);
15825
15825
if (classType) {
15826
15826
return getFlowTypeOfReference(node, classType);
15827
15827
}
@@ -15834,7 +15834,7 @@ namespace ts {
15834
15834
else if (isInJS &&
15835
15835
(container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) &&
15836
15836
getJSDocClassTag(container)) {
15837
- const classType = getJavascriptClassType (container.symbol);
15837
+ const classType = getJSClassType (container.symbol);
15838
15838
if (classType) {
15839
15839
return getFlowTypeOfReference(node, classType);
15840
15840
}
@@ -19851,7 +19851,7 @@ namespace ts {
19851
19851
if (callSignatures.length) {
19852
19852
const signature = resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp);
19853
19853
if (!noImplicitAny) {
19854
- if (signature.declaration && !isJavascriptConstructor (signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
19854
+ if (signature.declaration && !isJSConstructor (signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
19855
19855
error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
19856
19856
}
19857
19857
if (getThisTypeOfSignature(signature) === voidType) {
@@ -20134,7 +20134,7 @@ namespace ts {
20134
20134
* Indicates whether a declaration can be treated as a constructor in a JavaScript
20135
20135
* file.
20136
20136
*/
20137
- function isJavascriptConstructor (node: Declaration | undefined): boolean {
20137
+ function isJSConstructor (node: Declaration | undefined): boolean {
20138
20138
if (node && isInJSFile(node)) {
20139
20139
// If the node has a @class tag, treat it like a constructor.
20140
20140
if (getJSDocClassTag(node)) return true;
@@ -20150,22 +20150,22 @@ namespace ts {
20150
20150
return false;
20151
20151
}
20152
20152
20153
- function isJavascriptConstructorType (type: Type) {
20153
+ function isJSConstructorType (type: Type) {
20154
20154
if (type.flags & TypeFlags.Object) {
20155
20155
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);
20157
20157
}
20158
20158
return false;
20159
20159
}
20160
20160
20161
- function getJavascriptClassType (symbol: Symbol): Type | undefined {
20161
+ function getJSClassType (symbol: Symbol): Type | undefined {
20162
20162
let inferred: Type | undefined;
20163
- if (isJavascriptConstructor (symbol.valueDeclaration)) {
20163
+ if (isJSConstructor (symbol.valueDeclaration)) {
20164
20164
inferred = getInferredClassType(symbol);
20165
20165
}
20166
20166
const assigned = getAssignedClassType(symbol);
20167
20167
const valueType = getTypeOfSymbol(symbol);
20168
- if (valueType.symbol && !isInferredClassType(valueType) && isJavascriptConstructor (valueType.symbol.valueDeclaration)) {
20168
+ if (valueType.symbol && !isInferredClassType(valueType) && isJSConstructor (valueType.symbol.valueDeclaration)) {
20169
20169
inferred = getInferredClassType(valueType.symbol);
20170
20170
}
20171
20171
return assigned && inferred ?
@@ -20180,14 +20180,14 @@ namespace ts {
20180
20180
isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
20181
20181
isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
20182
20182
if (assignmentSymbol) {
20183
- const prototype = forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype );
20183
+ const prototype = forEach(assignmentSymbol.declarations, getAssignedJSPrototype );
20184
20184
if (prototype) {
20185
20185
return checkExpression(prototype);
20186
20186
}
20187
20187
}
20188
20188
}
20189
20189
20190
- function getAssignedJavascriptPrototype (node: Node) {
20190
+ function getAssignedJSPrototype (node: Node) {
20191
20191
if (!node.parent) {
20192
20192
return false;
20193
20193
}
@@ -20248,7 +20248,7 @@ namespace ts {
20248
20248
if (!funcSymbol && node.expression.kind === SyntaxKind.Identifier) {
20249
20249
funcSymbol = getResolvedSymbol(node.expression as Identifier);
20250
20250
}
20251
- const type = funcSymbol && getJavascriptClassType (funcSymbol);
20251
+ const type = funcSymbol && getJSClassType (funcSymbol);
20252
20252
if (type) {
20253
20253
return signature.target ? instantiateType(type, signature.mapper) : type;
20254
20254
}
@@ -20897,7 +20897,7 @@ namespace ts {
20897
20897
return undefined;
20898
20898
}
20899
20899
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))) {
20901
20901
// Javascript "callable constructors", containing eg `if (!(this instanceof A)) return new A()` should not add undefined
20902
20902
pushIfUnique(aggregatedTypes, undefinedType);
20903
20903
}
@@ -25811,7 +25811,7 @@ namespace ts {
25811
25811
// that the base type is a class or interface type (and not, for example, an anonymous object type).
25812
25812
// (Javascript constructor functions have this property trivially true since their return type is ignored.)
25813
25813
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)) {
25815
25815
error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type);
25816
25816
}
25817
25817
}
0 commit comments