tsc-ts 0.0.4 → 0.0.6
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 +34 -2
- package/dist/api/compiler/ast-utilities.d.ts +82 -0
- package/dist/api/compiler/ast-utilities.js +462 -0
- package/dist/api/compiler/ast.d.ts +2351 -0
- package/dist/api/compiler/ast.js +11212 -0
- package/dist/api/compiler/astnav.d.ts +37 -0
- package/dist/api/compiler/astnav.js +767 -0
- package/dist/api/compiler/binder-utilities.d.ts +182 -0
- package/dist/api/compiler/binder-utilities.js +1241 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2359 -0
- package/dist/api/compiler/character-codes.d.ts +161 -0
- package/dist/api/compiler/character-codes.js +160 -0
- package/dist/api/compiler/checker-calls.d.ts +46 -0
- package/dist/api/compiler/checker-calls.js +1641 -0
- package/dist/api/compiler/checker-classes.d.ts +30 -0
- package/dist/api/compiler/checker-classes.js +582 -0
- package/dist/api/compiler/checker-contextual.d.ts +77 -0
- package/dist/api/compiler/checker-contextual.js +1136 -0
- package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
- package/dist/api/compiler/checker-declaration-order.js +357 -0
- package/dist/api/compiler/checker-declarations.d.ts +33 -0
- package/dist/api/compiler/checker-declarations.js +888 -0
- package/dist/api/compiler/checker-declared-types.d.ts +48 -0
- package/dist/api/compiler/checker-declared-types.js +788 -0
- package/dist/api/compiler/checker-decorators.d.ts +26 -0
- package/dist/api/compiler/checker-decorators.js +562 -0
- package/dist/api/compiler/checker-deprecation.d.ts +33 -0
- package/dist/api/compiler/checker-deprecation.js +314 -0
- package/dist/api/compiler/checker-destructuring.d.ts +34 -0
- package/dist/api/compiler/checker-destructuring.js +584 -0
- package/dist/api/compiler/checker-elaboration.d.ts +15 -0
- package/dist/api/compiler/checker-elaboration.js +291 -0
- package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
- package/dist/api/compiler/checker-emit-helpers.js +154 -0
- package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
- package/dist/api/compiler/checker-emit-resolver.js +580 -0
- package/dist/api/compiler/checker-evaluator.d.ts +27 -0
- package/dist/api/compiler/checker-evaluator.js +188 -0
- package/dist/api/compiler/checker-expressions.d.ts +67 -0
- package/dist/api/compiler/checker-expressions.js +1351 -0
- package/dist/api/compiler/checker-features.d.ts +6 -0
- package/dist/api/compiler/checker-features.js +354 -0
- package/dist/api/compiler/checker-flow.d.ts +86 -0
- package/dist/api/compiler/checker-flow.js +169 -0
- package/dist/api/compiler/checker-functions.d.ts +43 -0
- package/dist/api/compiler/checker-functions.js +1002 -0
- package/dist/api/compiler/checker-generated-code.d.ts +25 -0
- package/dist/api/compiler/checker-generated-code.js +168 -0
- package/dist/api/compiler/checker-globals.d.ts +14 -0
- package/dist/api/compiler/checker-globals.js +37 -0
- package/dist/api/compiler/checker-grammar.d.ts +35 -0
- package/dist/api/compiler/checker-grammar.js +2587 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +901 -0
- package/dist/api/compiler/checker-inference.d.ts +179 -0
- package/dist/api/compiler/checker-inference.js +2105 -0
- package/dist/api/compiler/checker-iteration.d.ts +115 -0
- package/dist/api/compiler/checker-iteration.js +857 -0
- package/dist/api/compiler/checker-javascript.d.ts +42 -0
- package/dist/api/compiler/checker-javascript.js +442 -0
- package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
- package/dist/api/compiler/checker-jsdoc.js +320 -0
- package/dist/api/compiler/checker-jsx.d.ts +94 -0
- package/dist/api/compiler/checker-jsx.js +1433 -0
- package/dist/api/compiler/checker-literals.d.ts +6 -0
- package/dist/api/compiler/checker-literals.js +43 -0
- package/dist/api/compiler/checker-members.d.ts +200 -0
- package/dist/api/compiler/checker-members.js +2148 -0
- package/dist/api/compiler/checker-modules.d.ts +85 -0
- package/dist/api/compiler/checker-modules.js +2141 -0
- package/dist/api/compiler/checker-narrowing.d.ts +120 -0
- package/dist/api/compiler/checker-narrowing.js +2797 -0
- package/dist/api/compiler/checker-object-literals.d.ts +14 -0
- package/dist/api/compiler/checker-object-literals.js +483 -0
- package/dist/api/compiler/checker-operators.d.ts +33 -0
- package/dist/api/compiler/checker-operators.js +1040 -0
- package/dist/api/compiler/checker-overloads.d.ts +7 -0
- package/dist/api/compiler/checker-overloads.js +271 -0
- package/dist/api/compiler/checker-property-access.d.ts +34 -0
- package/dist/api/compiler/checker-property-access.js +672 -0
- package/dist/api/compiler/checker-services.d.ts +49 -0
- package/dist/api/compiler/checker-services.js +995 -0
- package/dist/api/compiler/checker-signatures.d.ts +55 -0
- package/dist/api/compiler/checker-signatures.js +789 -0
- package/dist/api/compiler/checker-source-file.d.ts +27 -0
- package/dist/api/compiler/checker-source-file.js +619 -0
- package/dist/api/compiler/checker-statements.d.ts +18 -0
- package/dist/api/compiler/checker-statements.js +226 -0
- package/dist/api/compiler/checker-super.d.ts +13 -0
- package/dist/api/compiler/checker-super.js +241 -0
- package/dist/api/compiler/checker-symbol-types.d.ts +51 -0
- package/dist/api/compiler/checker-symbol-types.js +955 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1784 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2542 -0
- package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
- package/dist/api/compiler/checker-type-nodes.js +828 -0
- package/dist/api/compiler/checker-type-operators.d.ts +109 -0
- package/dist/api/compiler/checker-type-operators.js +1842 -0
- package/dist/api/compiler/checker-types.d.ts +1093 -0
- package/dist/api/compiler/checker-types.js +1874 -0
- package/dist/api/compiler/checker-unused.d.ts +19 -0
- package/dist/api/compiler/checker-unused.js +524 -0
- package/dist/api/compiler/checker-utilities.d.ts +33 -0
- package/dist/api/compiler/checker-utilities.js +141 -0
- package/dist/api/compiler/checker.d.ts +512 -0
- package/dist/api/compiler/checker.js +932 -0
- package/dist/api/compiler/command-line.d.ts +32 -0
- package/dist/api/compiler/command-line.js +383 -0
- package/dist/api/compiler/compile-program.d.ts +118 -0
- package/dist/api/compiler/compile-program.js +384 -0
- package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
- package/dist/api/compiler/diagnostic-locales.js +64 -0
- package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
- package/dist/api/compiler/diagnostic-messages.js +184 -0
- package/dist/api/compiler/diagnostics.d.ts +161 -0
- package/dist/api/compiler/diagnostics.js +784 -0
- package/dist/api/compiler/emitter.d.ts +71 -0
- package/dist/api/compiler/emitter.js +327 -0
- package/dist/api/compiler/file-include.d.ts +144 -0
- package/dist/api/compiler/file-include.js +599 -0
- package/dist/api/compiler/file-loader.d.ts +290 -0
- package/dist/api/compiler/file-loader.js +1323 -0
- package/dist/api/compiler/file-system.d.ts +51 -0
- package/dist/api/compiler/file-system.js +132 -0
- package/dist/api/compiler/flow.d.ts +60 -0
- package/dist/api/compiler/flow.js +45 -0
- package/dist/api/compiler/instantiation.d.ts +74 -0
- package/dist/api/compiler/instantiation.js +835 -0
- package/dist/api/compiler/jsdoc.d.ts +75 -0
- package/dist/api/compiler/jsdoc.js +1229 -0
- package/dist/api/compiler/link-tables.d.ts +105 -0
- package/dist/api/compiler/link-tables.js +319 -0
- package/dist/api/compiler/locale-data.d.ts +24 -0
- package/dist/api/compiler/locale-data.js +183 -0
- package/dist/api/compiler/locale.d.ts +4 -0
- package/dist/api/compiler/locale.js +317 -0
- package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
- package/dist/api/compiler/locales/cs-CZ.js +3 -0
- package/dist/api/compiler/locales/de-DE.d.ts +2 -0
- package/dist/api/compiler/locales/de-DE.js +3 -0
- package/dist/api/compiler/locales/es-ES.d.ts +2 -0
- package/dist/api/compiler/locales/es-ES.js +3 -0
- package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
- package/dist/api/compiler/locales/fr-FR.js +3 -0
- package/dist/api/compiler/locales/it-IT.d.ts +2 -0
- package/dist/api/compiler/locales/it-IT.js +3 -0
- package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
- package/dist/api/compiler/locales/ja-JP.js +3 -0
- package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
- package/dist/api/compiler/locales/ko-KR.js +3 -0
- package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
- package/dist/api/compiler/locales/pl-PL.js +3 -0
- package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
- package/dist/api/compiler/locales/pt-BR.js +3 -0
- package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
- package/dist/api/compiler/locales/ru-RU.js +3 -0
- package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
- package/dist/api/compiler/locales/tr-TR.js +3 -0
- package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
- package/dist/api/compiler/locales/zh-CN.js +3 -0
- package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
- package/dist/api/compiler/locales/zh-TW.js +3 -0
- package/dist/api/compiler/module-resolution-types.d.ts +83 -0
- package/dist/api/compiler/module-resolution-types.js +176 -0
- package/dist/api/compiler/module-resolution.d.ts +71 -0
- package/dist/api/compiler/module-resolution.js +1598 -0
- package/dist/api/compiler/module-specifiers.d.ts +64 -0
- package/dist/api/compiler/module-specifiers.js +1101 -0
- package/dist/api/compiler/name-resolver.d.ts +43 -0
- package/dist/api/compiler/name-resolver.js +509 -0
- package/dist/api/compiler/node-builder-names.d.ts +32 -0
- package/dist/api/compiler/node-builder-names.js +854 -0
- package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
- package/dist/api/compiler/node-builder-pseudo.js +745 -0
- package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
- package/dist/api/compiler/node-builder-reuse.js +647 -0
- package/dist/api/compiler/node-builder.d.ts +270 -0
- package/dist/api/compiler/node-builder.js +2645 -0
- package/dist/api/compiler/option-declarations.d.ts +90 -0
- package/dist/api/compiler/option-declarations.js +1460 -0
- package/dist/api/compiler/options.d.ts +289 -0
- package/dist/api/compiler/options.js +1197 -0
- package/dist/api/compiler/output-paths.d.ts +42 -0
- package/dist/api/compiler/output-paths.js +195 -0
- package/dist/api/compiler/package-json.d.ts +175 -0
- package/dist/api/compiler/package-json.js +1015 -0
- package/dist/api/compiler/parallel-parse.d.ts +221 -0
- package/dist/api/compiler/parallel-parse.js +541 -0
- package/dist/api/compiler/parser.d.ts +604 -0
- package/dist/api/compiler/parser.js +6426 -0
- package/dist/api/compiler/path.d.ts +91 -0
- package/dist/api/compiler/path.js +705 -0
- package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
- package/dist/api/compiler/printer/async-helpers.js +91 -0
- package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
- package/dist/api/compiler/printer/auto-generate.js +20 -0
- package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
- package/dist/api/compiler/printer/decorator-helpers.js +118 -0
- package/dist/api/compiler/printer/emit-context.d.ts +157 -0
- package/dist/api/compiler/printer/emit-context.js +582 -0
- package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
- package/dist/api/compiler/printer/emit-flags.js +2 -0
- package/dist/api/compiler/printer/factory-base.d.ts +171 -0
- package/dist/api/compiler/printer/factory-base.js +1505 -0
- package/dist/api/compiler/printer/factory.d.ts +147 -0
- package/dist/api/compiler/printer/factory.js +542 -0
- package/dist/api/compiler/printer/helpers.d.ts +27 -0
- package/dist/api/compiler/printer/helpers.js +164 -0
- package/dist/api/compiler/printer/name-generator.d.ts +41 -0
- package/dist/api/compiler/printer/name-generator.js +283 -0
- package/dist/api/compiler/printer/printer.d.ts +411 -0
- package/dist/api/compiler/printer/printer.js +4517 -0
- package/dist/api/compiler/printer/text-writer.d.ts +46 -0
- package/dist/api/compiler/printer/text-writer.js +172 -0
- package/dist/api/compiler/printer/utilities.d.ts +82 -0
- package/dist/api/compiler/printer/utilities.js +817 -0
- package/dist/api/compiler/program-checker.d.ts +156 -0
- package/dist/api/compiler/program-checker.js +529 -0
- package/dist/api/compiler/program-utilities.d.ts +52 -0
- package/dist/api/compiler/program-utilities.js +365 -0
- package/dist/api/compiler/program.d.ts +180 -0
- package/dist/api/compiler/program.js +1019 -0
- package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
- package/dist/api/compiler/pseudo-bigint.js +61 -0
- package/dist/api/compiler/regexp-checker.d.ts +38 -0
- package/dist/api/compiler/regexp-checker.js +942 -0
- package/dist/api/compiler/relations.d.ts +263 -0
- package/dist/api/compiler/relations.js +4002 -0
- package/dist/api/compiler/reparser.d.ts +48 -0
- package/dist/api/compiler/reparser.js +1323 -0
- package/dist/api/compiler/scanner.d.ts +256 -0
- package/dist/api/compiler/scanner.js +2853 -0
- package/dist/api/compiler/side-state.d.ts +16 -0
- package/dist/api/compiler/side-state.js +89 -0
- package/dist/api/compiler/sourcemap.d.ts +55 -0
- package/dist/api/compiler/sourcemap.js +340 -0
- package/dist/api/compiler/spelling.d.ts +14 -0
- package/dist/api/compiler/spelling.js +128 -0
- package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
- package/dist/api/compiler/symbol-accessibility.js +991 -0
- package/dist/api/compiler/symbol.d.ts +282 -0
- package/dist/api/compiler/symbol.js +339 -0
- package/dist/api/compiler/symlinks.d.ts +32 -0
- package/dist/api/compiler/symlinks.js +114 -0
- package/dist/api/compiler/syntax-kind.d.ts +389 -0
- package/dist/api/compiler/syntax-kind.js +2 -0
- package/dist/api/compiler/timeline.d.ts +9 -0
- package/dist/api/compiler/timeline.js +54 -0
- package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
- package/dist/api/compiler/transformers/alias-references.js +677 -0
- package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
- package/dist/api/compiler/transformers/async-utilities.js +260 -0
- package/dist/api/compiler/transformers/async.d.ts +53 -0
- package/dist/api/compiler/transformers/async.js +645 -0
- package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
- package/dist/api/compiler/transformers/class-fields.js +2418 -0
- package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
- package/dist/api/compiler/transformers/class-utilities.js +261 -0
- package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
- package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
- package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
- package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.js +539 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +799 -0
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
- package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
- package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
- package/dist/api/compiler/transformers/declarations-tracker.js +198 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2381 -0
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
- package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
- package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
- package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
- package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
- package/dist/api/compiler/transformers/destructuring.js +626 -0
- package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
- package/dist/api/compiler/transformers/downlevel.js +45 -0
- package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
- package/dist/api/compiler/transformers/emit-resolver.js +197 -0
- package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
- package/dist/api/compiler/transformers/es-decorators.js +1901 -0
- package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
- package/dist/api/compiler/transformers/exponentiation.js +76 -0
- package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
- package/dist/api/compiler/transformers/external-module-info.js +351 -0
- package/dist/api/compiler/transformers/for-await.d.ts +43 -0
- package/dist/api/compiler/transformers/for-await.js +469 -0
- package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
- package/dist/api/compiler/transformers/import-elision.js +124 -0
- package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
- package/dist/api/compiler/transformers/jsx-entities.js +256 -0
- package/dist/api/compiler/transformers/jsx.d.ts +71 -0
- package/dist/api/compiler/transformers/jsx.js +700 -0
- package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
- package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
- package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
- package/dist/api/compiler/transformers/logical-assignment.js +62 -0
- package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
- package/dist/api/compiler/transformers/module-utilities.js +36 -0
- package/dist/api/compiler/transformers/module.d.ts +49 -0
- package/dist/api/compiler/transformers/module.js +296 -0
- package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
- package/dist/api/compiler/transformers/named-evaluation.js +266 -0
- package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
- package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
- package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
- package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
- package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
- package/dist/api/compiler/transformers/optional-catch.js +20 -0
- package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
- package/dist/api/compiler/transformers/optional-chain.js +188 -0
- package/dist/api/compiler/transformers/reference-resolver.d.ts +129 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1157 -0
- package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
- package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
- package/dist/api/compiler/transformers/subtree-facts.d.ts +10 -0
- package/dist/api/compiler/transformers/subtree-facts.js +205 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +52 -0
- package/dist/api/compiler/transformers/syntax-facts.js +258 -0
- package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
- package/dist/api/compiler/transformers/tagged-template.js +148 -0
- package/dist/api/compiler/transformers/transformer.d.ts +17 -0
- package/dist/api/compiler/transformers/transformer.js +54 -0
- package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
- package/dist/api/compiler/transformers/type-eraser.js +346 -0
- package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
- package/dist/api/compiler/transformers/type-serialization.js +347 -0
- package/dist/api/compiler/transformers/using.d.ts +56 -0
- package/dist/api/compiler/transformers/using.js +453 -0
- package/dist/api/compiler/transformers/utilities.d.ts +50 -0
- package/dist/api/compiler/transformers/utilities.js +347 -0
- package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
- package/dist/api/compiler/transformers/visitor-base.js +817 -0
- package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
- package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
- package/dist/api/compiler/tsconfig.d.ts +177 -0
- package/dist/api/compiler/tsconfig.js +1311 -0
- package/dist/api/compiler/type-printer.d.ts +15 -0
- package/dist/api/compiler/type-printer.js +74 -0
- package/dist/api/compiler/types.d.ts +87 -0
- package/dist/api/compiler/types.js +23 -0
- package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
- package/dist/api/compiler/unicode-identifiers.js +209 -0
- package/dist/api/compiler/unicode-properties.d.ts +8 -0
- package/dist/api/compiler/unicode-properties.js +531 -0
- package/dist/api/compiler/vfs-match.d.ts +24 -0
- package/dist/api/compiler/vfs-match.js +587 -0
- package/dist/api/library/ast.d.ts +3 -2
- package/dist/api/library/ast.generated.d.ts +127 -139
- package/dist/api/library/checker.d.ts +51 -0
- package/dist/api/library/checker.js +318 -0
- package/dist/api/library/diagnostics.d.ts +13 -0
- package/dist/api/library/diagnostics.js +50 -0
- package/dist/api/library/disk.d.ts +13 -0
- package/dist/api/library/disk.js +66 -0
- package/dist/api/library/errors.d.ts +13 -0
- package/dist/api/library/errors.js +24 -0
- package/dist/api/library/host.d.ts +24 -0
- package/dist/api/library/host.js +52 -0
- package/dist/api/library/index.d.ts +5 -1
- package/dist/api/library/index.js +4 -0
- package/dist/api/library/nodes.d.ts +51 -0
- package/dist/api/library/nodes.js +196 -0
- package/dist/api/library/options.d.ts +144 -0
- package/dist/api/library/options.js +308 -0
- package/dist/api/library/parse.d.ts +19 -0
- package/dist/api/library/parse.js +41 -0
- package/dist/api/library/program.d.ts +21 -0
- package/dist/api/library/program.js +234 -0
- package/dist/api/library/types.d.ts +14 -1
- package/package.json +12 -8
- package/src/compiler/ast-utilities.ts +548 -0
- package/src/compiler/ast.ts +12870 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2707 -0
- package/src/compiler/build-info.ts +1197 -0
- package/src/compiler/character-codes.ts +323 -0
- package/src/compiler/checker-calls.ts +2155 -0
- package/src/compiler/checker-classes.ts +706 -0
- package/src/compiler/checker-contextual.ts +1457 -0
- package/src/compiler/checker-declaration-order.ts +438 -0
- package/src/compiler/checker-declarations.ts +1201 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +355 -0
- package/src/compiler/checker-destructuring.ts +805 -0
- package/src/compiler/checker-elaboration.ts +477 -0
- package/src/compiler/checker-emit-helpers.ts +224 -0
- package/src/compiler/checker-emit-resolver.ts +769 -0
- package/src/compiler/checker-evaluator.ts +243 -0
- package/src/compiler/checker-expressions.ts +1831 -0
- package/src/compiler/checker-features.ts +361 -0
- package/src/compiler/checker-flow.ts +394 -0
- package/src/compiler/checker-functions.ts +1296 -0
- package/src/compiler/checker-generated-code.ts +227 -0
- package/src/compiler/checker-globals.ts +52 -0
- package/src/compiler/checker-grammar.ts +3596 -0
- package/src/compiler/checker-heritage.ts +1240 -0
- package/src/compiler/checker-inference.ts +2584 -0
- package/src/compiler/checker-iteration.ts +1206 -0
- package/src/compiler/checker-javascript.ts +502 -0
- package/src/compiler/checker-jsdoc.ts +360 -0
- package/src/compiler/checker-jsx.ts +1928 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2480 -0
- package/src/compiler/checker-modules.ts +2896 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +591 -0
- package/src/compiler/checker-operators.ts +1422 -0
- package/src/compiler/checker-overloads.ts +328 -0
- package/src/compiler/checker-property-access.ts +906 -0
- package/src/compiler/checker-services.ts +1149 -0
- package/src/compiler/checker-signatures.ts +1032 -0
- package/src/compiler/checker-source-file.ts +732 -0
- package/src/compiler/checker-statements.ts +292 -0
- package/src/compiler/checker-super.ts +261 -0
- package/src/compiler/checker-symbol-types.ts +1187 -0
- package/src/compiler/checker-symbols.ts +2157 -0
- package/src/compiler/checker-type-factory.ts +2616 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2510 -0
- package/src/compiler/checker-types.ts +2520 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1138 -0
- package/src/compiler/command-line.ts +436 -0
- package/src/compiler/compile-program.ts +439 -0
- package/src/compiler/decoder.ts +1209 -0
- package/src/compiler/diagnostic-locales.ts +86 -0
- package/src/compiler/diagnostic-messages.ts +2349 -0
- package/src/compiler/diagnostics.ts +858 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +741 -0
- package/src/compiler/file-loader.ts +1597 -0
- package/src/compiler/file-system.ts +143 -0
- package/src/compiler/flow.ts +89 -0
- package/src/compiler/help.ts +473 -0
- package/src/compiler/incremental.ts +2818 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +938 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +343 -0
- package/src/compiler/locale-data.ts +203 -0
- package/src/compiler/locale.ts +307 -0
- package/src/compiler/locales/cs-CZ.ts +5 -0
- package/src/compiler/locales/de-DE.ts +5 -0
- package/src/compiler/locales/es-ES.ts +5 -0
- package/src/compiler/locales/fr-FR.ts +5 -0
- package/src/compiler/locales/it-IT.ts +5 -0
- package/src/compiler/locales/ja-JP.ts +5 -0
- package/src/compiler/locales/ko-KR.ts +5 -0
- package/src/compiler/locales/pl-PL.ts +5 -0
- package/src/compiler/locales/pt-BR.ts +5 -0
- package/src/compiler/locales/ru-RU.ts +5 -0
- package/src/compiler/locales/tr-TR.ts +5 -0
- package/src/compiler/locales/zh-CN.ts +5 -0
- package/src/compiler/locales/zh-TW.ts +5 -0
- package/src/compiler/module-resolution-types.ts +243 -0
- package/src/compiler/module-resolution.ts +2072 -0
- package/src/compiler/module-specifiers.ts +1491 -0
- package/src/compiler/name-resolver.ts +646 -0
- package/src/compiler/node-builder-names.ts +1071 -0
- package/src/compiler/node-builder-pseudo.ts +892 -0
- package/src/compiler/node-builder-reuse.ts +764 -0
- package/src/compiler/node-builder.ts +3433 -0
- package/src/compiler/option-declarations.ts +1560 -0
- package/src/compiler/options.ts +1576 -0
- package/src/compiler/output-paths.ts +334 -0
- package/src/compiler/package-json.ts +1083 -0
- package/src/compiler/parallel-check.ts +1954 -0
- package/src/compiler/parallel-parse.ts +595 -0
- package/src/compiler/parse-thread.ts +136 -0
- package/src/compiler/parser.ts +7766 -0
- package/src/compiler/path.ts +717 -0
- package/src/compiler/printer/async-helpers.ts +183 -0
- package/src/compiler/printer/auto-generate.ts +27 -0
- package/src/compiler/printer/decorator-helpers.ts +218 -0
- package/src/compiler/printer/emit-context.ts +684 -0
- package/src/compiler/printer/emit-flags.ts +64 -0
- package/src/compiler/printer/factory-base.ts +2577 -0
- package/src/compiler/printer/factory.ts +764 -0
- package/src/compiler/printer/helpers.ts +291 -0
- package/src/compiler/printer/name-generator.ts +372 -0
- package/src/compiler/printer/printer.ts +5072 -0
- package/src/compiler/printer/text-writer.ts +183 -0
- package/src/compiler/printer/utilities.ts +884 -0
- package/src/compiler/program-checker.ts +594 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1426 -0
- package/src/compiler/pseudo-bigint.ts +62 -0
- package/src/compiler/regexp-checker.ts +1142 -0
- package/src/compiler/relations.ts +5149 -0
- package/src/compiler/reparser.ts +1566 -0
- package/src/compiler/scanner.ts +2951 -0
- package/src/compiler/show-config.ts +239 -0
- package/src/compiler/side-state.ts +125 -0
- package/src/compiler/sourcemap.ts +366 -0
- package/src/compiler/spelling.ts +122 -0
- package/src/compiler/symbol-accessibility.ts +1166 -0
- package/src/compiler/symbol.ts +557 -0
- package/src/compiler/symlinks.ts +137 -0
- package/src/compiler/syntax-kind.ts +391 -0
- package/src/compiler/thread-entry.ts +191 -0
- package/src/compiler/timeline.ts +53 -0
- package/src/compiler/transformers/alias-references.ts +757 -0
- package/src/compiler/transformers/async-utilities.ts +335 -0
- package/src/compiler/transformers/async.ts +838 -0
- package/src/compiler/transformers/class-fields.ts +2967 -0
- package/src/compiler/transformers/class-utilities.ts +324 -0
- package/src/compiler/transformers/commonjs-module.ts +1621 -0
- package/src/compiler/transformers/const-enum-inliner.ts +50 -0
- package/src/compiler/transformers/declarations-diagnostics.ts +833 -0
- package/src/compiler/transformers/declarations-pseudo.ts +969 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1867 -0
- package/src/compiler/transformers/declarations-tracker.ts +269 -0
- package/src/compiler/transformers/declarations.ts +3120 -0
- package/src/compiler/transformers/decorator-metadata.ts +697 -0
- package/src/compiler/transformers/decorator-utilities.ts +283 -0
- package/src/compiler/transformers/destructuring.ts +708 -0
- package/src/compiler/transformers/downlevel.ts +50 -0
- package/src/compiler/transformers/emit-resolver.ts +258 -0
- package/src/compiler/transformers/es-decorators.ts +2682 -0
- package/src/compiler/transformers/exponentiation.ts +80 -0
- package/src/compiler/transformers/external-module-info.ts +412 -0
- package/src/compiler/transformers/for-await.ts +687 -0
- package/src/compiler/transformers/import-elision.ts +152 -0
- package/src/compiler/transformers/jsx-entities.ts +256 -0
- package/src/compiler/transformers/jsx.ts +824 -0
- package/src/compiler/transformers/legacy-decorators.ts +726 -0
- package/src/compiler/transformers/logical-assignment.ts +75 -0
- package/src/compiler/transformers/module-utilities.ts +42 -0
- package/src/compiler/transformers/module.ts +474 -0
- package/src/compiler/transformers/named-evaluation.ts +389 -0
- package/src/compiler/transformers/nullish-coalescing.ts +35 -0
- package/src/compiler/transformers/object-rest-spread.ts +577 -0
- package/src/compiler/transformers/optional-catch.ts +29 -0
- package/src/compiler/transformers/optional-chain.ts +246 -0
- package/src/compiler/transformers/reference-resolver.ts +1213 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +253 -0
- package/src/compiler/transformers/syntax-facts.ts +358 -0
- package/src/compiler/transformers/tagged-template.ts +167 -0
- package/src/compiler/transformers/transformer.ts +56 -0
- package/src/compiler/transformers/type-eraser.ts +520 -0
- package/src/compiler/transformers/type-serialization.ts +374 -0
- package/src/compiler/transformers/using.ts +613 -0
- package/src/compiler/transformers/utilities.ts +419 -0
- package/src/compiler/transformers/visitor-base.ts +1601 -0
- package/src/compiler/transformers/visitor-hooks.ts +252 -0
- package/src/compiler/tsc-build.ts +1422 -0
- package/src/compiler/tsc-cli.ts +669 -0
- package/src/compiler/tsc-compile.ts +446 -0
- package/src/compiler/tsc-watch.ts +922 -0
- package/src/compiler/tsconfig.ts +1574 -0
- package/src/compiler/type-printer.ts +110 -0
- package/src/compiler/types.ts +115 -0
- package/src/compiler/unicode-identifiers.ts +212 -0
- package/src/compiler/unicode-properties.ts +537 -0
- package/src/compiler/vfs-match.ts +597 -0
- package/src/compiler/xxh3.ts +650 -0
- package/src/library/ast.generated.ts +141 -167
- package/src/library/ast.ts +4 -1
- package/src/library/checker.ts +384 -0
- package/src/library/diagnostics.ts +72 -0
- package/src/library/disk.ts +73 -0
- package/src/library/errors.ts +26 -0
- package/src/library/host.ts +63 -0
- package/src/library/index.ts +21 -0
- package/src/library/nodes.ts +232 -0
- package/src/library/options.ts +449 -0
- package/src/library/parse.ts +63 -0
- package/src/library/program.ts +293 -0
- package/src/library/types.ts +14 -1
|
@@ -0,0 +1,1311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tsconfig.json: options, `extends`, `files`/`include`/`exclude` and project references, with tsgo's diagnostics.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* const errors: Diagnostic[] = [];
|
|
6
|
+
* const config = new ConfigParser(fs, '/app').parseConfigFile('/app/tsconfig.json', {}, undefined, errors);
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
import { ArrayLiteralExpression, ComputedPropertyName, ExpressionStatement, ExternalModuleIndicatorOptions, getText, Identifier, NumericLiteral, ObjectLiteralExpression, ParseOptions, PrefixUnaryExpression, PropertyAssignment, StringLiteral, } from './ast.js';
|
|
10
|
+
import { enumNamesList } from './command-line.js';
|
|
11
|
+
import { compareCodePoints, createCompilerDiagnostic, Diagnostic, } from './diagnostics.js';
|
|
12
|
+
import { isValidLocale } from './locale.js';
|
|
13
|
+
import { ModuleResolutionHost, resolveConfig } from './module-resolution.js';
|
|
14
|
+
import { compilerOptionsByName, OptionNameMap, typeAcquisitionDeclarations, } from './option-declarations.js';
|
|
15
|
+
import { getAllowJS, getResolveJsonModule, mergeCompilerOptions, setCompilerOption, setTypeAcquisitionOption, } from './options.js';
|
|
16
|
+
import { getBuildInfoFileName, getCommonSourceDirectory, getOutputDeclarationFileName, } from './output-paths.js';
|
|
17
|
+
import { parseSourceFile } from './parser.js';
|
|
18
|
+
import { changeExtension, combinePaths, containsPath, fileExtensionIs, fileExtensionIsOneOf, getBaseFileName, getCanonicalFileName, getDirectoryPath, getNormalizedAbsolutePath, getPathComponentsRelativeTo, getPathFromPathComponents, hasJSFileExtension, isDeclarationFileName, isRootedDiskPath, normalizePath, normalizeSlashes, toPath, } from './path.js';
|
|
19
|
+
import { skipTrivia } from './scanner.js';
|
|
20
|
+
import { hasExtension, readDirectory, SpecMatcher, unlimitedDepth } from './vfs-match.js';
|
|
21
|
+
export class JsonArray {
|
|
22
|
+
items;
|
|
23
|
+
dropped;
|
|
24
|
+
constructor(items,
|
|
25
|
+
/** A non-empty array whose items were all `null` or invalid, which tsgo treats like a missing array. */
|
|
26
|
+
dropped = false) {
|
|
27
|
+
this.items = items;
|
|
28
|
+
this.dropped = dropped;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Entries in source order; a repeated key keeps its first position and its last value. */
|
|
32
|
+
export class JsonObject {
|
|
33
|
+
entries = new Map();
|
|
34
|
+
}
|
|
35
|
+
function stringItems(value) {
|
|
36
|
+
if (!(value instanceof JsonArray) || value.dropped)
|
|
37
|
+
return undefined;
|
|
38
|
+
const result = [];
|
|
39
|
+
for (const item of value.items)
|
|
40
|
+
if (typeof item === 'string')
|
|
41
|
+
result.push(item);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
// ---- Supported extensions
|
|
45
|
+
const supportedTSExtensions = [
|
|
46
|
+
['.ts', '.tsx', '.d.ts'],
|
|
47
|
+
['.cts', '.d.cts'],
|
|
48
|
+
['.mts', '.d.mts'],
|
|
49
|
+
];
|
|
50
|
+
const allSupportedExtensions = [
|
|
51
|
+
['.ts', '.tsx', '.d.ts', '.js', '.jsx'],
|
|
52
|
+
['.cts', '.d.cts', '.cjs'],
|
|
53
|
+
['.mts', '.d.mts', '.mjs'],
|
|
54
|
+
];
|
|
55
|
+
const supportedTSExtensionsWithJson = [...supportedTSExtensions, ['.json']];
|
|
56
|
+
const allSupportedExtensionsWithJson = [...allSupportedExtensions, ['.json']];
|
|
57
|
+
/** Extensions of root files, in priority groups. */
|
|
58
|
+
export function getSupportedExtensions(options) {
|
|
59
|
+
return getAllowJS(options) ? allSupportedExtensions : supportedTSExtensions;
|
|
60
|
+
}
|
|
61
|
+
export function getSupportedExtensionsWithJsonIfResolveJsonModule(options) {
|
|
62
|
+
if (!getResolveJsonModule(options))
|
|
63
|
+
return getSupportedExtensions(options);
|
|
64
|
+
return getAllowJS(options) ? allSupportedExtensionsWithJson : supportedTSExtensionsWithJson;
|
|
65
|
+
}
|
|
66
|
+
export function flattenExtensions(groups) {
|
|
67
|
+
const result = [];
|
|
68
|
+
for (const group of groups)
|
|
69
|
+
for (const extension of group)
|
|
70
|
+
result.push(extension);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
// ---- Parsed configuration
|
|
74
|
+
export class ProjectReference {
|
|
75
|
+
path;
|
|
76
|
+
originalPath;
|
|
77
|
+
circular;
|
|
78
|
+
constructor(
|
|
79
|
+
/** Absolute path of the referenced config file or directory. */
|
|
80
|
+
path, originalPath, circular) {
|
|
81
|
+
this.path = path;
|
|
82
|
+
this.originalPath = originalPath;
|
|
83
|
+
this.circular = circular;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** The config file `path` of a reference names: itself if a `.json` file, else its `tsconfig.json`. */
|
|
87
|
+
export function resolveProjectReferencePath(reference) {
|
|
88
|
+
return fileExtensionIs(reference.path, '.json') ? reference.path : combinePaths(reference.path, 'tsconfig.json');
|
|
89
|
+
}
|
|
90
|
+
/** `files`, `include` and `exclude` after validation. */
|
|
91
|
+
export class ConfigFileSpecs {
|
|
92
|
+
validatedFilesSpec;
|
|
93
|
+
validatedIncludeSpecs;
|
|
94
|
+
validatedExcludeSpecs;
|
|
95
|
+
validatedFilesSpecBeforeSubstitution;
|
|
96
|
+
validatedIncludeSpecsBeforeSubstitution;
|
|
97
|
+
isDefaultIncludeSpec;
|
|
98
|
+
constructor(validatedFilesSpec, validatedIncludeSpecs, validatedExcludeSpecs, validatedFilesSpecBeforeSubstitution, validatedIncludeSpecsBeforeSubstitution, isDefaultIncludeSpec) {
|
|
99
|
+
this.validatedFilesSpec = validatedFilesSpec;
|
|
100
|
+
this.validatedIncludeSpecs = validatedIncludeSpecs;
|
|
101
|
+
this.validatedExcludeSpecs = validatedExcludeSpecs;
|
|
102
|
+
this.validatedFilesSpecBeforeSubstitution = validatedFilesSpecBeforeSubstitution;
|
|
103
|
+
this.validatedIncludeSpecsBeforeSubstitution = validatedIncludeSpecsBeforeSubstitution;
|
|
104
|
+
this.isDefaultIncludeSpec = isDefaultIncludeSpec;
|
|
105
|
+
}
|
|
106
|
+
matchesExclude(fileName, currentDirectory, useCaseSensitiveFileNames) {
|
|
107
|
+
if (this.validatedExcludeSpecs.length === 0)
|
|
108
|
+
return false;
|
|
109
|
+
const matcher = SpecMatcher.create(this.validatedExcludeSpecs, currentDirectory, 2 /* MatchUsage.Exclude */, useCaseSensitiveFileNames);
|
|
110
|
+
if (matcher === undefined)
|
|
111
|
+
return false;
|
|
112
|
+
if (matcher.matches(fileName))
|
|
113
|
+
return true;
|
|
114
|
+
return !hasExtension(fileName) && matcher.matches(fileName + '/');
|
|
115
|
+
}
|
|
116
|
+
/** The `include` spec (as written) matching `fileName`, or `''`. */
|
|
117
|
+
getMatchedIncludeSpec(fileName, currentDirectory, useCaseSensitiveFileNames) {
|
|
118
|
+
for (let i = 0; i < this.validatedIncludeSpecs.length; i++) {
|
|
119
|
+
const matcher = SpecMatcher.create([this.validatedIncludeSpecs[i]], currentDirectory, 0 /* MatchUsage.Files */, useCaseSensitiveFileNames);
|
|
120
|
+
if (matcher !== undefined && matcher.matches(fileName))
|
|
121
|
+
return this.validatedIncludeSpecsBeforeSubstitution[i];
|
|
122
|
+
}
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
125
|
+
/** The `files` entry (as written) naming `fileName`, or `''`. */
|
|
126
|
+
getMatchedFileSpec(fileName, currentDirectory, useCaseSensitiveFileNames) {
|
|
127
|
+
const path = toPath(fileName, currentDirectory, useCaseSensitiveFileNames);
|
|
128
|
+
for (let i = 0; i < this.validatedFilesSpec.length; i++) {
|
|
129
|
+
if (toPath(this.validatedFilesSpec[i], currentDirectory, useCaseSensitiveFileNames) === path) {
|
|
130
|
+
return this.validatedFilesSpecBeforeSubstitution[i];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** A parsed config file: its syntax tree and the config files it extends. */
|
|
137
|
+
export class TsConfigSourceFile {
|
|
138
|
+
sourceFile;
|
|
139
|
+
/** Every config file this one extends, directly or not, sorted. */
|
|
140
|
+
extendedSourceFiles = [];
|
|
141
|
+
configFileSpecs = undefined;
|
|
142
|
+
constructor(sourceFile) {
|
|
143
|
+
this.sourceFile = sourceFile;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Options, root files and references of a project, from a config file or the command line. */
|
|
147
|
+
export class ParsedCommandLine {
|
|
148
|
+
options;
|
|
149
|
+
typeAcquisition;
|
|
150
|
+
fileNames;
|
|
151
|
+
projectReferences;
|
|
152
|
+
configFile;
|
|
153
|
+
errors;
|
|
154
|
+
currentDirectory;
|
|
155
|
+
useCaseSensitiveFileNames;
|
|
156
|
+
literalFileNamesLength;
|
|
157
|
+
/** The config file name, or `''`. */
|
|
158
|
+
configName;
|
|
159
|
+
/** Where `getOutputDeclarationFileName` maps sources of this project, once computed. */
|
|
160
|
+
sourceToReference = undefined;
|
|
161
|
+
outputDtsToReference = undefined;
|
|
162
|
+
commonSourceDirectoryValue = undefined;
|
|
163
|
+
referencePaths = undefined;
|
|
164
|
+
constructor(options, typeAcquisition, fileNames, projectReferences, configFile, errors,
|
|
165
|
+
/** The config's directory, or the current directory without a config. */
|
|
166
|
+
currentDirectory, useCaseSensitiveFileNames,
|
|
167
|
+
/** How many of `fileNames` come from `files`. */
|
|
168
|
+
literalFileNamesLength) {
|
|
169
|
+
this.options = options;
|
|
170
|
+
this.typeAcquisition = typeAcquisition;
|
|
171
|
+
this.fileNames = fileNames;
|
|
172
|
+
this.projectReferences = projectReferences;
|
|
173
|
+
this.configFile = configFile;
|
|
174
|
+
this.errors = errors;
|
|
175
|
+
this.currentDirectory = currentDirectory;
|
|
176
|
+
this.useCaseSensitiveFileNames = useCaseSensitiveFileNames;
|
|
177
|
+
this.literalFileNamesLength = literalFileNamesLength;
|
|
178
|
+
this.configName = configFile === undefined ? '' : configFile.sourceFile.fileName;
|
|
179
|
+
}
|
|
180
|
+
/** Config file paths of the references. */
|
|
181
|
+
resolvedProjectReferencePaths() {
|
|
182
|
+
if (this.referencePaths === undefined) {
|
|
183
|
+
this.referencePaths = [];
|
|
184
|
+
for (const reference of this.projectReferences)
|
|
185
|
+
this.referencePaths.push(resolveProjectReferencePath(reference));
|
|
186
|
+
}
|
|
187
|
+
return this.referencePaths;
|
|
188
|
+
}
|
|
189
|
+
/** Diagnostics of reading the config: syntax errors, then option errors. */
|
|
190
|
+
configFileParsingDiagnostics() {
|
|
191
|
+
if (this.configFile === undefined)
|
|
192
|
+
return this.errors;
|
|
193
|
+
return [...this.configFile.sourceFile.diagnostics, ...this.errors];
|
|
194
|
+
}
|
|
195
|
+
getMatchedFileSpec(fileName) {
|
|
196
|
+
const specs = this.configFile?.configFileSpecs;
|
|
197
|
+
if (specs === undefined)
|
|
198
|
+
return '';
|
|
199
|
+
return specs.getMatchedFileSpec(fileName, this.currentDirectory, this.useCaseSensitiveFileNames);
|
|
200
|
+
}
|
|
201
|
+
/** The `include` spec matching `fileName`, or `''`; the default spec `**\/*` matches everything. */
|
|
202
|
+
getMatchedIncludeSpec(fileName) {
|
|
203
|
+
const specs = this.configFile?.configFileSpecs;
|
|
204
|
+
if (specs === undefined || specs.validatedIncludeSpecs.length === 0)
|
|
205
|
+
return '';
|
|
206
|
+
if (specs.isDefaultIncludeSpec)
|
|
207
|
+
return specs.validatedIncludeSpecs[0];
|
|
208
|
+
return specs.getMatchedIncludeSpec(fileName, this.currentDirectory, this.useCaseSensitiveFileNames);
|
|
209
|
+
}
|
|
210
|
+
isDefaultIncludeSpec() {
|
|
211
|
+
const specs = this.configFile?.configFileSpecs;
|
|
212
|
+
return specs !== undefined && specs.isDefaultIncludeSpec && specs.validatedIncludeSpecs.length > 0;
|
|
213
|
+
}
|
|
214
|
+
/** The directory outputs are laid out relative to (with a trailing `/`), or `''`. */
|
|
215
|
+
commonSourceDirectory() {
|
|
216
|
+
if (this.commonSourceDirectoryValue === undefined) {
|
|
217
|
+
this.commonSourceDirectoryValue = getCommonSourceDirectory(this.options, () => this.emittedRootFiles(), this.currentDirectory, this.useCaseSensitiveFileNames, (files, root) => this.checkSourceFilesBelongToPath(files, root));
|
|
218
|
+
}
|
|
219
|
+
return this.commonSourceDirectoryValue;
|
|
220
|
+
}
|
|
221
|
+
emittedRootFiles() {
|
|
222
|
+
const files = [];
|
|
223
|
+
for (const file of this.fileNames) {
|
|
224
|
+
if (this.options.noEmitForJsFiles === true && hasJSFileExtension(file))
|
|
225
|
+
continue;
|
|
226
|
+
if (!isDeclarationFileName(file))
|
|
227
|
+
files.push(file);
|
|
228
|
+
}
|
|
229
|
+
return files;
|
|
230
|
+
}
|
|
231
|
+
checkSourceFilesBelongToPath(files, root) {
|
|
232
|
+
for (const file of files) {
|
|
233
|
+
if (containsPath(root, file, this.useCaseSensitiveFileNames, this.currentDirectory))
|
|
234
|
+
continue;
|
|
235
|
+
const absolute = getCanonicalFileName(getNormalizedAbsolutePath(file, this.currentDirectory), this.useCaseSensitiveFileNames);
|
|
236
|
+
this.errors.push(createCompilerDiagnostic(1234 /* Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files */, absolute, root));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** Maps each source of this project to its declaration output and back. */
|
|
240
|
+
sourceToProjectReference() {
|
|
241
|
+
this.parseInputOutputNames();
|
|
242
|
+
return this.sourceToReference ?? new Map();
|
|
243
|
+
}
|
|
244
|
+
outputDtsToProjectReference() {
|
|
245
|
+
this.parseInputOutputNames();
|
|
246
|
+
return this.outputDtsToReference ?? new Map();
|
|
247
|
+
}
|
|
248
|
+
parseInputOutputNames() {
|
|
249
|
+
if (this.sourceToReference !== undefined)
|
|
250
|
+
return;
|
|
251
|
+
const sourceToReference = new Map();
|
|
252
|
+
const outputDtsToReference = new Map();
|
|
253
|
+
for (const fileName of this.fileNames) {
|
|
254
|
+
const outputDts = isDeclarationFileName(fileName) || fileExtensionIs(fileName, '.json')
|
|
255
|
+
? ''
|
|
256
|
+
: getOutputDeclarationFileName(fileName, this.options, this);
|
|
257
|
+
const reference = new SourceOutputAndProjectReference(fileName, outputDts, this);
|
|
258
|
+
if (outputDts !== '') {
|
|
259
|
+
outputDtsToReference.set(toPath(outputDts, this.currentDirectory, this.useCaseSensitiveFileNames), reference);
|
|
260
|
+
}
|
|
261
|
+
sourceToReference.set(toPath(fileName, this.currentDirectory, this.useCaseSensitiveFileNames), reference);
|
|
262
|
+
}
|
|
263
|
+
this.sourceToReference = sourceToReference;
|
|
264
|
+
this.outputDtsToReference = outputDtsToReference;
|
|
265
|
+
}
|
|
266
|
+
/** The `.tsbuildinfo` file of an incremental build, or `''`. */
|
|
267
|
+
buildInfoFileName() {
|
|
268
|
+
return getBuildInfoFileName(this.options, this.currentDirectory, this.useCaseSensitiveFileNames);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** A source file of a referenced project and its declaration output. */
|
|
272
|
+
export class SourceOutputAndProjectReference {
|
|
273
|
+
source;
|
|
274
|
+
outputDts;
|
|
275
|
+
resolved;
|
|
276
|
+
constructor(source,
|
|
277
|
+
/** `''` for declaration and JSON sources. */
|
|
278
|
+
outputDts, resolved) {
|
|
279
|
+
this.source = source;
|
|
280
|
+
this.outputDts = outputDts;
|
|
281
|
+
this.resolved = resolved;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// ---- Root option declarations
|
|
285
|
+
const rootDeclaration = { name: 'undefined', kind: 'object' };
|
|
286
|
+
const compilerOptionsDeclaration = { name: 'compilerOptions', kind: 'object' };
|
|
287
|
+
const typeAcquisitionDeclaration = { name: 'typeAcquisition', kind: 'object' };
|
|
288
|
+
const extendsDeclaration = {
|
|
289
|
+
name: 'extends',
|
|
290
|
+
kind: 'listOrElement',
|
|
291
|
+
element: { name: 'extends', kind: 'string' },
|
|
292
|
+
};
|
|
293
|
+
const rootOptions = new OptionNameMap([
|
|
294
|
+
compilerOptionsDeclaration,
|
|
295
|
+
typeAcquisitionDeclaration,
|
|
296
|
+
extendsDeclaration,
|
|
297
|
+
{ name: 'references', kind: 'list', element: { name: 'references', kind: 'object' } },
|
|
298
|
+
{ name: 'files', kind: 'list', element: { name: 'files', kind: 'string' } },
|
|
299
|
+
{ name: 'include', kind: 'list', element: { name: 'include', kind: 'string' } },
|
|
300
|
+
{ name: 'exclude', kind: 'list', element: { name: 'exclude', kind: 'string' } },
|
|
301
|
+
{ name: 'compileOnSave', kind: 'boolean' },
|
|
302
|
+
]);
|
|
303
|
+
const typeAcquisitionOptions = new OptionNameMap(typeAcquisitionDeclarations);
|
|
304
|
+
/** Declarations of the keys of an object option, if they are checked. */
|
|
305
|
+
function elementOptions(option) {
|
|
306
|
+
if (option === rootDeclaration)
|
|
307
|
+
return rootOptions;
|
|
308
|
+
if (option === compilerOptionsDeclaration)
|
|
309
|
+
return compilerOptionsByName;
|
|
310
|
+
if (option === typeAcquisitionDeclaration)
|
|
311
|
+
return typeAcquisitionOptions;
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
function unknownKeyMessage(parent) {
|
|
315
|
+
if (parent === compilerOptionsDeclaration)
|
|
316
|
+
return 1121 /* Diagnostics.Unknown_compiler_option_0 */;
|
|
317
|
+
if (parent === typeAcquisitionDeclaration)
|
|
318
|
+
return 1813 /* Diagnostics.Unknown_type_acquisition_option_0 */;
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
function unknownKeyDidYouMeanMessage(parent) {
|
|
322
|
+
return parent === compilerOptionsDeclaration
|
|
323
|
+
? 1123 /* Diagnostics.Unknown_compiler_option_0_Did_you_mean_1 */
|
|
324
|
+
: 1821 /* Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1 */;
|
|
325
|
+
}
|
|
326
|
+
function valueTypeName(option) {
|
|
327
|
+
if (option.kind === 'list')
|
|
328
|
+
return 'Array';
|
|
329
|
+
if (option.kind === 'listOrElement')
|
|
330
|
+
return (option.element?.kind ?? 'string') + ' or Array';
|
|
331
|
+
return option.kind;
|
|
332
|
+
}
|
|
333
|
+
// ---- Diagnostics at syntax
|
|
334
|
+
/** A diagnostic at `node` without its leading trivia, or a compiler diagnostic without a node. */
|
|
335
|
+
export function diagnosticAtNode(file, node, message, ...args) {
|
|
336
|
+
if (file === undefined || node === undefined)
|
|
337
|
+
return createCompilerDiagnostic(message, ...args);
|
|
338
|
+
return new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, node.pos), node.end, message, args);
|
|
339
|
+
}
|
|
340
|
+
/** A diagnostic spanning `node` including its leading trivia. */
|
|
341
|
+
function diagnosticAtRange(file, node, message, ...args) {
|
|
342
|
+
return new Diagnostic(file.diagnosticFile(), node.pos, node.end, message, args);
|
|
343
|
+
}
|
|
344
|
+
/** The root object of a config file. */
|
|
345
|
+
export function getTsConfigObjectLiteral(file) {
|
|
346
|
+
if (file === undefined || file.statements.nodes.length === 0)
|
|
347
|
+
return undefined;
|
|
348
|
+
const statement = file.statements.nodes[0];
|
|
349
|
+
if (statement instanceof ExpressionStatement && statement.expression instanceof ObjectLiteralExpression) {
|
|
350
|
+
return statement.expression;
|
|
351
|
+
}
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
/** The first property assignment of `object` named `key` (or `key2`). */
|
|
355
|
+
export function findPropertyAssignment(object, key, key2 = '') {
|
|
356
|
+
if (object === undefined)
|
|
357
|
+
return undefined;
|
|
358
|
+
for (const property of object.properties.nodes) {
|
|
359
|
+
if (!(property instanceof PropertyAssignment))
|
|
360
|
+
continue;
|
|
361
|
+
const name = propertyNameText(property.name);
|
|
362
|
+
// `as`: scriptc loses instanceof narrowing of loop variables.
|
|
363
|
+
if (name !== undefined && (name === key || (key2 !== '' && name === key2)))
|
|
364
|
+
return property;
|
|
365
|
+
}
|
|
366
|
+
return undefined;
|
|
367
|
+
}
|
|
368
|
+
/** The string literal `value` in the array of the root property `key`. */
|
|
369
|
+
export function findTsConfigArrayElement(file, key, value) {
|
|
370
|
+
return findArrayElement(findPropertyAssignment(getTsConfigObjectLiteral(file), key), value);
|
|
371
|
+
}
|
|
372
|
+
/** The string literal `value` in the array initializing `property`. */
|
|
373
|
+
export function findArrayElement(property, value) {
|
|
374
|
+
if (property === undefined || !(property.initializer instanceof ArrayLiteralExpression))
|
|
375
|
+
return undefined;
|
|
376
|
+
for (const element of property.initializer.elements.nodes) {
|
|
377
|
+
if (element instanceof StringLiteral && element.text === value)
|
|
378
|
+
return element;
|
|
379
|
+
}
|
|
380
|
+
return undefined;
|
|
381
|
+
}
|
|
382
|
+
/** The text of a property name, or `undefined` for computed names that aren't literals. */
|
|
383
|
+
export function propertyNameText(name) {
|
|
384
|
+
// Separate tests: scriptc can't access members through a union of classes.
|
|
385
|
+
if (name instanceof Identifier)
|
|
386
|
+
return name.text;
|
|
387
|
+
if (name instanceof StringLiteral)
|
|
388
|
+
return name.text;
|
|
389
|
+
if (name instanceof NumericLiteral)
|
|
390
|
+
return name.text;
|
|
391
|
+
if (name instanceof ComputedPropertyName) {
|
|
392
|
+
const expression = name.expression;
|
|
393
|
+
if (expression instanceof StringLiteral)
|
|
394
|
+
return expression.text;
|
|
395
|
+
if (expression instanceof NumericLiteral)
|
|
396
|
+
return expression.text;
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */ || name.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) {
|
|
400
|
+
return getText(name);
|
|
401
|
+
}
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
// ---- Spec validation
|
|
405
|
+
/** Rejects specs ending in `**` (for `include`) and `..` after a `**`. */
|
|
406
|
+
export function specToDiagnostic(spec, disallowTrailingRecursion) {
|
|
407
|
+
if (disallowTrailingRecursion) {
|
|
408
|
+
const trimmed = spec.endsWith('/') ? spec.slice(0, -1) : spec;
|
|
409
|
+
if (trimmed === '**' || trimmed.endsWith('/**')) {
|
|
410
|
+
return 1118 /* Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 */;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const wildcard = spec.startsWith('**/') ? 0 : spec.indexOf('/**/');
|
|
414
|
+
if (wildcard === -1)
|
|
415
|
+
return undefined;
|
|
416
|
+
const lastDotDot = spec.endsWith('/..') ? spec.length : spec.lastIndexOf('/../');
|
|
417
|
+
return lastDotDot > wildcard
|
|
418
|
+
? 1140 /* Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 */
|
|
419
|
+
: undefined;
|
|
420
|
+
}
|
|
421
|
+
function validateSpecs(specs, disallowTrailingRecursion, file, key, errors) {
|
|
422
|
+
const result = [];
|
|
423
|
+
for (const spec of specs) {
|
|
424
|
+
if (typeof spec !== 'string')
|
|
425
|
+
continue;
|
|
426
|
+
const message = specToDiagnostic(spec, disallowTrailingRecursion);
|
|
427
|
+
if (message === undefined)
|
|
428
|
+
result.push(spec);
|
|
429
|
+
else
|
|
430
|
+
errors.push(diagnosticAtNode(file, findTsConfigArrayElement(file, key, spec), message, spec));
|
|
431
|
+
}
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
// ---- ${configDir}
|
|
435
|
+
const configDirTemplate = '$' + '{configDir}';
|
|
436
|
+
const configDirTemplateLower = configDirTemplate.toLowerCase();
|
|
437
|
+
function startsWithConfigDirTemplate(value) {
|
|
438
|
+
return (value.length >= configDirTemplate.length &&
|
|
439
|
+
value.slice(0, configDirTemplate.length).toLowerCase() === configDirTemplateLower);
|
|
440
|
+
}
|
|
441
|
+
function substituteConfigDir(value, basePath) {
|
|
442
|
+
return getNormalizedAbsolutePath(value.replace(configDirTemplate, './'), basePath);
|
|
443
|
+
}
|
|
444
|
+
/** `list` with `${configDir}` substituted, or `undefined` if no item uses it. */
|
|
445
|
+
function substituteConfigDirInList(list, basePath) {
|
|
446
|
+
if (list === undefined)
|
|
447
|
+
return undefined;
|
|
448
|
+
let result;
|
|
449
|
+
for (let i = 0; i < list.length; i++) {
|
|
450
|
+
if (!startsWithConfigDirTemplate(list[i]))
|
|
451
|
+
continue;
|
|
452
|
+
if (result === undefined)
|
|
453
|
+
result = list.slice();
|
|
454
|
+
result[i] = substituteConfigDir(list[i], basePath);
|
|
455
|
+
}
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
function substituteConfigDirInPath(value, basePath) {
|
|
459
|
+
return value !== undefined && startsWithConfigDirTemplate(value) ? substituteConfigDir(value, basePath) : value;
|
|
460
|
+
}
|
|
461
|
+
function substituteConfigDirInOptions(options, basePath) {
|
|
462
|
+
const paths = options.paths;
|
|
463
|
+
if (paths !== undefined) {
|
|
464
|
+
let substitutedPaths;
|
|
465
|
+
for (const [key, value] of paths) {
|
|
466
|
+
const substituted = substituteConfigDirInList(value, basePath);
|
|
467
|
+
if (substituted === undefined)
|
|
468
|
+
continue;
|
|
469
|
+
if (substitutedPaths === undefined)
|
|
470
|
+
substitutedPaths = new Map(paths);
|
|
471
|
+
substitutedPaths.set(key, substituted);
|
|
472
|
+
}
|
|
473
|
+
if (substitutedPaths !== undefined)
|
|
474
|
+
options.paths = substitutedPaths;
|
|
475
|
+
}
|
|
476
|
+
options.rootDirs = substituteConfigDirInList(options.rootDirs, basePath) ?? options.rootDirs;
|
|
477
|
+
options.typeRoots = substituteConfigDirInList(options.typeRoots, basePath) ?? options.typeRoots;
|
|
478
|
+
options.generateCpuProfile = substituteConfigDirInPath(options.generateCpuProfile, basePath);
|
|
479
|
+
options.generateTrace = substituteConfigDirInPath(options.generateTrace, basePath);
|
|
480
|
+
options.outFile = substituteConfigDirInPath(options.outFile, basePath);
|
|
481
|
+
options.outDir = substituteConfigDirInPath(options.outDir, basePath);
|
|
482
|
+
options.rootDir = substituteConfigDirInPath(options.rootDir, basePath);
|
|
483
|
+
options.tsBuildInfoFile = substituteConfigDirInPath(options.tsBuildInfoFile, basePath);
|
|
484
|
+
options.baseUrl = substituteConfigDirInPath(options.baseUrl, basePath);
|
|
485
|
+
options.declarationDir = substituteConfigDirInPath(options.declarationDir, basePath);
|
|
486
|
+
}
|
|
487
|
+
function nullKeysOfCompilerOptions(raw) {
|
|
488
|
+
if (!(raw instanceof JsonObject))
|
|
489
|
+
return undefined;
|
|
490
|
+
const compilerOptions = raw.entries.get('compilerOptions');
|
|
491
|
+
if (!(compilerOptions instanceof JsonObject))
|
|
492
|
+
return undefined;
|
|
493
|
+
let result;
|
|
494
|
+
for (const [key, value] of compilerOptions.entries) {
|
|
495
|
+
if (value !== null)
|
|
496
|
+
continue;
|
|
497
|
+
if (result === undefined)
|
|
498
|
+
result = new Set();
|
|
499
|
+
result.add(key);
|
|
500
|
+
}
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
/** Names of options given as `null` on the command line. */
|
|
504
|
+
export function nullKeysOfCommandLine(raw) {
|
|
505
|
+
if (raw === undefined)
|
|
506
|
+
return undefined;
|
|
507
|
+
let result;
|
|
508
|
+
for (const [key, value] of raw) {
|
|
509
|
+
if (value !== null)
|
|
510
|
+
continue;
|
|
511
|
+
if (result === undefined)
|
|
512
|
+
result = new Set();
|
|
513
|
+
result.add(key);
|
|
514
|
+
}
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
// ---- File names
|
|
518
|
+
function hasFileWithHigherPriorityExtension(file, extensions, literalFiles, wildcardFiles, useCaseSensitiveFileNames) {
|
|
519
|
+
const group = extensionGroupOf(file, extensions);
|
|
520
|
+
for (const extension of group) {
|
|
521
|
+
// `a.d.ts` also ends in `.ts`; it only yields to `a.ts` and `a.tsx` by the order below.
|
|
522
|
+
if (fileExtensionIs(file, extension) && (extension !== '.ts' || !fileExtensionIs(file, '.d.ts')))
|
|
523
|
+
return false;
|
|
524
|
+
const key = getCanonicalFileName(changeExtension(file, extension), useCaseSensitiveFileNames);
|
|
525
|
+
if (literalFiles.has(key) || wildcardFiles.has(key)) {
|
|
526
|
+
// Declarations next to JavaScript are kept, as in TypeScript.
|
|
527
|
+
if (extension === '.d.ts' && (fileExtensionIs(file, '.js') || fileExtensionIs(file, '.jsx')))
|
|
528
|
+
continue;
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, useCaseSensitiveFileNames) {
|
|
535
|
+
const group = extensionGroupOf(file, extensions);
|
|
536
|
+
for (let i = group.length - 1; i >= 0; i--) {
|
|
537
|
+
const extension = group[i];
|
|
538
|
+
if (fileExtensionIs(file, extension))
|
|
539
|
+
return;
|
|
540
|
+
wildcardFiles.delete(getCanonicalFileName(changeExtension(file, extension), useCaseSensitiveFileNames));
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/** The extensions of every group containing the extension of `file`. */
|
|
544
|
+
function extensionGroupOf(file, extensions) {
|
|
545
|
+
const result = [];
|
|
546
|
+
for (const group of extensions) {
|
|
547
|
+
if (fileExtensionIsOneOf(file, group))
|
|
548
|
+
for (const extension of group)
|
|
549
|
+
result.push(extension);
|
|
550
|
+
}
|
|
551
|
+
return result;
|
|
552
|
+
}
|
|
553
|
+
/** A root list of the raw config: its items, and whether it was given as an array. */
|
|
554
|
+
class RawList {
|
|
555
|
+
items;
|
|
556
|
+
isArray;
|
|
557
|
+
constructor(
|
|
558
|
+
/** `undefined` for a missing or non-array value, or an array whose items were all dropped. */
|
|
559
|
+
items, isArray) {
|
|
560
|
+
this.items = items;
|
|
561
|
+
this.isArray = isArray;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function rawList(raw, key) {
|
|
565
|
+
if (raw instanceof JsonObject) {
|
|
566
|
+
const value = raw.entries.get(key);
|
|
567
|
+
if (value instanceof JsonArray)
|
|
568
|
+
return new RawList(value.dropped ? undefined : value.items, true);
|
|
569
|
+
}
|
|
570
|
+
return new RawList(undefined, false);
|
|
571
|
+
}
|
|
572
|
+
/** tsgo's JSON encoding of a list, where missing arrays are `[]`. */
|
|
573
|
+
function jsonList(items) {
|
|
574
|
+
if (items === undefined)
|
|
575
|
+
return '[]';
|
|
576
|
+
const parts = [];
|
|
577
|
+
for (const item of items)
|
|
578
|
+
parts.push(jsonText(item));
|
|
579
|
+
return '[' + parts.join(',') + ']';
|
|
580
|
+
}
|
|
581
|
+
function jsonText(value) {
|
|
582
|
+
if (value === null)
|
|
583
|
+
return 'null';
|
|
584
|
+
if (typeof value === 'string')
|
|
585
|
+
return JSON.stringify(value);
|
|
586
|
+
if (typeof value === 'boolean')
|
|
587
|
+
return value ? 'true' : 'false';
|
|
588
|
+
if (typeof value === 'number')
|
|
589
|
+
return String(value);
|
|
590
|
+
if (value instanceof JsonArray)
|
|
591
|
+
return jsonList(value.dropped ? undefined : value.items);
|
|
592
|
+
const parts = [];
|
|
593
|
+
for (const [key, item] of value.entries)
|
|
594
|
+
parts.push(jsonText(key) + ':' + jsonText(item));
|
|
595
|
+
return '{' + parts.join(',') + '}';
|
|
596
|
+
}
|
|
597
|
+
// ---- Parsing
|
|
598
|
+
/** A module resolution host reading a file system, for `extends` of packages. */
|
|
599
|
+
class FileSystemResolutionHost extends ModuleResolutionHost {
|
|
600
|
+
fs;
|
|
601
|
+
currentDirectory;
|
|
602
|
+
constructor(fs, currentDirectory) {
|
|
603
|
+
super();
|
|
604
|
+
this.fs = fs;
|
|
605
|
+
this.currentDirectory = currentDirectory;
|
|
606
|
+
}
|
|
607
|
+
useCaseSensitiveFileNames() {
|
|
608
|
+
return this.fs.useCaseSensitiveFileNames;
|
|
609
|
+
}
|
|
610
|
+
getCurrentDirectory() {
|
|
611
|
+
return this.currentDirectory;
|
|
612
|
+
}
|
|
613
|
+
fileExists(path) {
|
|
614
|
+
return this.fs.fileExists(path);
|
|
615
|
+
}
|
|
616
|
+
directoryExists(path) {
|
|
617
|
+
return this.fs.directoryExists(path);
|
|
618
|
+
}
|
|
619
|
+
readFile(path) {
|
|
620
|
+
return this.fs.readFile(path);
|
|
621
|
+
}
|
|
622
|
+
realpath(path) {
|
|
623
|
+
return this.fs.realpath(path);
|
|
624
|
+
}
|
|
625
|
+
getDirectories(path) {
|
|
626
|
+
return this.fs.getAccessibleEntries(path).directories;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/** One config file's own settings, before applying the configs it extends. */
|
|
630
|
+
class OwnConfig {
|
|
631
|
+
raw;
|
|
632
|
+
options;
|
|
633
|
+
typeAcquisition;
|
|
634
|
+
extendedConfigPaths;
|
|
635
|
+
constructor(
|
|
636
|
+
/** `null` for a config in an `extends` cycle. */
|
|
637
|
+
raw,
|
|
638
|
+
/** `undefined` for a config in an `extends` cycle. */
|
|
639
|
+
options, typeAcquisition,
|
|
640
|
+
/** Resolved `extends` paths; `undefined` without `extends`. */
|
|
641
|
+
extendedConfigPaths) {
|
|
642
|
+
this.raw = raw;
|
|
643
|
+
this.options = options;
|
|
644
|
+
this.typeAcquisition = typeAcquisition;
|
|
645
|
+
this.extendedConfigPaths = extendedConfigPaths;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/** A parsed extended config, shared by every config that extends it. */
|
|
649
|
+
class ExtendedConfig {
|
|
650
|
+
file;
|
|
651
|
+
config;
|
|
652
|
+
errors;
|
|
653
|
+
constructor(file, config, errors) {
|
|
654
|
+
this.file = file;
|
|
655
|
+
this.config = config;
|
|
656
|
+
this.errors = errors;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
/** What the configs extended by one config contribute to it. */
|
|
660
|
+
class ExtendsResult {
|
|
661
|
+
options = {};
|
|
662
|
+
include = undefined;
|
|
663
|
+
exclude = undefined;
|
|
664
|
+
files = undefined;
|
|
665
|
+
compileOnSave = false;
|
|
666
|
+
extendedSourceFiles = new Set();
|
|
667
|
+
}
|
|
668
|
+
/** Converts a config file's syntax tree into JSON, applying options as they are found. */
|
|
669
|
+
class ConfigFileConverter {
|
|
670
|
+
parser;
|
|
671
|
+
file;
|
|
672
|
+
basePath;
|
|
673
|
+
configFileName;
|
|
674
|
+
errors;
|
|
675
|
+
options;
|
|
676
|
+
typeAcquisition = {};
|
|
677
|
+
extendedConfigPaths = undefined;
|
|
678
|
+
constructor(parser, file, basePath, configFileName, errors) {
|
|
679
|
+
this.parser = parser;
|
|
680
|
+
this.file = file;
|
|
681
|
+
this.basePath = basePath;
|
|
682
|
+
this.configFileName = configFileName;
|
|
683
|
+
this.errors = errors;
|
|
684
|
+
this.options = {};
|
|
685
|
+
if (configFileName !== '' && getBaseFileName(configFileName) === 'jsconfig.json') {
|
|
686
|
+
this.options.allowJs = true;
|
|
687
|
+
this.options.maxNodeModuleJsDepth = 2;
|
|
688
|
+
this.options.skipLibCheck = true;
|
|
689
|
+
this.options.noEmit = true;
|
|
690
|
+
this.typeAcquisition.enable = true;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
/** The root value, which must be an object; recovers the first object of an array. */
|
|
694
|
+
convertRoot() {
|
|
695
|
+
const statements = this.file.statements.nodes;
|
|
696
|
+
const statement = statements.length > 0 ? statements[0] : undefined;
|
|
697
|
+
const root = statement instanceof ExpressionStatement ? statement.expression : undefined;
|
|
698
|
+
if (root === undefined)
|
|
699
|
+
return new JsonObject();
|
|
700
|
+
if (!(root instanceof ObjectLiteralExpression)) {
|
|
701
|
+
// Error recovery may wrap the object in an array: use its first object, without reporting the root.
|
|
702
|
+
if (root instanceof ArrayLiteralExpression) {
|
|
703
|
+
for (const element of root.elements.nodes) {
|
|
704
|
+
if (element instanceof ObjectLiteralExpression) {
|
|
705
|
+
return this.convertObject(element, rootDeclaration);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
const name = getBaseFileName(this.file.fileName) === 'jsconfig.json' ? 'jsconfig.json' : 'tsconfig.json';
|
|
710
|
+
this.errors.push(createCompilerDiagnostic(1166 /* Diagnostics.The_root_value_of_a_0_file_must_be_an_object */, name));
|
|
711
|
+
return new JsonObject();
|
|
712
|
+
}
|
|
713
|
+
return this.convertObject(root, rootDeclaration);
|
|
714
|
+
}
|
|
715
|
+
convertValue(expression, option) {
|
|
716
|
+
switch (expression.kind) {
|
|
717
|
+
case 111 /* SyntaxKind.TrueKeyword */:
|
|
718
|
+
return true;
|
|
719
|
+
case 96 /* SyntaxKind.FalseKeyword */:
|
|
720
|
+
return false;
|
|
721
|
+
case 105 /* SyntaxKind.NullKeyword */:
|
|
722
|
+
return null;
|
|
723
|
+
case 10 /* SyntaxKind.StringLiteral */:
|
|
724
|
+
if (expression instanceof StringLiteral)
|
|
725
|
+
return expression.text;
|
|
726
|
+
break;
|
|
727
|
+
case 8 /* SyntaxKind.NumericLiteral */:
|
|
728
|
+
if (expression instanceof NumericLiteral)
|
|
729
|
+
return Number(expression.text);
|
|
730
|
+
break;
|
|
731
|
+
case 225 /* SyntaxKind.PrefixUnaryExpression */:
|
|
732
|
+
if (expression instanceof PrefixUnaryExpression &&
|
|
733
|
+
expression.operator === 40 /* SyntaxKind.MinusToken */ &&
|
|
734
|
+
expression.operand instanceof NumericLiteral) {
|
|
735
|
+
return -Number(expression.operand.text);
|
|
736
|
+
}
|
|
737
|
+
break;
|
|
738
|
+
case 211 /* SyntaxKind.ObjectLiteralExpression */:
|
|
739
|
+
if (expression instanceof ObjectLiteralExpression)
|
|
740
|
+
return this.convertObject(expression, option);
|
|
741
|
+
break;
|
|
742
|
+
case 210 /* SyntaxKind.ArrayLiteralExpression */:
|
|
743
|
+
if (expression instanceof ArrayLiteralExpression)
|
|
744
|
+
return this.convertArray(expression, option);
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
this.errors.push(option !== undefined
|
|
748
|
+
? diagnosticAtRange(this.file, expression, 1122 /* Diagnostics.Compiler_option_0_requires_a_value_of_type_1 */, option.name, valueTypeName(option))
|
|
749
|
+
: diagnosticAtRange(this.file, expression, 264 /* Diagnostics.Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal */));
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
convertArray(node, option) {
|
|
753
|
+
const elements = node.elements.nodes;
|
|
754
|
+
const items = [];
|
|
755
|
+
for (const element of elements) {
|
|
756
|
+
const value = this.convertValue(element, option);
|
|
757
|
+
if (value !== null)
|
|
758
|
+
items.push(value);
|
|
759
|
+
}
|
|
760
|
+
return new JsonArray(items, elements.length > 0 && items.length === 0);
|
|
761
|
+
}
|
|
762
|
+
convertObject(node, objectOption) {
|
|
763
|
+
const result = new JsonObject();
|
|
764
|
+
const known = objectOption === undefined ? undefined : elementOptions(objectOption);
|
|
765
|
+
for (const element of node.properties.nodes) {
|
|
766
|
+
if (!(element instanceof PropertyAssignment)) {
|
|
767
|
+
this.errors.push(diagnosticAtRange(this.file, element, 102 /* Diagnostics.Property_assignment_expected */));
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
const postfix = element.postfixToken;
|
|
771
|
+
if (postfix !== undefined && postfix.kind === 57 /* SyntaxKind.QuestionToken */) {
|
|
772
|
+
this.errors.push(diagnosticAtRange(this.file, postfix, 1741 /* Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files */, '?'));
|
|
773
|
+
}
|
|
774
|
+
const key = propertyNameText(element.name) ?? '';
|
|
775
|
+
let option = key !== '' && known !== undefined ? known.get(key) : undefined;
|
|
776
|
+
if (option !== undefined && option.name !== key)
|
|
777
|
+
option = undefined;
|
|
778
|
+
const value = this.convertValue(element.initializer, option);
|
|
779
|
+
if (key !== '') {
|
|
780
|
+
result.entries.set(key, value);
|
|
781
|
+
this.onPropertySet(key, value, element, objectOption, option);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return result;
|
|
785
|
+
}
|
|
786
|
+
onPropertySet(key, value, property, parent, option) {
|
|
787
|
+
if (option !== undefined && option !== extendsDeclaration) {
|
|
788
|
+
value = this.parser.convertOption(option, value, this.basePath, property, property.initializer, this.file, this.errors);
|
|
789
|
+
}
|
|
790
|
+
if (parent !== undefined && parent !== rootDeclaration && value !== null) {
|
|
791
|
+
if (option !== undefined) {
|
|
792
|
+
if (parent === compilerOptionsDeclaration)
|
|
793
|
+
setCompilerOptionFromJson(this.options, option, value);
|
|
794
|
+
else if (parent === typeAcquisitionDeclaration)
|
|
795
|
+
setTypeAcquisitionFromJson(this.typeAcquisition, option, value);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const unknownMessage = unknownKeyMessage(parent);
|
|
799
|
+
if (unknownMessage === undefined)
|
|
800
|
+
return;
|
|
801
|
+
const possible = elementOptions(parent)?.get(key);
|
|
802
|
+
if (possible !== undefined && possible.name !== key) {
|
|
803
|
+
this.errors.push(diagnosticAtNode(this.file, property.name, unknownKeyDidYouMeanMessage(parent), key, possible.name));
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
this.errors.push(diagnosticAtNode(this.file, property.name, unknownMessage, key));
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
else if (parent === rootDeclaration) {
|
|
810
|
+
if (option === extendsDeclaration) {
|
|
811
|
+
this.extendedConfigPaths = this.parser.getExtendsConfigPaths(value, this.basePath, this.configFileName, property, property.initializer, this.file, this.errors);
|
|
812
|
+
}
|
|
813
|
+
else if (option === undefined && key === 'excludes') {
|
|
814
|
+
this.errors.push(diagnosticAtNode(this.file, property.name, 1282 /* Diagnostics.Unknown_option_excludes_Did_you_mean_exclude */));
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function setCompilerOptionFromJson(options, option, value) {
|
|
820
|
+
if (option.name === 'paths') {
|
|
821
|
+
if (!(value instanceof JsonObject))
|
|
822
|
+
return;
|
|
823
|
+
const paths = new Map();
|
|
824
|
+
for (const [key, substitutions] of value.entries)
|
|
825
|
+
paths.set(key, stringItems(substitutions));
|
|
826
|
+
options.paths = paths;
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
setCompilerOption(options, option.name, toOptionValue(option, value));
|
|
830
|
+
}
|
|
831
|
+
function setTypeAcquisitionFromJson(options, option, value) {
|
|
832
|
+
setTypeAcquisitionOption(options, option.name, toOptionValue(option, value));
|
|
833
|
+
}
|
|
834
|
+
function toOptionValue(option, value) {
|
|
835
|
+
if (value instanceof JsonArray)
|
|
836
|
+
return stringItems(value) ?? null;
|
|
837
|
+
if (value instanceof JsonObject)
|
|
838
|
+
return null;
|
|
839
|
+
if (typeof value === 'number' && option.kind === 'number')
|
|
840
|
+
return Math.trunc(value);
|
|
841
|
+
return value;
|
|
842
|
+
}
|
|
843
|
+
/** Reads config files with a file system, sharing parsed `extends` targets. */
|
|
844
|
+
export class ConfigParser {
|
|
845
|
+
fs;
|
|
846
|
+
currentDirectory;
|
|
847
|
+
extendedConfigs = new Map();
|
|
848
|
+
resolutionHost;
|
|
849
|
+
/**
|
|
850
|
+
* Whether parsed configs list their root files. Parse threads (parallel-parse.ts), which get the
|
|
851
|
+
* files to load from the main thread, read the config without matching `include` patterns.
|
|
852
|
+
*/
|
|
853
|
+
expandFileNames = true;
|
|
854
|
+
/**
|
|
855
|
+
* Called once, with the options of the config, before its `include` patterns are matched; what it
|
|
856
|
+
* returns is called with each root file name as it is found: literal `files` first, then the matched
|
|
857
|
+
* files a directory at a time, without those that a file of the same name with a higher priority
|
|
858
|
+
* extension leaves out.
|
|
859
|
+
*/
|
|
860
|
+
beforeRootFiles = undefined;
|
|
861
|
+
constructor(fs, currentDirectory) {
|
|
862
|
+
this.fs = fs;
|
|
863
|
+
this.currentDirectory = currentDirectory;
|
|
864
|
+
this.resolutionHost = new FileSystemResolutionHost(fs, currentDirectory);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Reads `configFileName` and applies command-line `options` (`raw` as given, for `null` resets) over it.
|
|
868
|
+
* Returns `undefined`, with `errors`, if the file can't be read.
|
|
869
|
+
*/
|
|
870
|
+
parseConfigFile(configFileName, options, raw, errors) {
|
|
871
|
+
const fileName = getNormalizedAbsolutePath(configFileName, this.currentDirectory);
|
|
872
|
+
const text = this.fs.readFile(fileName);
|
|
873
|
+
if (text === undefined) {
|
|
874
|
+
errors.push(createCompilerDiagnostic(1158 /* Diagnostics.Cannot_read_file_0 */, fileName));
|
|
875
|
+
return undefined;
|
|
876
|
+
}
|
|
877
|
+
const path = toPath(fileName, this.currentDirectory, this.fs.useCaseSensitiveFileNames);
|
|
878
|
+
const file = new TsConfigSourceFile(parseConfigText(fileName, path, text));
|
|
879
|
+
return this.parseConfigFileContent(file, getDirectoryPath(fileName), options, raw, fileName);
|
|
880
|
+
}
|
|
881
|
+
/** Converts a parsed config file into options and root files. */
|
|
882
|
+
parseConfigFileContent(file, basePath, existingOptions, existingRaw, configFileName) {
|
|
883
|
+
const cs = this.fs.useCaseSensitiveFileNames;
|
|
884
|
+
const basePathForFileNames = normalizePath(configFileName !== '' ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, basePath)) : basePath);
|
|
885
|
+
const errors = [];
|
|
886
|
+
const parsed = this.parseConfig(file, basePath, configFileName, [], errors);
|
|
887
|
+
const options = parsed.options ?? {};
|
|
888
|
+
if (existingOptions !== undefined)
|
|
889
|
+
mergeCompilerOptions(options, existingOptions, nullKeysOfCommandLine(existingRaw));
|
|
890
|
+
substituteConfigDirInOptions(options, basePathForFileNames);
|
|
891
|
+
if (configFileName !== '')
|
|
892
|
+
options.configFilePath = normalizeSlashes(configFileName);
|
|
893
|
+
const raw = parsed.raw;
|
|
894
|
+
const references = rawList(raw, 'references');
|
|
895
|
+
const files = rawList(raw, 'files');
|
|
896
|
+
if (files.isArray) {
|
|
897
|
+
const referenceCount = references.items === undefined ? 0 : references.items.length;
|
|
898
|
+
const extendsValue = raw instanceof JsonObject ? (raw.entries.get('extends') ?? null) : null;
|
|
899
|
+
if (files.items !== undefined && files.items.length === 0 && referenceCount === 0 && extendsValue === null) {
|
|
900
|
+
const filesProperty = findPropertyAssignment(getTsConfigObjectLiteral(file.sourceFile), 'files');
|
|
901
|
+
errors.push(diagnosticAtNode(file.sourceFile, filesProperty?.initializer, 1826 /* Diagnostics.The_files_list_in_config_file_0_is_empty */, configFileName !== '' ? configFileName : 'tsconfig.json'));
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
let include = rawList(raw, 'include');
|
|
905
|
+
let exclude = rawList(raw, 'exclude');
|
|
906
|
+
let isDefaultIncludeSpec = false;
|
|
907
|
+
if (!exclude.isArray && (options.outDir !== undefined || options.declarationDir !== undefined)) {
|
|
908
|
+
const defaults = [];
|
|
909
|
+
if (options.outDir !== undefined)
|
|
910
|
+
defaults.push(options.outDir);
|
|
911
|
+
if (options.declarationDir !== undefined)
|
|
912
|
+
defaults.push(options.declarationDir);
|
|
913
|
+
exclude = new RawList(defaults, true);
|
|
914
|
+
}
|
|
915
|
+
if (files.items === undefined && include.items === undefined) {
|
|
916
|
+
include = new RawList(['**/*'], true);
|
|
917
|
+
isDefaultIncludeSpec = true;
|
|
918
|
+
}
|
|
919
|
+
let validatedIncludeBeforeSubstitution = [];
|
|
920
|
+
let validatedInclude = [];
|
|
921
|
+
if (include.items !== undefined) {
|
|
922
|
+
validatedIncludeBeforeSubstitution = validateSpecs(include.items, true, file.sourceFile, 'include', errors);
|
|
923
|
+
validatedInclude =
|
|
924
|
+
substituteConfigDirInList(validatedIncludeBeforeSubstitution, basePathForFileNames) ??
|
|
925
|
+
validatedIncludeBeforeSubstitution;
|
|
926
|
+
}
|
|
927
|
+
let validatedExclude = [];
|
|
928
|
+
if (exclude.items !== undefined) {
|
|
929
|
+
validatedExclude = validateSpecs(exclude.items, false, file.sourceFile, 'exclude', errors);
|
|
930
|
+
validatedExclude = substituteConfigDirInList(validatedExclude, basePathForFileNames) ?? validatedExclude;
|
|
931
|
+
}
|
|
932
|
+
let validatedFilesBeforeSubstitution = [];
|
|
933
|
+
let validatedFiles = [];
|
|
934
|
+
if (files.items !== undefined) {
|
|
935
|
+
for (const spec of files.items)
|
|
936
|
+
if (typeof spec === 'string')
|
|
937
|
+
validatedFilesBeforeSubstitution.push(spec);
|
|
938
|
+
validatedFiles =
|
|
939
|
+
substituteConfigDirInList(validatedFilesBeforeSubstitution, basePathForFileNames) ??
|
|
940
|
+
validatedFilesBeforeSubstitution;
|
|
941
|
+
}
|
|
942
|
+
const specs = new ConfigFileSpecs(validatedFiles, validatedInclude, validatedExclude, validatedFilesBeforeSubstitution, validatedIncludeBeforeSubstitution, isDefaultIncludeSpec);
|
|
943
|
+
file.configFileSpecs = specs;
|
|
944
|
+
const literalFiles = new Map();
|
|
945
|
+
const beforeRootFiles = this.beforeRootFiles;
|
|
946
|
+
this.beforeRootFiles = undefined;
|
|
947
|
+
const fileNames = this.expandFileNames
|
|
948
|
+
? this.getFileNamesFromConfigSpecs(specs, basePathForFileNames, options, literalFiles, beforeRootFiles === undefined ? undefined : beforeRootFiles(options))
|
|
949
|
+
: [];
|
|
950
|
+
const canReportNoInputFiles = !(raw instanceof JsonObject) || (!raw.entries.has('files') && !raw.entries.has('references'));
|
|
951
|
+
if (this.expandFileNames && fileNames.length === 0 && canReportNoInputFiles) {
|
|
952
|
+
errors.push(createCompilerDiagnostic(1827 /* Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2 */, configFileName, jsonList(include.items), jsonList(exclude.items)));
|
|
953
|
+
}
|
|
954
|
+
const projectReferences = [];
|
|
955
|
+
if (references.items !== undefined) {
|
|
956
|
+
for (const reference of references.items) {
|
|
957
|
+
if (!(reference instanceof JsonObject))
|
|
958
|
+
continue;
|
|
959
|
+
const path = reference.entries.get('path');
|
|
960
|
+
const circular = reference.entries.get('circular');
|
|
961
|
+
if (typeof path !== 'string' || path === '')
|
|
962
|
+
continue;
|
|
963
|
+
projectReferences.push(new ProjectReference(getNormalizedAbsolutePath(path, basePathForFileNames), path, circular === true));
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return new ParsedCommandLine(options, parsed.typeAcquisition, fileNames, projectReferences, file, errors, basePathForFileNames, cs, literalFiles.size);
|
|
967
|
+
}
|
|
968
|
+
/** A config file's options with what it extends applied. */
|
|
969
|
+
parseConfig(file, basePath, configFileName, resolutionStack, errors) {
|
|
970
|
+
basePath = normalizeSlashes(basePath);
|
|
971
|
+
const resolvedPath = toPath(configFileName, basePath, this.fs.useCaseSensitiveFileNames);
|
|
972
|
+
if (resolutionStack.includes(resolvedPath)) {
|
|
973
|
+
errors.push(createCompilerDiagnostic(1825 /* Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0 */));
|
|
974
|
+
return new OwnConfig(null, undefined, undefined, undefined);
|
|
975
|
+
}
|
|
976
|
+
const converter = new ConfigFileConverter(this, file.sourceFile, basePath, configFileName, errors);
|
|
977
|
+
const raw = converter.convertRoot();
|
|
978
|
+
const own = new OwnConfig(raw, converter.options, converter.typeAcquisition, converter.extendedConfigPaths);
|
|
979
|
+
const ownOptions = converter.options;
|
|
980
|
+
// `paths` may be inherited, so remember which directory it is relative to.
|
|
981
|
+
if (ownOptions.paths !== undefined)
|
|
982
|
+
ownOptions.pathsBasePath = basePath;
|
|
983
|
+
const extendedPaths = own.extendedConfigPaths;
|
|
984
|
+
if (extendedPaths === undefined)
|
|
985
|
+
return own;
|
|
986
|
+
const stack = [...resolutionStack, resolvedPath];
|
|
987
|
+
const result = new ExtendsResult();
|
|
988
|
+
for (const extendedPath of extendedPaths)
|
|
989
|
+
this.applyExtendedConfig(raw, basePath, extendedPath, stack, result, errors);
|
|
990
|
+
if (raw instanceof JsonObject) {
|
|
991
|
+
if (result.include !== undefined)
|
|
992
|
+
raw.entries.set('include', result.include);
|
|
993
|
+
if (result.exclude !== undefined)
|
|
994
|
+
raw.entries.set('exclude', result.exclude);
|
|
995
|
+
if (result.files !== undefined)
|
|
996
|
+
raw.entries.set('files', result.files);
|
|
997
|
+
if (result.compileOnSave && !raw.entries.has('compileOnSave'))
|
|
998
|
+
raw.entries.set('compileOnSave', true);
|
|
999
|
+
}
|
|
1000
|
+
const extendedSourceFiles = new Set(file.extendedSourceFiles);
|
|
1001
|
+
for (const name of result.extendedSourceFiles)
|
|
1002
|
+
extendedSourceFiles.add(name);
|
|
1003
|
+
file.extendedSourceFiles = [...extendedSourceFiles].sort(compareCodePoints);
|
|
1004
|
+
own.options = mergeCompilerOptions(result.options, ownOptions, nullKeysOfCompilerOptions(raw));
|
|
1005
|
+
return own;
|
|
1006
|
+
}
|
|
1007
|
+
applyExtendedConfig(ownRaw, basePath, extendedConfigPath, stack, result, errors) {
|
|
1008
|
+
const extended = this.getExtendedConfig(extendedConfigPath, stack);
|
|
1009
|
+
for (const error of extended.errors)
|
|
1010
|
+
errors.push(error);
|
|
1011
|
+
result.extendedSourceFiles.add(extended.file.sourceFile.fileName);
|
|
1012
|
+
for (const name of extended.file.extendedSourceFiles)
|
|
1013
|
+
result.extendedSourceFiles.add(name);
|
|
1014
|
+
const config = extended.config;
|
|
1015
|
+
if (config === undefined || config.options === undefined)
|
|
1016
|
+
return;
|
|
1017
|
+
const extendsRaw = config.raw;
|
|
1018
|
+
let relativeDifference;
|
|
1019
|
+
const ownObject = ownRaw instanceof JsonObject ? ownRaw : undefined;
|
|
1020
|
+
for (const key of ['include', 'exclude', 'files']) {
|
|
1021
|
+
if (ownObject !== undefined && ownObject.entries.has(key))
|
|
1022
|
+
continue;
|
|
1023
|
+
if (!(extendsRaw instanceof JsonObject))
|
|
1024
|
+
continue;
|
|
1025
|
+
const value = extendsRaw.entries.get(key);
|
|
1026
|
+
if (!(value instanceof JsonArray) || value.dropped)
|
|
1027
|
+
continue;
|
|
1028
|
+
const items = [];
|
|
1029
|
+
for (const item of value.items) {
|
|
1030
|
+
if (typeof item !== 'string' || startsWithConfigDirTemplate(item) || isRootedDiskPath(item)) {
|
|
1031
|
+
items.push(item);
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
if (relativeDifference === undefined) {
|
|
1035
|
+
relativeDifference = convertToRelativePath(getDirectoryPath(extendedConfigPath), basePath, this.fs.useCaseSensitiveFileNames);
|
|
1036
|
+
}
|
|
1037
|
+
items.push(combinePaths(relativeDifference, item));
|
|
1038
|
+
}
|
|
1039
|
+
const array = new JsonArray(items);
|
|
1040
|
+
if (key === 'include')
|
|
1041
|
+
result.include = array;
|
|
1042
|
+
else if (key === 'exclude')
|
|
1043
|
+
result.exclude = array;
|
|
1044
|
+
else
|
|
1045
|
+
result.files = array;
|
|
1046
|
+
}
|
|
1047
|
+
if (extendsRaw instanceof JsonObject) {
|
|
1048
|
+
const compileOnSave = extendsRaw.entries.get('compileOnSave');
|
|
1049
|
+
if (typeof compileOnSave === 'boolean')
|
|
1050
|
+
result.compileOnSave = compileOnSave;
|
|
1051
|
+
}
|
|
1052
|
+
mergeCompilerOptions(result.options, config.options, nullKeysOfCompilerOptions(extendsRaw));
|
|
1053
|
+
}
|
|
1054
|
+
/** A parsed extended config; cached unless it is part of an `extends` cycle. */
|
|
1055
|
+
getExtendedConfig(fileName, stack) {
|
|
1056
|
+
const path = toPath(fileName, this.currentDirectory, this.fs.useCaseSensitiveFileNames);
|
|
1057
|
+
if (stack.includes(path))
|
|
1058
|
+
return this.parseExtendedConfig(fileName, path, stack);
|
|
1059
|
+
let extended = this.extendedConfigs.get(path);
|
|
1060
|
+
if (extended === undefined) {
|
|
1061
|
+
extended = this.parseExtendedConfig(fileName, path, stack);
|
|
1062
|
+
this.extendedConfigs.set(path, extended);
|
|
1063
|
+
}
|
|
1064
|
+
return extended;
|
|
1065
|
+
}
|
|
1066
|
+
parseExtendedConfig(fileName, path, stack) {
|
|
1067
|
+
const text = this.fs.readFile(fileName);
|
|
1068
|
+
if (text === undefined) {
|
|
1069
|
+
const error = createCompilerDiagnostic(1158 /* Diagnostics.Cannot_read_file_0 */, fileName);
|
|
1070
|
+
const file = new TsConfigSourceFile(parseConfigText(fileName, path, ''));
|
|
1071
|
+
file.sourceFile.diagnostics = [error];
|
|
1072
|
+
return new ExtendedConfig(file, undefined, [error]);
|
|
1073
|
+
}
|
|
1074
|
+
const file = new TsConfigSourceFile(parseConfigText(fileName, path, text));
|
|
1075
|
+
if (file.sourceFile.diagnostics.length > 0)
|
|
1076
|
+
return new ExtendedConfig(file, undefined, file.sourceFile.diagnostics);
|
|
1077
|
+
const errors = [];
|
|
1078
|
+
const config = this.parseConfig(file, getDirectoryPath(fileName), getBaseFileName(fileName), stack, errors);
|
|
1079
|
+
return new ExtendedConfig(file, config, errors);
|
|
1080
|
+
}
|
|
1081
|
+
/** Converts a value of `option`, reporting invalid values at `valueExpression`. */
|
|
1082
|
+
convertOption(option, value, basePath, property, valueExpression, file, errors) {
|
|
1083
|
+
if (option.isCommandLineOnly === true) {
|
|
1084
|
+
errors.push(diagnosticAtNode(file, property?.name, 1418 /* Diagnostics.Option_0_can_only_be_specified_on_command_line */, option.name));
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
if (!isOptionValue(option, value)) {
|
|
1088
|
+
errors.push(diagnosticAtNode(file, valueExpression, 1122 /* Diagnostics.Compiler_option_0_requires_a_value_of_type_1 */, option.name, valueTypeName(option)));
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
const element = option.element;
|
|
1092
|
+
if (option.kind === 'list' || (option.kind === 'listOrElement' && value instanceof JsonArray)) {
|
|
1093
|
+
return element === undefined
|
|
1094
|
+
? null
|
|
1095
|
+
: this.convertListOption(option, element, value, basePath, property, valueExpression, file, errors);
|
|
1096
|
+
}
|
|
1097
|
+
if (option.kind === 'listOrElement') {
|
|
1098
|
+
return element === undefined
|
|
1099
|
+
? null
|
|
1100
|
+
: this.convertOption(element, value, basePath, property, valueExpression, file, errors);
|
|
1101
|
+
}
|
|
1102
|
+
if (option.kind === 'enum') {
|
|
1103
|
+
return typeof value === 'string' ? convertEnumOption(option, value, valueExpression, file, errors) : null;
|
|
1104
|
+
}
|
|
1105
|
+
const validated = validateOptionValue(option, value, valueExpression, file, errors);
|
|
1106
|
+
if (validated === null || option.isFilePath !== true || typeof validated !== 'string')
|
|
1107
|
+
return validated;
|
|
1108
|
+
let path = normalizeSlashes(validated);
|
|
1109
|
+
if (!startsWithConfigDirTemplate(path))
|
|
1110
|
+
path = getNormalizedAbsolutePath(path, basePath);
|
|
1111
|
+
return path === '' ? '.' : path;
|
|
1112
|
+
}
|
|
1113
|
+
convertListOption(option, element, values, basePath, property, valueExpression, file, errors) {
|
|
1114
|
+
if (!(values instanceof JsonArray) || values.dropped)
|
|
1115
|
+
return null;
|
|
1116
|
+
// Items are matched to elements by index, though `null` items were dropped (as in tsgo).
|
|
1117
|
+
const elements = valueExpression instanceof ArrayLiteralExpression ? valueExpression.elements.nodes : undefined;
|
|
1118
|
+
const items = [];
|
|
1119
|
+
for (let i = 0; i < values.items.length; i++) {
|
|
1120
|
+
const expression = elements !== undefined && i < elements.length ? elements[i] : undefined;
|
|
1121
|
+
const item = this.convertOption(element, values.items[i], basePath, property, expression, file, errors);
|
|
1122
|
+
if (option.listPreserveFalsyValues === true || (item !== null && item !== false && item !== ''))
|
|
1123
|
+
items.push(item);
|
|
1124
|
+
}
|
|
1125
|
+
return new JsonArray(items);
|
|
1126
|
+
}
|
|
1127
|
+
/** Resolves `extends`: a path, a package, or an array of those. */
|
|
1128
|
+
getExtendsConfigPaths(value, basePath, configFileName, property, valueExpression, file, errors) {
|
|
1129
|
+
const paths = [];
|
|
1130
|
+
const newBase = configFileName !== '' ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, basePath)) : basePath;
|
|
1131
|
+
if (typeof value === 'string') {
|
|
1132
|
+
const path = this.getExtendsConfigPath(value, newBase, valueExpression, file, errors);
|
|
1133
|
+
if (path !== '')
|
|
1134
|
+
paths.push(path);
|
|
1135
|
+
return paths;
|
|
1136
|
+
}
|
|
1137
|
+
if (value instanceof JsonArray) {
|
|
1138
|
+
const elements = valueExpression instanceof ArrayLiteralExpression ? valueExpression.elements.nodes : undefined;
|
|
1139
|
+
for (let i = 0; i < value.items.length; i++) {
|
|
1140
|
+
const item = value.items[i];
|
|
1141
|
+
const expression = elements !== undefined && i < elements.length ? elements[i] : undefined;
|
|
1142
|
+
if (typeof item === 'string') {
|
|
1143
|
+
const path = this.getExtendsConfigPath(item, newBase, expression, file, errors);
|
|
1144
|
+
if (path !== '')
|
|
1145
|
+
paths.push(path);
|
|
1146
|
+
}
|
|
1147
|
+
else if (extendsDeclaration.element !== undefined) {
|
|
1148
|
+
// tsgo checks the whole array against the element type here.
|
|
1149
|
+
this.convertOption(extendsDeclaration.element, value, basePath, property, expression, file, errors);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return paths;
|
|
1153
|
+
}
|
|
1154
|
+
this.convertOption(extendsDeclaration, value, basePath, property, valueExpression, file, errors);
|
|
1155
|
+
return paths;
|
|
1156
|
+
}
|
|
1157
|
+
getExtendsConfigPath(extendedConfig, basePath, valueExpression, file, errors) {
|
|
1158
|
+
extendedConfig = normalizeSlashes(extendedConfig);
|
|
1159
|
+
if (isRootedDiskPath(extendedConfig) || extendedConfig.startsWith('./') || extendedConfig.startsWith('../')) {
|
|
1160
|
+
let path = getNormalizedAbsolutePath(extendedConfig, basePath);
|
|
1161
|
+
if (!this.fs.fileExists(path) && !path.endsWith('.json')) {
|
|
1162
|
+
path += '.json';
|
|
1163
|
+
if (!this.fs.fileExists(path)) {
|
|
1164
|
+
errors.push(diagnosticAtNode(file, valueExpression, 1229 /* Diagnostics.File_0_not_found */, extendedConfig));
|
|
1165
|
+
return '';
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return path;
|
|
1169
|
+
}
|
|
1170
|
+
const resolved = resolveConfig(extendedConfig, combinePaths(basePath, 'tsconfig.json'), this.resolutionHost);
|
|
1171
|
+
if (resolved.resolvedFileName !== '')
|
|
1172
|
+
return resolved.resolvedFileName;
|
|
1173
|
+
errors.push(extendedConfig === ''
|
|
1174
|
+
? diagnosticAtNode(file, valueExpression, 1867 /* Diagnostics.Compiler_option_0_cannot_be_given_an_empty_string */, 'extends')
|
|
1175
|
+
: diagnosticAtNode(file, valueExpression, 1229 /* Diagnostics.File_0_not_found */, extendedConfig));
|
|
1176
|
+
return '';
|
|
1177
|
+
}
|
|
1178
|
+
/** Root files: `files` as given, then `include` matches not excluded, then JSON files matched explicitly. */
|
|
1179
|
+
getFileNamesFromConfigSpecs(specs, basePath, options, literalFiles, onRootFile) {
|
|
1180
|
+
basePath = normalizePath(basePath);
|
|
1181
|
+
const cs = this.fs.useCaseSensitiveFileNames;
|
|
1182
|
+
const wildcardFiles = new Map();
|
|
1183
|
+
const wildcardJsonFiles = new Map();
|
|
1184
|
+
const supportedExtensions = getSupportedExtensions(options);
|
|
1185
|
+
const extensionsWithJson = getSupportedExtensionsWithJsonIfResolveJsonModule(options);
|
|
1186
|
+
// Keys of literal files are the specs as written, as in tsgo.
|
|
1187
|
+
for (const fileName of specs.validatedFilesSpec) {
|
|
1188
|
+
literalFiles.set(getCanonicalFileName(fileName, cs), getNormalizedAbsolutePath(fileName, basePath));
|
|
1189
|
+
}
|
|
1190
|
+
if (onRootFile !== undefined)
|
|
1191
|
+
for (const fileName of literalFiles.values())
|
|
1192
|
+
onRootFile(fileName);
|
|
1193
|
+
const includes = specs.validatedIncludeSpecs;
|
|
1194
|
+
if (includes.length > 0) {
|
|
1195
|
+
// Matches go to `onRootFile` a directory at a time, without those that a file of the same name
|
|
1196
|
+
// with a higher priority extension leaves out below.
|
|
1197
|
+
let directory = '';
|
|
1198
|
+
let pending = [];
|
|
1199
|
+
const flush = () => {
|
|
1200
|
+
if (onRootFile === undefined || pending.length === 0)
|
|
1201
|
+
return;
|
|
1202
|
+
const siblings = new Map();
|
|
1203
|
+
for (const file of pending)
|
|
1204
|
+
siblings.set(getCanonicalFileName(file, cs), file);
|
|
1205
|
+
for (const file of pending)
|
|
1206
|
+
if (!hasFileWithHigherPriorityExtension(file, supportedExtensions, literalFiles, siblings, cs))
|
|
1207
|
+
onRootFile(file);
|
|
1208
|
+
pending = [];
|
|
1209
|
+
};
|
|
1210
|
+
const onMatch = onRootFile === undefined
|
|
1211
|
+
? undefined
|
|
1212
|
+
: (file) => {
|
|
1213
|
+
const fileDirectory = getDirectoryPath(file);
|
|
1214
|
+
if (fileDirectory !== directory) {
|
|
1215
|
+
flush();
|
|
1216
|
+
directory = fileDirectory;
|
|
1217
|
+
}
|
|
1218
|
+
pending.push(file);
|
|
1219
|
+
};
|
|
1220
|
+
const matched = readDirectory(this.fs, basePath, basePath, flattenExtensions(extensionsWithJson), specs.validatedExcludeSpecs, includes, unlimitedDepth, onMatch);
|
|
1221
|
+
flush();
|
|
1222
|
+
let jsonIncludes;
|
|
1223
|
+
for (const file of matched) {
|
|
1224
|
+
if (fileExtensionIs(file, '.json')) {
|
|
1225
|
+
if (jsonIncludes === undefined) {
|
|
1226
|
+
const jsonSpecs = [];
|
|
1227
|
+
for (const include of includes)
|
|
1228
|
+
if (include.endsWith('.json'))
|
|
1229
|
+
jsonSpecs.push(include);
|
|
1230
|
+
jsonIncludes = SpecMatcher.create(jsonSpecs, basePath, 0 /* MatchUsage.Files */, cs);
|
|
1231
|
+
}
|
|
1232
|
+
if (jsonIncludes !== undefined && jsonIncludes.matchIndex(file) !== -1) {
|
|
1233
|
+
const key = getCanonicalFileName(file, cs);
|
|
1234
|
+
if (!literalFiles.has(key) && !wildcardJsonFiles.has(key))
|
|
1235
|
+
wildcardJsonFiles.set(key, file);
|
|
1236
|
+
}
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
// Skip outputs of other matched files, like `a.d.ts` next to `a.ts`.
|
|
1240
|
+
if (hasFileWithHigherPriorityExtension(file, supportedExtensions, literalFiles, wildcardFiles, cs))
|
|
1241
|
+
continue;
|
|
1242
|
+
removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, supportedExtensions, cs);
|
|
1243
|
+
const key = getCanonicalFileName(file, cs);
|
|
1244
|
+
if (!literalFiles.has(key) && !wildcardFiles.has(key))
|
|
1245
|
+
wildcardFiles.set(key, file);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
const files = [];
|
|
1249
|
+
for (const file of literalFiles.values())
|
|
1250
|
+
files.push(file);
|
|
1251
|
+
for (const file of wildcardFiles.values())
|
|
1252
|
+
files.push(file);
|
|
1253
|
+
for (const file of wildcardJsonFiles.values())
|
|
1254
|
+
files.push(file);
|
|
1255
|
+
return files;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
function parseConfigText(fileName, path, text) {
|
|
1259
|
+
return parseSourceFile(fileName, text, new ParseOptions(path, 6 /* ScriptKind.JSON */, new ExternalModuleIndicatorOptions(false, false)));
|
|
1260
|
+
}
|
|
1261
|
+
function isOptionValue(option, value) {
|
|
1262
|
+
if (value === null)
|
|
1263
|
+
return option !== extendsDeclaration;
|
|
1264
|
+
switch (option.kind) {
|
|
1265
|
+
case 'list':
|
|
1266
|
+
return value instanceof JsonArray;
|
|
1267
|
+
case 'listOrElement':
|
|
1268
|
+
return value instanceof JsonArray || (option.element !== undefined && isOptionValue(option.element, value));
|
|
1269
|
+
case 'string':
|
|
1270
|
+
case 'enum':
|
|
1271
|
+
return typeof value === 'string';
|
|
1272
|
+
case 'boolean':
|
|
1273
|
+
return typeof value === 'boolean';
|
|
1274
|
+
case 'number':
|
|
1275
|
+
return typeof value === 'number';
|
|
1276
|
+
case 'object':
|
|
1277
|
+
return value instanceof JsonObject;
|
|
1278
|
+
}
|
|
1279
|
+
return false;
|
|
1280
|
+
}
|
|
1281
|
+
function validateOptionValue(option, value, valueExpression, file, errors) {
|
|
1282
|
+
if (value === null || typeof value !== 'string')
|
|
1283
|
+
return value;
|
|
1284
|
+
if (option.extraValidation === 'spec') {
|
|
1285
|
+
const message = specToDiagnostic(value, false);
|
|
1286
|
+
if (message !== undefined) {
|
|
1287
|
+
errors.push(diagnosticAtNode(file, valueExpression, message, value));
|
|
1288
|
+
return null;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
else if (option.extraValidation === 'locale' && !isValidLocale(value)) {
|
|
1292
|
+
errors.push(diagnosticAtNode(file, valueExpression, 1225 /* Diagnostics.Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1 */, 'en', 'ja-jp'));
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
return value;
|
|
1296
|
+
}
|
|
1297
|
+
function convertEnumOption(option, value, valueExpression, file, errors) {
|
|
1298
|
+
if (value === '')
|
|
1299
|
+
return null;
|
|
1300
|
+
const enumValue = option.values?.get(value.toLowerCase());
|
|
1301
|
+
if (enumValue !== undefined)
|
|
1302
|
+
return validateOptionValue(option, enumValue, valueExpression, file, errors);
|
|
1303
|
+
errors.push(diagnosticAtNode(file, valueExpression, 1224 /* Diagnostics.Argument_for_0_option_must_be_Colon_1 */, '--' + option.name, enumNamesList(option)));
|
|
1304
|
+
return null;
|
|
1305
|
+
}
|
|
1306
|
+
/** `path` relative to `currentDirectory` if absolute. */
|
|
1307
|
+
function convertToRelativePath(path, currentDirectory, useCaseSensitiveFileNames) {
|
|
1308
|
+
if (!isRootedDiskPath(path))
|
|
1309
|
+
return path;
|
|
1310
|
+
return getPathFromPathComponents(getPathComponentsRelativeTo(currentDirectory, path, useCaseSensitiveFileNames, currentDirectory));
|
|
1311
|
+
}
|