@@ -840,15 +840,6 @@ namespace ts {
840
840
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier);
841
841
}
842
842
843
- function getMemberOfModuleVariable(moduleSymbol: Symbol, name: string): Symbol {
844
- if (moduleSymbol.flags & SymbolFlags.Variable) {
845
- const typeAnnotation = (<VariableDeclaration>moduleSymbol.valueDeclaration).type;
846
- if (typeAnnotation) {
847
- return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name);
848
- }
849
- }
850
- }
851
-
852
843
// This function creates a synthetic symbol that combines the value side of one symbol with the
853
844
// type/namespace side of another symbol. Consider this example:
854
845
//
@@ -1084,7 +1075,6 @@ namespace ts {
1084
1075
}
1085
1076
1086
1077
const moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
1087
- const searchPath = getDirectoryPath(getSourceFile(location).fileName);
1088
1078
1089
1079
// Module names are escaped in our symbol table. However, string literal values aren't.
1090
1080
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
@@ -2204,65 +2194,15 @@ namespace ts {
2204
2194
}
2205
2195
2206
2196
function isDeclarationVisible(node: Declaration): boolean {
2207
- function getContainingExternalModule(node: Node) {
2208
- for (; node; node = node.parent) {
2209
- if (node.kind === SyntaxKind.ModuleDeclaration) {
2210
- if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
2211
- return node;
2212
- }
2213
- }
2214
- else if (node.kind === SyntaxKind.SourceFile) {
2215
- return isExternalOrCommonJsModule(<SourceFile>node) ? node : undefined;
2216
- }
2197
+ if (node) {
2198
+ const links = getNodeLinks(node);
2199
+ if (links.isVisible === undefined) {
2200
+ links.isVisible = !!determineIfDeclarationIsVisible();
2217
2201
}
2218
- Debug.fail("getContainingModule cant reach here") ;
2202
+ return links.isVisible ;
2219
2203
}
2220
2204
2221
- function isUsedInExportAssignment(node: Node) {
2222
- // Get source File and see if it is external module and has export assigned symbol
2223
- const externalModule = getContainingExternalModule(node);
2224
- let exportAssignmentSymbol: Symbol;
2225
- let resolvedExportSymbol: Symbol;
2226
- if (externalModule) {
2227
- // This is export assigned symbol node
2228
- const externalModuleSymbol = getSymbolOfNode(externalModule);
2229
- exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol);
2230
- const symbolOfNode = getSymbolOfNode(node);
2231
- if (isSymbolUsedInExportAssignment(symbolOfNode)) {
2232
- return true;
2233
- }
2234
-
2235
- // if symbolOfNode is alias declaration, resolve the symbol declaration and check
2236
- if (symbolOfNode.flags & SymbolFlags.Alias) {
2237
- return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode));
2238
- }
2239
- }
2240
-
2241
- // Check if the symbol is used in export assignment
2242
- function isSymbolUsedInExportAssignment(symbol: Symbol) {
2243
- if (exportAssignmentSymbol === symbol) {
2244
- return true;
2245
- }
2246
-
2247
- if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & SymbolFlags.Alias)) {
2248
- // if export assigned symbol is alias declaration, resolve the alias
2249
- resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol);
2250
- if (resolvedExportSymbol === symbol) {
2251
- return true;
2252
- }
2253
-
2254
- // Container of resolvedExportSymbol is visible
2255
- return forEach(resolvedExportSymbol.declarations, (current: Node) => {
2256
- while (current) {
2257
- if (current === node) {
2258
- return true;
2259
- }
2260
- current = current.parent;
2261
- }
2262
- });
2263
- }
2264
- }
2265
- }
2205
+ return false;
2266
2206
2267
2207
function determineIfDeclarationIsVisible() {
2268
2208
switch (node.kind) {
@@ -2341,14 +2281,6 @@ namespace ts {
2341
2281
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
2342
2282
}
2343
2283
}
2344
-
2345
- if (node) {
2346
- const links = getNodeLinks(node);
2347
- if (links.isVisible === undefined) {
2348
- links.isVisible = !!determineIfDeclarationIsVisible();
2349
- }
2350
- return links.isVisible;
2351
- }
2352
2284
}
2353
2285
2354
2286
function collectLinkedAliases(node: Identifier): Node[] {
@@ -3394,14 +3326,6 @@ namespace ts {
3394
3326
}
3395
3327
}
3396
3328
3397
- function addInheritedSignatures(signatures: Signature[], baseSignatures: Signature[]) {
3398
- if (baseSignatures) {
3399
- for (const signature of baseSignatures) {
3400
- signatures.push(signature);
3401
- }
3402
- }
3403
- }
3404
-
3405
3329
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
3406
3330
if (!(<InterfaceTypeWithDeclaredMembers>type).declaredProperties) {
3407
3331
const symbol = type.symbol;
@@ -3890,25 +3814,6 @@ namespace ts {
3890
3814
function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] {
3891
3815
return getSignaturesOfStructuredType(getApparentType(type), kind);
3892
3816
}
3893
-
3894
- function typeHasConstructSignatures(type: Type): boolean {
3895
- const apparentType = getApparentType(type);
3896
- if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) {
3897
- const resolved = resolveStructuredTypeMembers(<ObjectType>type);
3898
- return resolved.constructSignatures.length > 0;
3899
- }
3900
- return false;
3901
- }
3902
-
3903
- function typeHasCallOrConstructSignatures(type: Type): boolean {
3904
- const apparentType = getApparentType(type);
3905
- if (apparentType.flags & TypeFlags.StructuredType) {
3906
- const resolved = resolveStructuredTypeMembers(<ObjectType>type);
3907
- return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0;
3908
- }
3909
- return false;
3910
- }
3911
-
3912
3817
function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type {
3913
3818
if (type.flags & TypeFlags.StructuredType) {
3914
3819
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
@@ -4410,10 +4315,6 @@ namespace ts {
4410
4315
return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity);
4411
4316
}
4412
4317
4413
- function tryGetGlobalType(name: string, arity = 0): ObjectType {
4414
- return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity);
4415
- }
4416
-
4417
4318
/**
4418
4319
* Returns a type that is inside a namespace at the global scope, e.g.
4419
4320
* getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type
@@ -6299,12 +6200,8 @@ namespace ts {
6299
6200
}
6300
6201
6301
6202
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
6302
- const inferences: TypeInferences[] = [];
6303
- for (const unused of typeParameters) {
6304
- inferences.push({
6305
- primary: undefined, secondary: undefined, isFixed: false
6306
- });
6307
- }
6203
+ const inferences = map(typeParameters, createTypeInferencesObject);
6204
+
6308
6205
return {
6309
6206
typeParameters,
6310
6207
inferUnionTypes,
@@ -6313,6 +6210,14 @@ namespace ts {
6313
6210
};
6314
6211
}
6315
6212
6213
+ function createTypeInferencesObject(): TypeInferences {
6214
+ return {
6215
+ primary: undefined,
6216
+ secondary: undefined,
6217
+ isFixed: false,
6218
+ };
6219
+ }
6220
+
6316
6221
function inferTypes(context: InferenceContext, source: Type, target: Type) {
6317
6222
let sourceStack: Type[];
6318
6223
let targetStack: Type[];
@@ -6583,10 +6488,6 @@ namespace ts {
6583
6488
return context.inferredTypes;
6584
6489
}
6585
6490
6586
- function hasAncestor(node: Node, kind: SyntaxKind): boolean {
6587
- return getAncestor(node, kind) !== undefined;
6588
- }
6589
-
6590
6491
// EXPRESSION TYPE CHECKING
6591
6492
6592
6493
function getResolvedSymbol(node: Identifier): Symbol {
@@ -8206,7 +8107,6 @@ namespace ts {
8206
8107
/// type or factory function.
8207
8108
/// Otherwise, returns unknownSymbol.
8208
8109
function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
8209
- const flags: JsxFlags = JsxFlags.UnknownElement;
8210
8110
const links = getNodeLinks(node);
8211
8111
if (!links.resolvedSymbol) {
8212
8112
if (isJsxIntrinsicIdentifier(node.tagName)) {
@@ -14479,16 +14379,6 @@ namespace ts {
14479
14379
}
14480
14380
}
14481
14381
14482
- function getModuleStatements(node: Declaration): Statement[] {
14483
- if (node.kind === SyntaxKind.SourceFile) {
14484
- return (<SourceFile>node).statements;
14485
- }
14486
- if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).body.kind === SyntaxKind.ModuleBlock) {
14487
- return (<ModuleBlock>(<ModuleDeclaration>node).body).statements;
14488
- }
14489
- return emptyArray;
14490
- }
14491
-
14492
14382
function hasExportedMembers(moduleSymbol: Symbol) {
14493
14383
for (var id in moduleSymbol.exports) {
14494
14384
if (id !== "export=") {
@@ -15567,20 +15457,6 @@ namespace ts {
15567
15457
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
15568
15458
}
15569
15459
15570
- function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
15571
- if (functionType === unknownType) {
15572
- return unknownType;
15573
- }
15574
-
15575
- const signature = getSingleCallSignature(functionType);
15576
- if (!signature) {
15577
- return unknownType;
15578
- }
15579
-
15580
- const instantiatedSignature = getSignatureInstantiation(signature, typeArguments);
15581
- return getOrCreateTypeFromSignature(instantiatedSignature);
15582
- }
15583
-
15584
15460
function createResolver(): EmitResolver {
15585
15461
return {
15586
15462
getReferencedExportContainer,
@@ -16629,25 +16505,6 @@ namespace ts {
16629
16505
}
16630
16506
}
16631
16507
16632
- function isIntegerLiteral(expression: Expression): boolean {
16633
- if (expression.kind === SyntaxKind.PrefixUnaryExpression) {
16634
- const unaryExpression = <PrefixUnaryExpression>expression;
16635
- if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) {
16636
- expression = unaryExpression.operand;
16637
- }
16638
- }
16639
- if (expression.kind === SyntaxKind.NumericLiteral) {
16640
- // Allows for scientific notation since literalExpression.text was formed by
16641
- // coercing a number to a string. Sometimes this coercion can yield a string
16642
- // in scientific notation.
16643
- // We also don't need special logic for hex because a hex integer is converted
16644
- // to decimal when it is coerced.
16645
- return /^[0-9]+([eE]\+?[0-9]+)?$/.test((<LiteralExpression>expression).text);
16646
- }
16647
-
16648
- return false;
16649
- }
16650
-
16651
16508
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
16652
16509
return sourceFile.parseDiagnostics.length > 0;
16653
16510
}
@@ -16676,11 +16533,6 @@ namespace ts {
16676
16533
}
16677
16534
}
16678
16535
16679
- function isEvalOrArgumentsIdentifier(node: Node): boolean {
16680
- return node.kind === SyntaxKind.Identifier &&
16681
- ((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
16682
- }
16683
-
16684
16536
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
16685
16537
if (node.typeParameters) {
16686
16538
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
0 commit comments