tsc-ts 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +20 -15
- package/dist/api/compiler/ast.js +1023 -995
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +173 -123
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +134 -90
- package/dist/api/compiler/checker-contextual.js +64 -61
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +244 -211
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +469 -438
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -113
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +105 -88
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +210 -74
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +137 -34
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +93 -31
- package/dist/api/compiler/checker.js +143 -35
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +19 -4
- package/dist/api/compiler/compile-program.js +45 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +23 -23
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parser.d.ts +40 -19
- package/dist/api/compiler/parser.js +308 -216
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +3 -1
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +1 -0
- package/dist/api/compiler/printer/printer.js +303 -281
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +2 -0
- package/dist/api/compiler/program.js +69 -57
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +337 -180
- package/dist/api/compiler/reparser.js +60 -56
- package/dist/api/compiler/scanner.d.ts +19 -2
- package/dist/api/compiler/scanner.js +123 -108
- package/dist/api/compiler/shared-results.d.ts +463 -0
- package/dist/api/compiler/shared-results.js +2128 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +305 -238
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +55 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +78 -24
- package/src/compiler/checker-contextual.ts +6 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +79 -46
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +26 -4
- package/src/compiler/checker-members.ts +197 -55
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +120 -21
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +168 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +51 -25
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +86 -18
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +3 -1
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +197 -8
- package/src/compiler/parallel-emit.ts +1 -1
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +4 -1
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +35 -14
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -77
- package/src/compiler/reparser.ts +7 -2
- package/src/compiler/scanner.ts +109 -79
- package/src/compiler/shared-results.ts +2414 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +19 -2
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +134 -48
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +3 -0
- package/src/compiler/tsc-cli.ts +2 -0
- package/src/compiler/tsc-compile.ts +7 -2
- package/src/compiler/tsc-watch.ts +74 -45
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* Finds every file of a program: root files, libraries, references, imports and type directives, in tsgo's order.
|
|
3
3
|
*/
|
|
4
4
|
import { ImportDeclaration, ParseOptions, StringLiteral, getText, } from './ast.js';
|
|
5
|
+
import { messageWithArgs } from './diagnostics.js';
|
|
5
6
|
import { FileIncludeReason, IncludeProcessor, ProcessingDiagnostic } from './file-include.js';
|
|
6
7
|
import { ModuleResolutionHost, Resolver, getAutomaticTypeDirectiveNames } from './module-resolution.js';
|
|
7
8
|
import { getResolutionDiagnostic, inferredTypesContainingFile, } from './module-resolution-types.js';
|
|
8
9
|
import { getAllowJS, getIsolatedModules, getModuleResolutionKind, ModuleKind, ModuleResolutionKind, } from './options.js';
|
|
9
10
|
import { isPrepared, preparedLoad, preparedPackageJsonLookups, takePreparedFile, } from './parallel-parse.js';
|
|
10
|
-
import { parseSourceFile } from './parser.js';
|
|
11
|
+
import { parseSourceFile, getScriptKindFromFileName } from './parser.js';
|
|
11
12
|
import { mark } from './timeline.js';
|
|
12
|
-
import { combinePaths, fileExtensionIsOneOf, getCanonicalFileName, getDirectoryPath, getNormalizedAbsolutePath, getRootLength, hasJSFileExtension, isRootedDiskPath, normalizePath, normalizeSlashes, removeTrailingDirectorySeparator, supportedTSExtensionsWithJsonFlat, toFileNameLowerCase, toPath, } from './path.js';
|
|
13
|
+
import { combinePaths, fileExtensionIsOneOf, getCanonicalFileName, getDirectoryPath, getNormalizedAbsolutePath, getRootLength, hasJSFileExtension, isRootedDiskPath, normalizePath, normalizeSlashes, removeTrailingDirectorySeparator, supportedTSExtensionsWithJsonFlat, toFileNameLowerCase, toPath, isNetworkPath, } from './path.js';
|
|
13
14
|
import { getDefaultLibFileName, getDefaultResolutionModeForFile, getExternalModuleIndicatorOptions, getImpliedNodeFormatForFile, getJSXImplicitImportBase, getJSXRuntimeImport, getLibFileName, getModeForUsageLocation, isExternalModule, isSourceFileJS, libFileMetadata, libNames, SourceFileMetadata, } from './program-utilities.js';
|
|
15
|
+
import { isSourcePhaseImport } from './ast-utilities.js';
|
|
14
16
|
import { hasExtension } from './vfs-match.js';
|
|
15
17
|
import { ConfigParser, flattenExtensions, getSupportedExtensions, getSupportedExtensionsWithJsonIfResolveJsonModule, } from './tsconfig.js';
|
|
16
18
|
/** Files and services the compiler reads through. */
|
|
@@ -58,7 +60,10 @@ export class CompilerHost extends ModuleResolutionHost {
|
|
|
58
60
|
const text = this.fs.readFile(fileName);
|
|
59
61
|
if (text === undefined)
|
|
60
62
|
return undefined;
|
|
61
|
-
|
|
63
|
+
// A file without a known extension (with allowNonTsExtensions) parses as TypeScript.
|
|
64
|
+
const kind = getScriptKindFromFileName(fileName);
|
|
65
|
+
const scriptKind = kind === 0 /* ScriptKind.Unknown */ ? 3 /* ScriptKind.TS */ : kind;
|
|
66
|
+
return parseSourceFile(fileName, text, new ParseOptions(path, scriptKind, externalModuleIndicatorOptions));
|
|
62
67
|
}
|
|
63
68
|
/** The config of a referenced project, or `undefined` if it can't be read. */
|
|
64
69
|
getResolvedProjectReference(fileName) {
|
|
@@ -187,6 +192,8 @@ class ParseTask {
|
|
|
187
192
|
subTasks = undefined;
|
|
188
193
|
loaded = false;
|
|
189
194
|
startedSubTasks = false;
|
|
195
|
+
/** A root file name that resolved to no supported file: the task only carries its processing diagnostic. */
|
|
196
|
+
failedLookup = false;
|
|
190
197
|
metadata = libFileMetadata;
|
|
191
198
|
resolutionsInFile = undefined;
|
|
192
199
|
resolutionsTrace = undefined;
|
|
@@ -197,6 +204,8 @@ class ParseTask {
|
|
|
197
204
|
jsxRuntimeImport = undefined;
|
|
198
205
|
/** The task of the same file name that was loaded instead of this one. */
|
|
199
206
|
loadedTask = undefined;
|
|
207
|
+
/** The index in `FileLoader.taskData` of the tasks of this task's path, once known; -1 before. */
|
|
208
|
+
dataIndex = -1;
|
|
200
209
|
/** Whether an import or a type reference directive adds the file (`ProcessedFiles.addedFiles`). */
|
|
201
210
|
byImport;
|
|
202
211
|
constructor(normalizedFilePath, libFile, includeReason, isForAutomaticTypeDirective, increaseDepth,
|
|
@@ -228,9 +237,29 @@ class ParseTask {
|
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
const noData = [];
|
|
240
|
+
/** The resolution of a module the importing file declares itself: none. */
|
|
241
|
+
const locallyDeclaredModule = {
|
|
242
|
+
resolvedFileName: '',
|
|
243
|
+
originalPath: '',
|
|
244
|
+
extension: '',
|
|
245
|
+
resolvedUsingTsExtension: false,
|
|
246
|
+
packageId: undefined,
|
|
247
|
+
isExternalLibraryImport: false,
|
|
248
|
+
alternateResult: '',
|
|
249
|
+
resolutionDiagnostics: [],
|
|
250
|
+
};
|
|
231
251
|
/** The tasks of one path, by file name casing. */
|
|
232
252
|
class ParseTaskData {
|
|
233
253
|
tasks = new Map();
|
|
254
|
+
/** Whether a task of the path is queued (`start`). */
|
|
255
|
+
queued = false;
|
|
256
|
+
/** The path's first queued task, the first of `tasks`. */
|
|
257
|
+
first = undefined;
|
|
258
|
+
/**
|
|
259
|
+
* Whether every task of `tasks` is loaded (`run`): then more work of the path does nothing unless it
|
|
260
|
+
* reaches the path at a lower depth.
|
|
261
|
+
*/
|
|
262
|
+
settled = false;
|
|
234
263
|
lowestDepth = Number.MAX_SAFE_INTEGER;
|
|
235
264
|
startedSubTasks = false;
|
|
236
265
|
packageId = undefined;
|
|
@@ -240,9 +269,10 @@ class ParseTaskData {
|
|
|
240
269
|
keptCopy = undefined;
|
|
241
270
|
/** The paths the file's imports and type reference directives add, once collected. */
|
|
242
271
|
added = noData;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
272
|
+
/** The file name `collect` reached the path by first, once it did. */
|
|
273
|
+
collectedName = undefined;
|
|
274
|
+
/** The path's include reasons, once `collect` found one: the list in `IncludeProcessor.fileIncludeReasons`. */
|
|
275
|
+
reasons = undefined;
|
|
246
276
|
}
|
|
247
277
|
/** Pending processing of `tasks[index]`. */
|
|
248
278
|
class ParseWork {
|
|
@@ -407,7 +437,7 @@ export function needsImportHelpersImportSpecifier(file, options) {
|
|
|
407
437
|
}
|
|
408
438
|
/** The module `file` imports the JSX runtime from under `options`, or '' if it imports none. */
|
|
409
439
|
export function jsxRuntimeImportOf(file, options) {
|
|
410
|
-
if (file
|
|
440
|
+
if (!isSourceFileJS(file) && file.scriptKind !== 4 /* ScriptKind.TSX */)
|
|
411
441
|
return '';
|
|
412
442
|
return getJSXRuntimeImport(getJSXImplicitImportBase(options, file), options);
|
|
413
443
|
}
|
|
@@ -481,6 +511,9 @@ export class FileLoader {
|
|
|
481
511
|
supportedExtensionsWithJson;
|
|
482
512
|
maxNodeModuleJsDepth;
|
|
483
513
|
rootTasks = [];
|
|
514
|
+
/** The tasks of each path, created when a task of the path is first queued or built ahead. */
|
|
515
|
+
taskData = [];
|
|
516
|
+
/** The index in `taskData` of each path's tasks. */
|
|
484
517
|
taskDataByPath = new Map();
|
|
485
518
|
/** Work queued by `start`, run last-in first-out like tsgo's single-threaded work group. */
|
|
486
519
|
work = [];
|
|
@@ -548,8 +581,11 @@ export class FileLoader {
|
|
|
548
581
|
if (loaded === undefined)
|
|
549
582
|
continue;
|
|
550
583
|
const subTasks = this.subTasksOf(loaded);
|
|
551
|
-
|
|
584
|
+
// Their paths and tasks, found here while threads parse rather than when the walk reaches them.
|
|
585
|
+
for (const task of subTasks) {
|
|
552
586
|
task.path = this.toPath(task.normalizedFilePath);
|
|
587
|
+
task.dataIndex = this.dataIndexOf(task.path);
|
|
588
|
+
}
|
|
553
589
|
this.subTasksAhead.set(prepared.fileName, new SubTasksAhead(loaded, subTasks));
|
|
554
590
|
}
|
|
555
591
|
}
|
|
@@ -616,7 +652,7 @@ export class FileLoader {
|
|
|
616
652
|
}
|
|
617
653
|
walk() {
|
|
618
654
|
for (let work = this.work.pop(); work !== undefined; work = this.work.pop()) {
|
|
619
|
-
if (this.walkingAhead && this.parsesUnprepared(work.tasks[work.index], work.data)) {
|
|
655
|
+
if (this.walkingAhead && !this.elides(work) && this.parsesUnprepared(work.tasks[work.index], work.data)) {
|
|
620
656
|
this.work.push(work);
|
|
621
657
|
return;
|
|
622
658
|
}
|
|
@@ -631,6 +667,7 @@ export class FileLoader {
|
|
|
631
667
|
*/
|
|
632
668
|
release() {
|
|
633
669
|
this.rootTasks.length = 0;
|
|
670
|
+
this.taskData.length = 0;
|
|
634
671
|
this.taskDataByPath.clear();
|
|
635
672
|
this.work.length = 0;
|
|
636
673
|
this.subTasksAhead.clear();
|
|
@@ -776,6 +813,7 @@ export class FileLoader {
|
|
|
776
813
|
return;
|
|
777
814
|
}
|
|
778
815
|
const task = new ParseTask(absolute, undefined, reason, false, false, false, undefined);
|
|
816
|
+
task.failedLookup = true;
|
|
779
817
|
task.addProcessingDiagnostic(ProcessingDiagnostic.explainingFileInclude('', reason, resolved.message, resolved.args));
|
|
780
818
|
this.rootTasks.push(task);
|
|
781
819
|
}
|
|
@@ -793,17 +831,19 @@ export class FileLoader {
|
|
|
793
831
|
getSourceFileFromReference(fileName, referenceText, containingFile, reason) {
|
|
794
832
|
const allowNonTsExtensions = this.options.allowNonTsExtensions === true;
|
|
795
833
|
const diagnosticFileName = normalizeSlashes(referenceText);
|
|
834
|
+
if (isNetworkPath(fileName))
|
|
835
|
+
return new ReferenceDiagnostic(1195 /* Diagnostics.Network_path_0_is_not_supported */, [diagnosticFileName]);
|
|
796
836
|
const fs = this.host.fs;
|
|
797
837
|
if (hasExtension(fileName)) {
|
|
798
838
|
const canonicalFileName = getCanonicalFileName(fileName, fs.useCaseSensitiveFileNames);
|
|
799
839
|
if (!allowNonTsExtensions && !this.isSupportedExtension(canonicalFileName)) {
|
|
800
840
|
if (hasJSFileExtension(canonicalFileName)) {
|
|
801
|
-
return new ReferenceDiagnostic(
|
|
841
|
+
return new ReferenceDiagnostic(1530 /* Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option */, [diagnosticFileName]);
|
|
802
842
|
}
|
|
803
|
-
return new ReferenceDiagnostic(
|
|
843
|
+
return new ReferenceDiagnostic(1241 /* Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1 */, [diagnosticFileName, this.supportedExtensionsList()]);
|
|
804
844
|
}
|
|
805
845
|
if (!fs.fileExists(fileName))
|
|
806
|
-
return new ReferenceDiagnostic(
|
|
846
|
+
return new ReferenceDiagnostic(1240 /* Diagnostics.File_0_not_found */, [diagnosticFileName]);
|
|
807
847
|
if (reason.isReferencedFile() &&
|
|
808
848
|
getCanonicalFileName(containingFile, fs.useCaseSensitiveFileNames) === canonicalFileName) {
|
|
809
849
|
return new ReferenceDiagnostic(3 /* Diagnostics.A_file_cannot_have_a_reference_to_itself */, []);
|
|
@@ -813,14 +853,14 @@ export class FileLoader {
|
|
|
813
853
|
if (allowNonTsExtensions) {
|
|
814
854
|
return fs.fileExists(fileName)
|
|
815
855
|
? fileName
|
|
816
|
-
: new ReferenceDiagnostic(
|
|
856
|
+
: new ReferenceDiagnostic(1240 /* Diagnostics.File_0_not_found */, [diagnosticFileName]);
|
|
817
857
|
}
|
|
818
858
|
for (const extension of this.supportedExtensions[0]) {
|
|
819
859
|
const candidate = fileName + extension;
|
|
820
860
|
if (fs.fileExists(candidate))
|
|
821
861
|
return candidate;
|
|
822
862
|
}
|
|
823
|
-
return new ReferenceDiagnostic(
|
|
863
|
+
return new ReferenceDiagnostic(1394 /* Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1 */, [
|
|
824
864
|
diagnosticFileName,
|
|
825
865
|
this.supportedExtensionsList(),
|
|
826
866
|
]);
|
|
@@ -876,31 +916,51 @@ export class FileLoader {
|
|
|
876
916
|
}
|
|
877
917
|
// ---- Loading
|
|
878
918
|
start(tasks, depth) {
|
|
919
|
+
const taskData = this.taskData;
|
|
879
920
|
for (let i = 0; i < tasks.length; i++) {
|
|
880
921
|
const task = tasks[i];
|
|
881
|
-
// Sub-tasks built ahead have their paths.
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
922
|
+
// Sub-tasks built ahead have their paths and tasks.
|
|
923
|
+
let k = task.dataIndex;
|
|
924
|
+
if (k < 0) {
|
|
925
|
+
if (task.path === '')
|
|
926
|
+
task.path = this.toPath(task.normalizedFilePath);
|
|
927
|
+
k = this.dataIndexOf(task.path);
|
|
928
|
+
task.dataIndex = k;
|
|
929
|
+
}
|
|
930
|
+
const data = taskData[k];
|
|
931
|
+
const loaded = data.queued;
|
|
932
|
+
if (!loaded) {
|
|
933
|
+
data.queued = true;
|
|
934
|
+
data.first = task;
|
|
935
|
+
data.tasks.set(task.normalizedFilePath, task);
|
|
889
936
|
}
|
|
890
937
|
this.work.push(new ParseWork(tasks, i, data, loaded, depth));
|
|
891
938
|
}
|
|
892
939
|
}
|
|
940
|
+
/** The index in `taskData` of the tasks of `path`, created if needed. */
|
|
941
|
+
dataIndexOf(path) {
|
|
942
|
+
let k = this.taskDataByPath.get(path);
|
|
943
|
+
if (k === undefined) {
|
|
944
|
+
k = this.taskData.length;
|
|
945
|
+
this.taskData.push(new ParseTaskData());
|
|
946
|
+
this.taskDataByPath.set(path, k);
|
|
947
|
+
}
|
|
948
|
+
return k;
|
|
949
|
+
}
|
|
893
950
|
run(work) {
|
|
894
951
|
const task = work.tasks[work.index];
|
|
895
952
|
const data = work.data;
|
|
896
953
|
let startSubTasks = false;
|
|
897
954
|
if (work.loaded) {
|
|
898
|
-
const
|
|
955
|
+
const name = task.normalizedFilePath;
|
|
956
|
+
const first = data.first;
|
|
957
|
+
const existing = first !== undefined && first.normalizedFilePath === name ? first : data.tasks.get(name);
|
|
899
958
|
if (existing !== undefined) {
|
|
900
959
|
task.loadedTask = existing;
|
|
901
960
|
}
|
|
902
961
|
else {
|
|
903
|
-
data.tasks.set(
|
|
962
|
+
data.tasks.set(name, task);
|
|
963
|
+
data.settled = false;
|
|
904
964
|
// A new casing of a file: load its references if another casing's were.
|
|
905
965
|
startSubTasks = data.startedSubTasks;
|
|
906
966
|
}
|
|
@@ -908,7 +968,8 @@ export class FileLoader {
|
|
|
908
968
|
if (data.packageId === undefined && task.packageId !== undefined)
|
|
909
969
|
data.packageId = task.packageId;
|
|
910
970
|
const depth = task.increaseDepth ? work.depth + 1 : work.depth;
|
|
911
|
-
|
|
971
|
+
const lowered = depth < data.lowestDepth;
|
|
972
|
+
if (lowered) {
|
|
912
973
|
// Reached at a lower depth than before: load references again.
|
|
913
974
|
data.lowestDepth = depth;
|
|
914
975
|
startSubTasks = true;
|
|
@@ -916,6 +977,9 @@ export class FileLoader {
|
|
|
916
977
|
}
|
|
917
978
|
if (task.elideOnDepth && depth > this.maxNodeModuleJsDepth)
|
|
918
979
|
return;
|
|
980
|
+
// Most work reaches a path already loaded, at no lower depth.
|
|
981
|
+
if (data.settled && !startSubTasks)
|
|
982
|
+
return;
|
|
919
983
|
for (const taskByFileName of data.tasks.values()) {
|
|
920
984
|
let loadSubTasks = startSubTasks;
|
|
921
985
|
if (!taskByFileName.loaded) {
|
|
@@ -925,12 +989,23 @@ export class FileLoader {
|
|
|
925
989
|
data.startedSubTasks = true;
|
|
926
990
|
}
|
|
927
991
|
}
|
|
928
|
-
|
|
992
|
+
// A lower depth restarts references already started, which may now be loaded past `maxNodeModuleJsDepth`.
|
|
993
|
+
// Every file reached from them is at least as deep, so a depth past it changes nothing they load.
|
|
994
|
+
if (loadSubTasks && ((lowered && depth <= this.maxNodeModuleJsDepth) || !taskByFileName.startedSubTasks)) {
|
|
929
995
|
taskByFileName.startedSubTasks = true;
|
|
930
996
|
if (taskByFileName.subTasks !== undefined)
|
|
931
997
|
this.start(taskByFileName.subTasks, data.lowestDepth);
|
|
932
998
|
}
|
|
933
999
|
}
|
|
1000
|
+
data.settled = true;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Whether `run` drops `work` without loading its file: a JavaScript file past `maxNodeModuleJsDepth`,
|
|
1004
|
+
* which no parse thread prepares, so the walk ahead does not wait for it.
|
|
1005
|
+
*/
|
|
1006
|
+
elides(work) {
|
|
1007
|
+
const task = work.tasks[work.index];
|
|
1008
|
+
return task.elideOnDepth && (task.increaseDepth ? work.depth + 1 : work.depth) > this.maxNodeModuleJsDepth;
|
|
934
1009
|
}
|
|
935
1010
|
/**
|
|
936
1011
|
* Whether running the work of `task` (of `data`'s path) may parse a file that parse threads have not
|
|
@@ -950,6 +1025,8 @@ export class FileLoader {
|
|
|
950
1025
|
this.loadAutomaticTypeDirectives(task);
|
|
951
1026
|
return;
|
|
952
1027
|
}
|
|
1028
|
+
if (task.failedLookup)
|
|
1029
|
+
return;
|
|
953
1030
|
const redirect = this.mapper.getParseFileRedirect(task.path);
|
|
954
1031
|
if (redirect !== '') {
|
|
955
1032
|
const redirected = new ParseTask(normalizePath(redirect), task.libFile, task.includeReason, false, false, false, undefined);
|
|
@@ -962,8 +1039,8 @@ export class FileLoader {
|
|
|
962
1039
|
const canonicalFileName = getCanonicalFileName(task.normalizedFilePath, fs.useCaseSensitiveFileNames);
|
|
963
1040
|
if (!this.isSupportedExtension(canonicalFileName)) {
|
|
964
1041
|
task.addProcessingDiagnostic(hasJSFileExtension(canonicalFileName)
|
|
965
|
-
? ProcessingDiagnostic.explainingFileInclude('', task.includeReason,
|
|
966
|
-
: ProcessingDiagnostic.explainingFileInclude('', task.includeReason,
|
|
1042
|
+
? ProcessingDiagnostic.explainingFileInclude('', task.includeReason, 1530 /* Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option */, [task.normalizedFilePath])
|
|
1043
|
+
: ProcessingDiagnostic.explainingFileInclude('', task.includeReason, 1241 /* Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1 */, [task.normalizedFilePath, this.supportedExtensionsList()]));
|
|
967
1044
|
return;
|
|
968
1045
|
}
|
|
969
1046
|
}
|
|
@@ -1085,7 +1162,7 @@ export class FileLoader {
|
|
|
1085
1162
|
task.addSubTask(resolved.resolvedFileName, undefined, FileIncludeReason.automaticTypeDirective(name, resolved.packageId), resolved.isExternalLibraryImport, false, resolved.packageId);
|
|
1086
1163
|
}
|
|
1087
1164
|
else {
|
|
1088
|
-
task.addProcessingDiagnostic(ProcessingDiagnostic.explainingFileInclude('', FileIncludeReason.automaticTypeDirective(name, undefined),
|
|
1165
|
+
task.addProcessingDiagnostic(ProcessingDiagnostic.explainingFileInclude('', FileIncludeReason.automaticTypeDirective(name, undefined), 828 /* Diagnostics.Cannot_find_type_definition_file_for_0 */, [name]));
|
|
1089
1166
|
}
|
|
1090
1167
|
}
|
|
1091
1168
|
task.typeResolutionsInFile = resolutions;
|
|
@@ -1120,9 +1197,19 @@ export class FileLoader {
|
|
|
1120
1197
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
1121
1198
|
const entry = moduleNames[index];
|
|
1122
1199
|
const moduleName = getText(entry);
|
|
1123
|
-
|
|
1200
|
+
// A source phase import loads no module declarations.
|
|
1201
|
+
if (moduleName === '' || isSourcePhaseImport(entry.parent))
|
|
1124
1202
|
continue;
|
|
1125
1203
|
const mode = getModeForUsageLocation(file.fileName, task.metadata, entry, options);
|
|
1204
|
+
// A module the file declares itself (`declare module "m"`) isn't resolved.
|
|
1205
|
+
if (file.ambientModuleNames.includes(moduleName)) {
|
|
1206
|
+
if (options.traceResolution === true)
|
|
1207
|
+
task
|
|
1208
|
+
.moduleTraces(true)
|
|
1209
|
+
.push(messageWithArgs(1319 /* Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1 */, moduleName, file.fileName));
|
|
1210
|
+
resolutions.set(modeAwareKey(moduleName, mode), locallyDeclaredModule);
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1126
1213
|
const resolved = this.resolver.resolveModuleName(moduleName, containingFile, mode, redirect?.resolved, task.moduleTraces(this.options.traceResolution === true));
|
|
1127
1214
|
resolutions.set(modeAwareKey(moduleName, mode), resolved);
|
|
1128
1215
|
const resolvedFileName = resolved.resolvedFileName;
|
|
@@ -1173,7 +1260,7 @@ export class FileLoader {
|
|
|
1173
1260
|
const redirectFilesByPath = new Map();
|
|
1174
1261
|
const packageIdToSourceFile = new Map();
|
|
1175
1262
|
const checkCasing = this.options.forceConsistentCasingInFileNames !== false;
|
|
1176
|
-
const
|
|
1263
|
+
const taskData = this.taskData;
|
|
1177
1264
|
// The paths each file's imports and type reference directives add (the tasks of each path), for
|
|
1178
1265
|
// `ProcessedFiles.addedFiles`: recorded while collecting visits them, as their files are only known
|
|
1179
1266
|
// once every file is collected.
|
|
@@ -1189,14 +1276,14 @@ export class FileLoader {
|
|
|
1189
1276
|
if (task.loadedTask !== undefined)
|
|
1190
1277
|
task = task.loadedTask;
|
|
1191
1278
|
if (includeReason !== undefined)
|
|
1192
|
-
addIncludeReason(includeProcessor, task, includeReason);
|
|
1279
|
+
addIncludeReason(includeProcessor, taskData, task, includeReason);
|
|
1193
1280
|
}
|
|
1194
|
-
const data =
|
|
1281
|
+
const data = task.dataIndex >= 0 ? taskData[task.dataIndex] : undefined;
|
|
1195
1282
|
if (added !== undefined && data !== undefined && byImport)
|
|
1196
1283
|
added.push(data);
|
|
1197
1284
|
if (!task.loaded || data === undefined)
|
|
1198
1285
|
continue;
|
|
1199
|
-
const checkedName =
|
|
1286
|
+
const checkedName = data.collectedName;
|
|
1200
1287
|
if (checkedName !== undefined) {
|
|
1201
1288
|
// The same name normalizes the same: only another spelling needs comparing.
|
|
1202
1289
|
if (checkCasing &&
|
|
@@ -1207,7 +1294,7 @@ export class FileLoader {
|
|
|
1207
1294
|
}
|
|
1208
1295
|
continue;
|
|
1209
1296
|
}
|
|
1210
|
-
|
|
1297
|
+
data.collectedName = task.normalizedFilePath;
|
|
1211
1298
|
if (tasksSeenByNameIgnoreCase !== undefined) {
|
|
1212
1299
|
const lowerCasePath = toFileNameLowerCase(task.path);
|
|
1213
1300
|
const existing = tasksSeenByNameIgnoreCase.get(lowerCasePath);
|
|
@@ -1259,13 +1346,15 @@ export class FileLoader {
|
|
|
1259
1346
|
includeProcessor.addProcessingDiagnostic(diagnostic);
|
|
1260
1347
|
continue;
|
|
1261
1348
|
}
|
|
1262
|
-
const path = task.path;
|
|
1263
1349
|
for (const diagnostic of task.processingDiagnostics ?? noProcessingDiagnostics)
|
|
1264
1350
|
includeProcessor.addProcessingDiagnostic(diagnostic);
|
|
1265
1351
|
if (file === undefined) {
|
|
1266
1352
|
missingFiles.push(task.normalizedFilePath);
|
|
1267
1353
|
continue;
|
|
1268
1354
|
}
|
|
1355
|
+
// The program's maps of the file are keyed by the file's own path: lookups by `file.path` then find
|
|
1356
|
+
// the same string, also for a file a parse thread created, whose path is another string than the task's.
|
|
1357
|
+
const path = file.path === task.path ? file.path : task.path;
|
|
1269
1358
|
if (task.libFile !== undefined) {
|
|
1270
1359
|
libFiles.push(file);
|
|
1271
1360
|
libData.set(file, data);
|
|
@@ -1336,12 +1425,20 @@ const noPackageJsonLookups = [];
|
|
|
1336
1425
|
export function releaseLater(loader) {
|
|
1337
1426
|
setImmediate(() => loader.release());
|
|
1338
1427
|
}
|
|
1339
|
-
function addIncludeReason(processor, task, reason) {
|
|
1428
|
+
function addIncludeReason(processor, taskData, task, reason) {
|
|
1340
1429
|
const redirected = task.redirectedParseTask;
|
|
1341
1430
|
if (redirected !== undefined)
|
|
1342
|
-
addIncludeReason(processor, redirected, reason);
|
|
1343
|
-
else if (task.loaded)
|
|
1344
|
-
|
|
1431
|
+
addIncludeReason(processor, taskData, redirected, reason);
|
|
1432
|
+
else if (task.loaded) {
|
|
1433
|
+
// The path's list, without looking the path up for each reference to the file.
|
|
1434
|
+
const data = task.dataIndex >= 0 ? taskData[task.dataIndex] : undefined;
|
|
1435
|
+
if (data === undefined)
|
|
1436
|
+
processor.addReason(task.path, reason);
|
|
1437
|
+
else if (data.reasons !== undefined)
|
|
1438
|
+
data.reasons.push(reason);
|
|
1439
|
+
else
|
|
1440
|
+
data.reasons = processor.addReason(task.path, reason);
|
|
1441
|
+
}
|
|
1345
1442
|
}
|
|
1346
1443
|
function createProjectReferenceTasks(paths) {
|
|
1347
1444
|
const tasks = [];
|
|
@@ -1358,7 +1455,7 @@ function withoutRoot(path) {
|
|
|
1358
1455
|
/** A specifier of an import the compiler adds, such as `tslib` for `importHelpers`. */
|
|
1359
1456
|
function createSyntheticImport(text, file) {
|
|
1360
1457
|
const specifier = new StringLiteral(text, 0 /* TokenFlags.None */);
|
|
1361
|
-
const declaration = new ImportDeclaration(
|
|
1458
|
+
const declaration = new ImportDeclaration(274 /* SyntaxKind.ImportDeclaration */, undefined, undefined, specifier, undefined);
|
|
1362
1459
|
specifier.parent = declaration;
|
|
1363
1460
|
declaration.parent = file;
|
|
1364
1461
|
return specifier;
|
|
@@ -38,6 +38,8 @@ export declare class UniqueLiteralMapper extends TypeMapper {
|
|
|
38
38
|
export declare function combineTypeMappers(c: Checker, m1: TypeMapper | undefined, m2: TypeMapper): TypeMapper;
|
|
39
39
|
export declare function instantiateType(c: Checker, type: Type, mapper: TypeMapper | undefined): Type;
|
|
40
40
|
export declare function instantiateTypeWithAlias(c: Checker, type: Type, mapper: TypeMapper | undefined, alias: TypeAlias | undefined): Type;
|
|
41
|
+
/** `'a', 'b', 'c'`. */
|
|
42
|
+
export declare function quotedAndCommaSeparated(items: readonly string[]): string;
|
|
41
43
|
/** Whether `type` could reference a type parameter we infer for. Cached on the type. */
|
|
42
44
|
export declare function couldContainTypeVariables(c: Checker, type: Type): boolean;
|
|
43
45
|
/** Whether `node` has a reference to `tp` (or one that may be to it, such as a type query). */
|
|
@@ -65,6 +67,11 @@ export declare function instantiateSymbol(c: Checker, symbol: Symbol, mapper: Ty
|
|
|
65
67
|
* is resolved yet, so lazily instantiated members record it when tsgo would instantiate them.
|
|
66
68
|
*/
|
|
67
69
|
export declare function keepsSymbolUnderInstantiation(c: Checker, symbol: Symbol, mapper: TypeMapper): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the resolved type of `symbol` (and its write type) can't change under instantiation, so that
|
|
72
|
+
* `instantiateSymbol` keeps it whatever the mapper. Once true, it stays true: types are resolved once.
|
|
73
|
+
*/
|
|
74
|
+
export declare function keepsSymbolTypeUnderInstantiation(c: Checker, symbol: Symbol): boolean;
|
|
68
75
|
/** The instantiated copy of `symbol` that `instantiateSymbol` creates when it doesn't keep it. */
|
|
69
76
|
export declare function newInstantiatedSymbol(c: Checker, symbol: Symbol, mapper: TypeMapper): Symbol;
|
|
70
77
|
/** Conservatively, whether a parameter or member's type can't reference `this`. */
|