|
3 | 3 | /// <reference path="core.ts" /> |
4 | 4 |
|
5 | 5 | namespace ts { |
6 | | - const emptyArray: any[] = []; |
7 | 6 | const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; |
8 | 7 |
|
9 | 8 | export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { |
@@ -1390,8 +1389,8 @@ namespace ts { |
1390 | 1389 | const isExternalModuleFile = isExternalModule(file); |
1391 | 1390 |
|
1392 | 1391 | // file.imports may not be undefined if there exists dynamic import |
1393 | | - let imports: LiteralExpression[]; |
1394 | | - let moduleAugmentations: LiteralExpression[]; |
| 1392 | + let imports: StringLiteral[]; |
| 1393 | + let moduleAugmentations: StringLiteral[]; |
1395 | 1394 | let ambientModules: string[]; |
1396 | 1395 |
|
1397 | 1396 | // If we are importing helpers, we need to add a synthetic reference to resolve the |
@@ -1426,23 +1425,23 @@ namespace ts { |
1426 | 1425 | case SyntaxKind.ImportEqualsDeclaration: |
1427 | 1426 | case SyntaxKind.ExportDeclaration: |
1428 | 1427 | const moduleNameExpr = getExternalModuleName(node); |
1429 | | - if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { |
| 1428 | + if (!moduleNameExpr || !isStringLiteral(moduleNameExpr)) { |
1430 | 1429 | break; |
1431 | 1430 | } |
1432 | | - if (!(<LiteralExpression>moduleNameExpr).text) { |
| 1431 | + if (!moduleNameExpr.text) { |
1433 | 1432 | break; |
1434 | 1433 | } |
1435 | 1434 |
|
1436 | 1435 | // TypeScript 1.0 spec (April 2014): 12.1.6 |
1437 | 1436 | // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules |
1438 | 1437 | // only through top - level external module names. Relative external module names are not permitted. |
1439 | | - if (!inAmbientModule || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) { |
1440 | | - (imports || (imports = [])).push(<LiteralExpression>moduleNameExpr); |
| 1438 | + if (!inAmbientModule || !isExternalModuleNameRelative(moduleNameExpr.text)) { |
| 1439 | + (imports || (imports = [])).push(moduleNameExpr); |
1441 | 1440 | } |
1442 | 1441 | break; |
1443 | 1442 | case SyntaxKind.ModuleDeclaration: |
1444 | 1443 | if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) { |
1445 | | - const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name; |
| 1444 | + const moduleName = <StringLiteral>(<ModuleDeclaration>node).name; |
1446 | 1445 | // Ambient module declarations can be interpreted as augmentations for some existing external modules. |
1447 | 1446 | // This will happen in two cases: |
1448 | 1447 | // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope |
|
0 commit comments