tsc-ts 0.0.9 → 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 +2 -2
- 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 +22 -15
- package/dist/api/compiler/ast.js +1026 -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 +178 -124
- 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 +472 -440
- 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 -107
- 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 +212 -75
- 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 +145 -36
- 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 +104 -31
- package/dist/api/compiler/checker.js +181 -33
- 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 +42 -3
- package/dist/api/compiler/compile-program.js +139 -27
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.d.ts +22 -0
- package/dist/api/compiler/diagnostics.js +93 -11
- 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 +21 -1
- package/dist/api/compiler/file-loader.js +201 -48
- 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/parallel-parse.d.ts +3 -2
- package/dist/api/compiler/parallel-parse.js +17 -5
- 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 +5 -1
- package/dist/api/compiler/printer/emit-context.js +20 -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 +49 -2
- package/dist/api/compiler/printer/printer.js +539 -293
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +12 -2
- package/dist/api/compiler/program-checker.js +88 -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 +4 -6
- package/dist/api/compiler/program.js +74 -87
- 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 +347 -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 +23 -14
- package/dist/api/compiler/symbol.js +23 -11
- 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 +58 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +79 -9
- 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 +136 -62
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -82
- 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 +200 -56
- 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 +124 -23
- 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 +203 -39
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +167 -27
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/diagnostics.ts +84 -3
- 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 +197 -38
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +165 -30
- 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 +326 -52
- package/src/compiler/parallel-emit.ts +320 -0
- package/src/compiler/parallel-parse.ts +16 -5
- package/src/compiler/parse-thread.ts +3 -0
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +21 -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 +266 -30
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +57 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +18 -26
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +240 -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 +46 -24
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +64 -4
- 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 +66 -9
- package/src/compiler/tsc-cli.ts +7 -0
- package/src/compiler/tsc-compile.ts +284 -4
- 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,10 @@ 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;
|
|
209
|
+
/** Whether an import or a type reference directive adds the file (`ProcessedFiles.addedFiles`). */
|
|
210
|
+
byImport;
|
|
200
211
|
constructor(normalizedFilePath, libFile, includeReason, isForAutomaticTypeDirective, increaseDepth,
|
|
201
212
|
/** A JavaScript file found in `node_modules`, loaded only within `maxNodeModuleJsDepth`. */
|
|
202
213
|
elideOnDepth, packageId) {
|
|
@@ -207,6 +218,8 @@ class ParseTask {
|
|
|
207
218
|
this.increaseDepth = increaseDepth;
|
|
208
219
|
this.elideOnDepth = elideOnDepth;
|
|
209
220
|
this.packageId = packageId;
|
|
221
|
+
const kind = includeReason !== undefined ? includeReason.kind : -1;
|
|
222
|
+
this.byImport = kind === 0 /* FileIncludeKind.Import */ || kind === 2 /* FileIncludeKind.TypeReferenceDirective */;
|
|
210
223
|
}
|
|
211
224
|
addSubTask(fileName, libFile, reason, increaseDepth, elideOnDepth, packageId) {
|
|
212
225
|
(this.subTasks ??= []).push(new ParseTask(normalizePath(fileName), libFile, reason, false, increaseDepth, elideOnDepth, packageId));
|
|
@@ -223,15 +236,43 @@ class ParseTask {
|
|
|
223
236
|
return trace ? (this.typeResolutionsTrace ??= []) : undefined;
|
|
224
237
|
}
|
|
225
238
|
}
|
|
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
|
+
};
|
|
226
251
|
/** The tasks of one path, by file name casing. */
|
|
227
252
|
class ParseTaskData {
|
|
228
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;
|
|
229
263
|
lowestDepth = Number.MAX_SAFE_INTEGER;
|
|
230
264
|
startedSubTasks = false;
|
|
231
265
|
packageId = undefined;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
266
|
+
/** The index of this path's file in the program's files, once collected; -1 for none. */
|
|
267
|
+
index = -1;
|
|
268
|
+
/** For a deduplicated package's path, the tasks of the copy kept (`collect`). */
|
|
269
|
+
keptCopy = undefined;
|
|
270
|
+
/** The paths the file's imports and type reference directives add, once collected. */
|
|
271
|
+
added = noData;
|
|
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;
|
|
235
276
|
}
|
|
236
277
|
/** Pending processing of `tasks[index]`. */
|
|
237
278
|
class ParseWork {
|
|
@@ -340,6 +381,7 @@ export class ProcessedFiles {
|
|
|
340
381
|
redirectFilesByPath;
|
|
341
382
|
projectReferenceMapper;
|
|
342
383
|
preparedPackageJsons;
|
|
384
|
+
addedFiles;
|
|
343
385
|
constructor(resolver,
|
|
344
386
|
/** Libraries first, sorted, then other files in load order. */
|
|
345
387
|
files, filesByPath, missingFiles, resolvedModules, typeResolutionsInFile, sourceFileMetadata, jsxRuntimeImports, importHelpersImportSpecifiers, libFiles,
|
|
@@ -351,7 +393,12 @@ export class ProcessedFiles {
|
|
|
351
393
|
* The `package.json` lookups made resolving the files whose resolutions were taken from parse
|
|
352
394
|
* threads (`preparedPackageJsonLookups`); `undefined` where they may miss some.
|
|
353
395
|
*/
|
|
354
|
-
preparedPackageJsons
|
|
396
|
+
preparedPackageJsons,
|
|
397
|
+
/**
|
|
398
|
+
* The files each file's imports and type reference directives added to the program, by index into
|
|
399
|
+
* `files`, without the file itself.
|
|
400
|
+
*/
|
|
401
|
+
addedFiles) {
|
|
355
402
|
this.resolver = resolver;
|
|
356
403
|
this.files = files;
|
|
357
404
|
this.filesByPath = filesByPath;
|
|
@@ -369,6 +416,7 @@ export class ProcessedFiles {
|
|
|
369
416
|
this.redirectFilesByPath = redirectFilesByPath;
|
|
370
417
|
this.projectReferenceMapper = projectReferenceMapper;
|
|
371
418
|
this.preparedPackageJsons = preparedPackageJsons;
|
|
419
|
+
this.addedFiles = addedFiles;
|
|
372
420
|
}
|
|
373
421
|
}
|
|
374
422
|
/** The files of `processed` with `file` in place of the file at its path, for `Program.updateFile`. */
|
|
@@ -377,7 +425,9 @@ export function withReplacedFile(processed, file) {
|
|
|
377
425
|
files[files.findIndex((f) => f.path === file.path)] = file;
|
|
378
426
|
const filesByPath = new Map(processed.filesByPath);
|
|
379
427
|
filesByPath.set(file.path, file);
|
|
380
|
-
return new ProcessedFiles(processed.resolver, files, filesByPath, processed.missingFiles, processed.resolvedModules, processed.typeResolutionsInFile, processed.sourceFileMetadata, processed.jsxRuntimeImports, processed.importHelpersImportSpecifiers, processed.libFiles, processed.sourceFilesFoundSearchingNodeModules, processed.includeProcessor.copy(file.path), processed.outputFileToProjectReferenceSource, processed.redirectTargets, processed.redirectFilesByPath, processed.projectReferenceMapper, processed.preparedPackageJsons
|
|
428
|
+
return new ProcessedFiles(processed.resolver, files, filesByPath, processed.missingFiles, processed.resolvedModules, processed.typeResolutionsInFile, processed.sourceFileMetadata, processed.jsxRuntimeImports, processed.importHelpersImportSpecifiers, processed.libFiles, processed.sourceFilesFoundSearchingNodeModules, processed.includeProcessor.copy(file.path), processed.outputFileToProjectReferenceSource, processed.redirectTargets, processed.redirectFilesByPath, processed.projectReferenceMapper, processed.preparedPackageJsons,
|
|
429
|
+
// The file has the same references (`canReplaceFile`), and keeps its index.
|
|
430
|
+
processed.addedFiles);
|
|
381
431
|
}
|
|
382
432
|
/** Whether `file` imports the `importHelpers` module (tslib) under `options`. */
|
|
383
433
|
export function needsImportHelpersImportSpecifier(file, options) {
|
|
@@ -387,7 +437,7 @@ export function needsImportHelpersImportSpecifier(file, options) {
|
|
|
387
437
|
}
|
|
388
438
|
/** The module `file` imports the JSX runtime from under `options`, or '' if it imports none. */
|
|
389
439
|
export function jsxRuntimeImportOf(file, options) {
|
|
390
|
-
if (file
|
|
440
|
+
if (!isSourceFileJS(file) && file.scriptKind !== 4 /* ScriptKind.TSX */)
|
|
391
441
|
return '';
|
|
392
442
|
return getJSXRuntimeImport(getJSXImplicitImportBase(options, file), options);
|
|
393
443
|
}
|
|
@@ -461,6 +511,9 @@ export class FileLoader {
|
|
|
461
511
|
supportedExtensionsWithJson;
|
|
462
512
|
maxNodeModuleJsDepth;
|
|
463
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. */
|
|
464
517
|
taskDataByPath = new Map();
|
|
465
518
|
/** Work queued by `start`, run last-in first-out like tsgo's single-threaded work group. */
|
|
466
519
|
work = [];
|
|
@@ -528,8 +581,11 @@ export class FileLoader {
|
|
|
528
581
|
if (loaded === undefined)
|
|
529
582
|
continue;
|
|
530
583
|
const subTasks = this.subTasksOf(loaded);
|
|
531
|
-
|
|
584
|
+
// Their paths and tasks, found here while threads parse rather than when the walk reaches them.
|
|
585
|
+
for (const task of subTasks) {
|
|
532
586
|
task.path = this.toPath(task.normalizedFilePath);
|
|
587
|
+
task.dataIndex = this.dataIndexOf(task.path);
|
|
588
|
+
}
|
|
533
589
|
this.subTasksAhead.set(prepared.fileName, new SubTasksAhead(loaded, subTasks));
|
|
534
590
|
}
|
|
535
591
|
}
|
|
@@ -596,7 +652,7 @@ export class FileLoader {
|
|
|
596
652
|
}
|
|
597
653
|
walk() {
|
|
598
654
|
for (let work = this.work.pop(); work !== undefined; work = this.work.pop()) {
|
|
599
|
-
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)) {
|
|
600
656
|
this.work.push(work);
|
|
601
657
|
return;
|
|
602
658
|
}
|
|
@@ -611,6 +667,7 @@ export class FileLoader {
|
|
|
611
667
|
*/
|
|
612
668
|
release() {
|
|
613
669
|
this.rootTasks.length = 0;
|
|
670
|
+
this.taskData.length = 0;
|
|
614
671
|
this.taskDataByPath.clear();
|
|
615
672
|
this.work.length = 0;
|
|
616
673
|
this.subTasksAhead.clear();
|
|
@@ -756,6 +813,7 @@ export class FileLoader {
|
|
|
756
813
|
return;
|
|
757
814
|
}
|
|
758
815
|
const task = new ParseTask(absolute, undefined, reason, false, false, false, undefined);
|
|
816
|
+
task.failedLookup = true;
|
|
759
817
|
task.addProcessingDiagnostic(ProcessingDiagnostic.explainingFileInclude('', reason, resolved.message, resolved.args));
|
|
760
818
|
this.rootTasks.push(task);
|
|
761
819
|
}
|
|
@@ -773,17 +831,19 @@ export class FileLoader {
|
|
|
773
831
|
getSourceFileFromReference(fileName, referenceText, containingFile, reason) {
|
|
774
832
|
const allowNonTsExtensions = this.options.allowNonTsExtensions === true;
|
|
775
833
|
const diagnosticFileName = normalizeSlashes(referenceText);
|
|
834
|
+
if (isNetworkPath(fileName))
|
|
835
|
+
return new ReferenceDiagnostic(1195 /* Diagnostics.Network_path_0_is_not_supported */, [diagnosticFileName]);
|
|
776
836
|
const fs = this.host.fs;
|
|
777
837
|
if (hasExtension(fileName)) {
|
|
778
838
|
const canonicalFileName = getCanonicalFileName(fileName, fs.useCaseSensitiveFileNames);
|
|
779
839
|
if (!allowNonTsExtensions && !this.isSupportedExtension(canonicalFileName)) {
|
|
780
840
|
if (hasJSFileExtension(canonicalFileName)) {
|
|
781
|
-
return new ReferenceDiagnostic(
|
|
841
|
+
return new ReferenceDiagnostic(1530 /* Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option */, [diagnosticFileName]);
|
|
782
842
|
}
|
|
783
|
-
return new ReferenceDiagnostic(
|
|
843
|
+
return new ReferenceDiagnostic(1241 /* Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1 */, [diagnosticFileName, this.supportedExtensionsList()]);
|
|
784
844
|
}
|
|
785
845
|
if (!fs.fileExists(fileName))
|
|
786
|
-
return new ReferenceDiagnostic(
|
|
846
|
+
return new ReferenceDiagnostic(1240 /* Diagnostics.File_0_not_found */, [diagnosticFileName]);
|
|
787
847
|
if (reason.isReferencedFile() &&
|
|
788
848
|
getCanonicalFileName(containingFile, fs.useCaseSensitiveFileNames) === canonicalFileName) {
|
|
789
849
|
return new ReferenceDiagnostic(3 /* Diagnostics.A_file_cannot_have_a_reference_to_itself */, []);
|
|
@@ -793,14 +853,14 @@ export class FileLoader {
|
|
|
793
853
|
if (allowNonTsExtensions) {
|
|
794
854
|
return fs.fileExists(fileName)
|
|
795
855
|
? fileName
|
|
796
|
-
: new ReferenceDiagnostic(
|
|
856
|
+
: new ReferenceDiagnostic(1240 /* Diagnostics.File_0_not_found */, [diagnosticFileName]);
|
|
797
857
|
}
|
|
798
858
|
for (const extension of this.supportedExtensions[0]) {
|
|
799
859
|
const candidate = fileName + extension;
|
|
800
860
|
if (fs.fileExists(candidate))
|
|
801
861
|
return candidate;
|
|
802
862
|
}
|
|
803
|
-
return new ReferenceDiagnostic(
|
|
863
|
+
return new ReferenceDiagnostic(1394 /* Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1 */, [
|
|
804
864
|
diagnosticFileName,
|
|
805
865
|
this.supportedExtensionsList(),
|
|
806
866
|
]);
|
|
@@ -856,31 +916,51 @@ export class FileLoader {
|
|
|
856
916
|
}
|
|
857
917
|
// ---- Loading
|
|
858
918
|
start(tasks, depth) {
|
|
919
|
+
const taskData = this.taskData;
|
|
859
920
|
for (let i = 0; i < tasks.length; i++) {
|
|
860
921
|
const task = tasks[i];
|
|
861
|
-
// Sub-tasks built ahead have their paths.
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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);
|
|
869
936
|
}
|
|
870
937
|
this.work.push(new ParseWork(tasks, i, data, loaded, depth));
|
|
871
938
|
}
|
|
872
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
|
+
}
|
|
873
950
|
run(work) {
|
|
874
951
|
const task = work.tasks[work.index];
|
|
875
952
|
const data = work.data;
|
|
876
953
|
let startSubTasks = false;
|
|
877
954
|
if (work.loaded) {
|
|
878
|
-
const
|
|
955
|
+
const name = task.normalizedFilePath;
|
|
956
|
+
const first = data.first;
|
|
957
|
+
const existing = first !== undefined && first.normalizedFilePath === name ? first : data.tasks.get(name);
|
|
879
958
|
if (existing !== undefined) {
|
|
880
959
|
task.loadedTask = existing;
|
|
881
960
|
}
|
|
882
961
|
else {
|
|
883
|
-
data.tasks.set(
|
|
962
|
+
data.tasks.set(name, task);
|
|
963
|
+
data.settled = false;
|
|
884
964
|
// A new casing of a file: load its references if another casing's were.
|
|
885
965
|
startSubTasks = data.startedSubTasks;
|
|
886
966
|
}
|
|
@@ -888,7 +968,8 @@ export class FileLoader {
|
|
|
888
968
|
if (data.packageId === undefined && task.packageId !== undefined)
|
|
889
969
|
data.packageId = task.packageId;
|
|
890
970
|
const depth = task.increaseDepth ? work.depth + 1 : work.depth;
|
|
891
|
-
|
|
971
|
+
const lowered = depth < data.lowestDepth;
|
|
972
|
+
if (lowered) {
|
|
892
973
|
// Reached at a lower depth than before: load references again.
|
|
893
974
|
data.lowestDepth = depth;
|
|
894
975
|
startSubTasks = true;
|
|
@@ -896,6 +977,9 @@ export class FileLoader {
|
|
|
896
977
|
}
|
|
897
978
|
if (task.elideOnDepth && depth > this.maxNodeModuleJsDepth)
|
|
898
979
|
return;
|
|
980
|
+
// Most work reaches a path already loaded, at no lower depth.
|
|
981
|
+
if (data.settled && !startSubTasks)
|
|
982
|
+
return;
|
|
899
983
|
for (const taskByFileName of data.tasks.values()) {
|
|
900
984
|
let loadSubTasks = startSubTasks;
|
|
901
985
|
if (!taskByFileName.loaded) {
|
|
@@ -905,12 +989,23 @@ export class FileLoader {
|
|
|
905
989
|
data.startedSubTasks = true;
|
|
906
990
|
}
|
|
907
991
|
}
|
|
908
|
-
|
|
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)) {
|
|
909
995
|
taskByFileName.startedSubTasks = true;
|
|
910
996
|
if (taskByFileName.subTasks !== undefined)
|
|
911
997
|
this.start(taskByFileName.subTasks, data.lowestDepth);
|
|
912
998
|
}
|
|
913
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;
|
|
914
1009
|
}
|
|
915
1010
|
/**
|
|
916
1011
|
* Whether running the work of `task` (of `data`'s path) may parse a file that parse threads have not
|
|
@@ -930,6 +1025,8 @@ export class FileLoader {
|
|
|
930
1025
|
this.loadAutomaticTypeDirectives(task);
|
|
931
1026
|
return;
|
|
932
1027
|
}
|
|
1028
|
+
if (task.failedLookup)
|
|
1029
|
+
return;
|
|
933
1030
|
const redirect = this.mapper.getParseFileRedirect(task.path);
|
|
934
1031
|
if (redirect !== '') {
|
|
935
1032
|
const redirected = new ParseTask(normalizePath(redirect), task.libFile, task.includeReason, false, false, false, undefined);
|
|
@@ -942,8 +1039,8 @@ export class FileLoader {
|
|
|
942
1039
|
const canonicalFileName = getCanonicalFileName(task.normalizedFilePath, fs.useCaseSensitiveFileNames);
|
|
943
1040
|
if (!this.isSupportedExtension(canonicalFileName)) {
|
|
944
1041
|
task.addProcessingDiagnostic(hasJSFileExtension(canonicalFileName)
|
|
945
|
-
? ProcessingDiagnostic.explainingFileInclude('', task.includeReason,
|
|
946
|
-
: 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()]));
|
|
947
1044
|
return;
|
|
948
1045
|
}
|
|
949
1046
|
}
|
|
@@ -1065,7 +1162,7 @@ export class FileLoader {
|
|
|
1065
1162
|
task.addSubTask(resolved.resolvedFileName, undefined, FileIncludeReason.automaticTypeDirective(name, resolved.packageId), resolved.isExternalLibraryImport, false, resolved.packageId);
|
|
1066
1163
|
}
|
|
1067
1164
|
else {
|
|
1068
|
-
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]));
|
|
1069
1166
|
}
|
|
1070
1167
|
}
|
|
1071
1168
|
task.typeResolutionsInFile = resolutions;
|
|
@@ -1100,9 +1197,19 @@ export class FileLoader {
|
|
|
1100
1197
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
1101
1198
|
const entry = moduleNames[index];
|
|
1102
1199
|
const moduleName = getText(entry);
|
|
1103
|
-
|
|
1200
|
+
// A source phase import loads no module declarations.
|
|
1201
|
+
if (moduleName === '' || isSourcePhaseImport(entry.parent))
|
|
1104
1202
|
continue;
|
|
1105
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
|
+
}
|
|
1106
1213
|
const resolved = this.resolver.resolveModuleName(moduleName, containingFile, mode, redirect?.resolved, task.moduleTraces(this.options.traceResolution === true));
|
|
1107
1214
|
resolutions.set(modeAwareKey(moduleName, mode), resolved);
|
|
1108
1215
|
const resolvedFileName = resolved.resolvedFileName;
|
|
@@ -1153,21 +1260,30 @@ export class FileLoader {
|
|
|
1153
1260
|
const redirectFilesByPath = new Map();
|
|
1154
1261
|
const packageIdToSourceFile = new Map();
|
|
1155
1262
|
const checkCasing = this.options.forceConsistentCasingInFileNames !== false;
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1263
|
+
const taskData = this.taskData;
|
|
1264
|
+
// The paths each file's imports and type reference directives add (the tasks of each path), for
|
|
1265
|
+
// `ProcessedFiles.addedFiles`: recorded while collecting visits them, as their files are only known
|
|
1266
|
+
// once every file is collected.
|
|
1267
|
+
const fileData = [];
|
|
1268
|
+
const libData = new Map();
|
|
1269
|
+
const packageIdToData = new Map();
|
|
1270
|
+
const collectFiles = (tasks, added) => {
|
|
1158
1271
|
for (let task of tasks) {
|
|
1159
1272
|
const includeReason = task.includeReason;
|
|
1273
|
+
const byImport = task.byImport;
|
|
1160
1274
|
// Automatic type directive tasks are an implementation detail, not a reason.
|
|
1161
1275
|
if (task.redirectedParseTask === undefined && !task.isForAutomaticTypeDirective) {
|
|
1162
1276
|
if (task.loadedTask !== undefined)
|
|
1163
1277
|
task = task.loadedTask;
|
|
1164
1278
|
if (includeReason !== undefined)
|
|
1165
|
-
addIncludeReason(includeProcessor, task, includeReason);
|
|
1279
|
+
addIncludeReason(includeProcessor, taskData, task, includeReason);
|
|
1166
1280
|
}
|
|
1167
|
-
const data =
|
|
1281
|
+
const data = task.dataIndex >= 0 ? taskData[task.dataIndex] : undefined;
|
|
1282
|
+
if (added !== undefined && data !== undefined && byImport)
|
|
1283
|
+
added.push(data);
|
|
1168
1284
|
if (!task.loaded || data === undefined)
|
|
1169
1285
|
continue;
|
|
1170
|
-
const checkedName =
|
|
1286
|
+
const checkedName = data.collectedName;
|
|
1171
1287
|
if (checkedName !== undefined) {
|
|
1172
1288
|
// The same name normalizes the same: only another spelling needs comparing.
|
|
1173
1289
|
if (checkCasing &&
|
|
@@ -1178,7 +1294,7 @@ export class FileLoader {
|
|
|
1178
1294
|
}
|
|
1179
1295
|
continue;
|
|
1180
1296
|
}
|
|
1181
|
-
|
|
1297
|
+
data.collectedName = task.normalizedFilePath;
|
|
1182
1298
|
if (tasksSeenByNameIgnoreCase !== undefined) {
|
|
1183
1299
|
const lowerCasePath = toFileNameLowerCase(task.path);
|
|
1184
1300
|
const existing = tasksSeenByNameIgnoreCase.get(lowerCasePath);
|
|
@@ -1206,15 +1322,19 @@ export class FileLoader {
|
|
|
1206
1322
|
targets.push(task.normalizedFilePath);
|
|
1207
1323
|
redirectFilesByPath.set(task.path, new RedirectFile(files.length + redirectFilesByPath.size, task.normalizedFilePath, task.path, packageIdFile.path));
|
|
1208
1324
|
filesByPath.set(task.path, packageIdFile);
|
|
1325
|
+
data.keptCopy = packageIdToData.get(key);
|
|
1209
1326
|
if (data.lowestDepth > 0)
|
|
1210
1327
|
sourceFilesFoundSearchingNodeModules.add(task.path);
|
|
1211
1328
|
continue;
|
|
1212
1329
|
}
|
|
1213
|
-
if (file !== undefined)
|
|
1330
|
+
if (file !== undefined) {
|
|
1214
1331
|
packageIdToSourceFile.set(key, file);
|
|
1332
|
+
packageIdToData.set(key, data);
|
|
1333
|
+
}
|
|
1215
1334
|
}
|
|
1335
|
+
let own = undefined;
|
|
1216
1336
|
if (task.subTasks !== undefined && task.subTasks.length > 0)
|
|
1217
|
-
collectFiles(task.subTasks);
|
|
1337
|
+
collectFiles(task.subTasks, (own = []));
|
|
1218
1338
|
const redirected = task.redirectedParseTask;
|
|
1219
1339
|
if (redirected !== undefined) {
|
|
1220
1340
|
outputFileToProjectReferenceSource.set(redirected.path, task.normalizedFilePath);
|
|
@@ -1226,20 +1346,26 @@ export class FileLoader {
|
|
|
1226
1346
|
includeProcessor.addProcessingDiagnostic(diagnostic);
|
|
1227
1347
|
continue;
|
|
1228
1348
|
}
|
|
1229
|
-
const path = task.path;
|
|
1230
1349
|
for (const diagnostic of task.processingDiagnostics ?? noProcessingDiagnostics)
|
|
1231
1350
|
includeProcessor.addProcessingDiagnostic(diagnostic);
|
|
1232
1351
|
if (file === undefined) {
|
|
1233
1352
|
missingFiles.push(task.normalizedFilePath);
|
|
1234
1353
|
continue;
|
|
1235
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;
|
|
1236
1358
|
if (task.libFile !== undefined) {
|
|
1237
1359
|
libFiles.push(file);
|
|
1360
|
+
libData.set(file, data);
|
|
1238
1361
|
libFilesByPath.set(path, task.libFile);
|
|
1239
1362
|
}
|
|
1240
1363
|
else {
|
|
1241
1364
|
files.push(file);
|
|
1365
|
+
fileData.push(data);
|
|
1242
1366
|
}
|
|
1367
|
+
if (own !== undefined)
|
|
1368
|
+
data.added = own;
|
|
1243
1369
|
filesByPath.set(path, file);
|
|
1244
1370
|
resolvedModules.set(path, task.resolutionsInFile);
|
|
1245
1371
|
typeResolutionsInFile.set(path, task.typeResolutionsInFile);
|
|
@@ -1253,7 +1379,7 @@ export class FileLoader {
|
|
|
1253
1379
|
sourceFilesFoundSearchingNodeModules.add(path);
|
|
1254
1380
|
}
|
|
1255
1381
|
};
|
|
1256
|
-
collectFiles(this.rootTasks);
|
|
1382
|
+
collectFiles(this.rootTasks, undefined);
|
|
1257
1383
|
const priorities = new Map();
|
|
1258
1384
|
for (const file of libFiles)
|
|
1259
1385
|
priorities.set(file, this.libFilePriority(file));
|
|
@@ -1261,6 +1387,25 @@ export class FileLoader {
|
|
|
1261
1387
|
const allFiles = [...libFiles, ...files];
|
|
1262
1388
|
for (const redirect of redirectFilesByPath.values())
|
|
1263
1389
|
redirect.index += libFiles.length;
|
|
1390
|
+
// The files a file adds, without reading its resolutions again or looking up their paths.
|
|
1391
|
+
const dataOfFiles = [];
|
|
1392
|
+
for (const file of libFiles)
|
|
1393
|
+
dataOfFiles.push(libData.get(file));
|
|
1394
|
+
for (const data of fileData)
|
|
1395
|
+
dataOfFiles.push(data);
|
|
1396
|
+
for (let i = 0; i < dataOfFiles.length; i++)
|
|
1397
|
+
dataOfFiles[i].index = i;
|
|
1398
|
+
const addedFiles = [];
|
|
1399
|
+
for (let i = 0; i < dataOfFiles.length; i++) {
|
|
1400
|
+
const added = [];
|
|
1401
|
+
for (const data of dataOfFiles[i].added) {
|
|
1402
|
+
const kept = data.keptCopy;
|
|
1403
|
+
const k = kept !== undefined ? kept.index : data.index;
|
|
1404
|
+
if (k >= 0 && k !== i)
|
|
1405
|
+
added.push(k);
|
|
1406
|
+
}
|
|
1407
|
+
addedFiles.push(added);
|
|
1408
|
+
}
|
|
1264
1409
|
const keys = [...this.libResolutions.keys()].sort();
|
|
1265
1410
|
for (const key of keys) {
|
|
1266
1411
|
const resolution = this.libResolutions.get(key);
|
|
@@ -1272,7 +1417,7 @@ export class FileLoader {
|
|
|
1272
1417
|
for (const trace of resolution.trace)
|
|
1273
1418
|
host.trace(trace);
|
|
1274
1419
|
}
|
|
1275
|
-
return new ProcessedFiles(this.resolver, allFiles, filesByPath, missingFiles, resolvedModules, typeResolutionsInFile, sourceFileMetadata, jsxRuntimeImports, importHelpersImportSpecifiers, libFilesByPath, sourceFilesFoundSearchingNodeModules, includeProcessor, outputFileToProjectReferenceSource, redirectTargets, redirectFilesByPath, this.mapper, this.tookPreparedResolutions ? preparedPackageJsonLookups() : noPackageJsonLookups);
|
|
1420
|
+
return new ProcessedFiles(this.resolver, allFiles, filesByPath, missingFiles, resolvedModules, typeResolutionsInFile, sourceFileMetadata, jsxRuntimeImports, importHelpersImportSpecifiers, libFilesByPath, sourceFilesFoundSearchingNodeModules, includeProcessor, outputFileToProjectReferenceSource, redirectTargets, redirectFilesByPath, this.mapper, this.tookPreparedResolutions ? preparedPackageJsonLookups() : noPackageJsonLookups, addedFiles);
|
|
1276
1421
|
}
|
|
1277
1422
|
}
|
|
1278
1423
|
const noPackageJsonLookups = [];
|
|
@@ -1280,12 +1425,20 @@ const noPackageJsonLookups = [];
|
|
|
1280
1425
|
export function releaseLater(loader) {
|
|
1281
1426
|
setImmediate(() => loader.release());
|
|
1282
1427
|
}
|
|
1283
|
-
function addIncludeReason(processor, task, reason) {
|
|
1428
|
+
function addIncludeReason(processor, taskData, task, reason) {
|
|
1284
1429
|
const redirected = task.redirectedParseTask;
|
|
1285
1430
|
if (redirected !== undefined)
|
|
1286
|
-
addIncludeReason(processor, redirected, reason);
|
|
1287
|
-
else if (task.loaded)
|
|
1288
|
-
|
|
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
|
+
}
|
|
1289
1442
|
}
|
|
1290
1443
|
function createProjectReferenceTasks(paths) {
|
|
1291
1444
|
const tasks = [];
|
|
@@ -1302,7 +1455,7 @@ function withoutRoot(path) {
|
|
|
1302
1455
|
/** A specifier of an import the compiler adds, such as `tslib` for `importHelpers`. */
|
|
1303
1456
|
function createSyntheticImport(text, file) {
|
|
1304
1457
|
const specifier = new StringLiteral(text, 0 /* TokenFlags.None */);
|
|
1305
|
-
const declaration = new ImportDeclaration(
|
|
1458
|
+
const declaration = new ImportDeclaration(274 /* SyntaxKind.ImportDeclaration */, undefined, undefined, specifier, undefined);
|
|
1306
1459
|
specifier.parent = declaration;
|
|
1307
1460
|
declaration.parent = file;
|
|
1308
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`. */
|