tsc-ts 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +22 -15
- package/dist/api/compiler/ast.js +1026 -995
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +178 -124
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +134 -90
- package/dist/api/compiler/checker-contextual.js +64 -61
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +244 -211
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +472 -440
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -107
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +105 -88
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +212 -75
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +145 -36
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +104 -31
- package/dist/api/compiler/checker.js +181 -33
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +42 -3
- package/dist/api/compiler/compile-program.js +139 -27
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.d.ts +22 -0
- package/dist/api/compiler/diagnostics.js +93 -11
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +21 -1
- package/dist/api/compiler/file-loader.js +201 -48
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +23 -23
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parallel-parse.d.ts +3 -2
- package/dist/api/compiler/parallel-parse.js +17 -5
- package/dist/api/compiler/parser.d.ts +40 -19
- package/dist/api/compiler/parser.js +308 -216
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +5 -1
- package/dist/api/compiler/printer/emit-context.js +20 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +3 -1
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +49 -2
- package/dist/api/compiler/printer/printer.js +539 -293
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +12 -2
- package/dist/api/compiler/program-checker.js +88 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +4 -6
- package/dist/api/compiler/program.js +74 -87
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +347 -180
- package/dist/api/compiler/reparser.js +60 -56
- package/dist/api/compiler/scanner.d.ts +19 -2
- package/dist/api/compiler/scanner.js +123 -108
- package/dist/api/compiler/shared-results.d.ts +463 -0
- package/dist/api/compiler/shared-results.js +2128 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +23 -14
- package/dist/api/compiler/symbol.js +23 -11
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +305 -238
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +58 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +79 -9
- package/src/compiler/checker-classes.ts +78 -24
- package/src/compiler/checker-contextual.ts +6 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +79 -46
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +136 -62
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -82
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +26 -4
- package/src/compiler/checker-members.ts +200 -56
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +124 -23
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +203 -39
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +167 -27
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/diagnostics.ts +84 -3
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +197 -38
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +165 -30
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +3 -1
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +326 -52
- package/src/compiler/parallel-emit.ts +320 -0
- package/src/compiler/parallel-parse.ts +16 -5
- package/src/compiler/parse-thread.ts +3 -0
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +21 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +4 -1
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +266 -30
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +57 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +18 -26
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +240 -77
- package/src/compiler/reparser.ts +7 -2
- package/src/compiler/scanner.ts +109 -79
- package/src/compiler/shared-results.ts +2414 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +46 -24
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +64 -4
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +134 -48
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +66 -9
- package/src/compiler/tsc-cli.ts +7 -0
- package/src/compiler/tsc-compile.ts +284 -4
- package/src/compiler/tsc-watch.ts +74 -45
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
modeMismatchDetails,
|
|
42
42
|
moduleNotFoundDetails,
|
|
43
43
|
resolveExternalModuleName,
|
|
44
|
+
getImportAttributesTypeForModuleSpecifier,
|
|
44
45
|
} from './checker-modules.js';
|
|
45
46
|
import { getSymbolAtLocation } from './checker-services.js';
|
|
46
47
|
import { resolveAlias } from './checker-symbols.js';
|
|
@@ -1231,7 +1232,17 @@ function addOwnReferencedFiles(checked: CheckedProgram, file: SourceFile, refere
|
|
|
1231
1232
|
// call that does not initialize a variable (`exports.a = require("./a").a`), so its build info leaves out that
|
|
1232
1233
|
// module and its incremental builds keep outputs that depend on it.
|
|
1233
1234
|
for (const importName of file.imports) {
|
|
1234
|
-
addReferencedFilesFromSymbol(
|
|
1235
|
+
addReferencedFilesFromSymbol(
|
|
1236
|
+
file,
|
|
1237
|
+
referenced,
|
|
1238
|
+
resolveExternalModuleName(
|
|
1239
|
+
checker,
|
|
1240
|
+
importName,
|
|
1241
|
+
importName,
|
|
1242
|
+
true,
|
|
1243
|
+
getImportAttributesTypeForModuleSpecifier(checker, importName),
|
|
1244
|
+
),
|
|
1245
|
+
);
|
|
1235
1246
|
}
|
|
1236
1247
|
const sourceFileDirectory = getDirectoryPath(file.fileName);
|
|
1237
1248
|
for (const reference of file.referencedFiles) {
|
|
@@ -1275,9 +1286,16 @@ function programToSnapshot(checked: CheckedProgram, oldSnapshot: Snapshot | unde
|
|
|
1275
1286
|
// Reuse from the old state.
|
|
1276
1287
|
if (oldSnapshot !== undefined) {
|
|
1277
1288
|
if (options.composite === true) snapshot.latestChangedDtsFile = oldSnapshot.latestChangedDtsFile;
|
|
1278
|
-
for (const path of oldSnapshot.changedFilesSet) snapshot.changedFilesSet.add(path);
|
|
1279
|
-
for (const [path, kind] of oldSnapshot.affectedFilesPendingEmit) snapshot.affectedFilesPendingEmit.set(path, kind);
|
|
1280
1289
|
snapshot.buildInfoEmitPending = oldSnapshot.buildInfoEmitPending;
|
|
1290
|
+
// Changes and pending emit of files no longer in the program are dropped, which changes the build info.
|
|
1291
|
+
for (const path of oldSnapshot.changedFilesSet) {
|
|
1292
|
+
if (program.getSourceFileByPath(path) !== undefined) snapshot.changedFilesSet.add(path);
|
|
1293
|
+
else snapshot.buildInfoEmitPending = true;
|
|
1294
|
+
}
|
|
1295
|
+
for (const [path, kind] of oldSnapshot.affectedFilesPendingEmit) {
|
|
1296
|
+
if (program.getSourceFileByPath(path) !== undefined) snapshot.affectedFilesPendingEmit.set(path, kind);
|
|
1297
|
+
else snapshot.buildInfoEmitPending = true;
|
|
1298
|
+
}
|
|
1281
1299
|
snapshot.hasErrorsFromOldState = oldSnapshot.hasErrors;
|
|
1282
1300
|
snapshot.hasSemanticErrorsFromOldState = oldSnapshot.hasSemanticErrors;
|
|
1283
1301
|
const oldPackageJsons = oldSnapshot.packageJsons;
|
|
@@ -1425,13 +1443,23 @@ function programToSnapshot(checked: CheckedProgram, oldSnapshot: Snapshot | unde
|
|
|
1425
1443
|
if (oldSnapshot !== undefined) {
|
|
1426
1444
|
for (const [path, oldInfo] of oldSnapshot.fileInfos) {
|
|
1427
1445
|
if (snapshot.fileInfos.has(path)) continue;
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1446
|
+
snapshot.buildInfoEmitPending = true;
|
|
1447
|
+
snapshot.changedFilesSet.delete(path);
|
|
1448
|
+
snapshot.affectedFilesPendingEmit.delete(path);
|
|
1449
|
+
if (oldInfo.affectsGlobalScope) globalFileRemoved = true;
|
|
1450
|
+
}
|
|
1451
|
+
if (globalFileRemoved) invalidateGlobalScope(checked, snapshot);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// A file that no longer affects the global scope changes it as its removal would.
|
|
1455
|
+
if (oldSnapshot !== undefined && !globalFileRemoved) {
|
|
1456
|
+
for (const [path, oldInfo] of oldSnapshot.fileInfos) {
|
|
1457
|
+
if (!oldInfo.affectsGlobalScope) continue;
|
|
1458
|
+
const info = snapshot.fileInfos.get(path);
|
|
1459
|
+
if (info !== undefined && !info.affectsGlobalScope) {
|
|
1460
|
+
invalidateGlobalScope(checked, snapshot);
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1435
1463
|
}
|
|
1436
1464
|
}
|
|
1437
1465
|
|
|
@@ -1460,6 +1488,19 @@ function programToSnapshot(checked: CheckedProgram, oldSnapshot: Snapshot | unde
|
|
|
1460
1488
|
return snapshot;
|
|
1461
1489
|
}
|
|
1462
1490
|
|
|
1491
|
+
/**
|
|
1492
|
+
* After a change to the global scope, every file but the default libraries is changed, and the default
|
|
1493
|
+
* libraries that are checked are checked again.
|
|
1494
|
+
*/
|
|
1495
|
+
function invalidateGlobalScope(checked: CheckedProgram, snapshot: Snapshot): void {
|
|
1496
|
+
const program = checked.program;
|
|
1497
|
+
snapshot.buildInfoEmitPending = true;
|
|
1498
|
+
for (const file of program.getSourceFiles()) {
|
|
1499
|
+
if (!program.isSourceFileDefaultLibrary(file.path)) snapshot.addFileToChangeSet(file.path);
|
|
1500
|
+
else if (!checked.skipTypeChecking(file, true)) snapshot.semanticDiagnosticsPerFile.delete(file.path);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1463
1504
|
// ---- Affected files
|
|
1464
1505
|
|
|
1465
1506
|
class AffectedFilesHandler {
|
|
@@ -1510,7 +1551,12 @@ class AffectedFilesHandler {
|
|
|
1510
1551
|
private computeDtsSignature(file: SourceFile): string {
|
|
1511
1552
|
const known = this.incremental.signatures.get(file.path);
|
|
1512
1553
|
if (known !== undefined) return known;
|
|
1513
|
-
|
|
1554
|
+
const done = this.incremental.beginNestedEmit();
|
|
1555
|
+
try {
|
|
1556
|
+
return declarationSignature(this.incremental.emitter, file, this.snapshot.options);
|
|
1557
|
+
} finally {
|
|
1558
|
+
done();
|
|
1559
|
+
}
|
|
1514
1560
|
}
|
|
1515
1561
|
|
|
1516
1562
|
updateShapeSignature(file: SourceFile, useFileVersionAsSignature: boolean): boolean {
|
|
@@ -1519,7 +1565,10 @@ class AffectedFilesHandler {
|
|
|
1519
1565
|
if (info === undefined) return false;
|
|
1520
1566
|
const previous = info.signature;
|
|
1521
1567
|
let signature = '';
|
|
1522
|
-
|
|
1568
|
+
// A JSON file has no declaration output, so its version is its signature, which invalidates its importers.
|
|
1569
|
+
if (!file.isDeclarationFile && !isJsonSourceFile(file) && !useFileVersionAsSignature) {
|
|
1570
|
+
signature = this.computeDtsSignature(file);
|
|
1571
|
+
}
|
|
1523
1572
|
if (signature === '') signature = info.version;
|
|
1524
1573
|
this.updatedSignatures.set(file.path, signature);
|
|
1525
1574
|
return signature !== previous;
|
|
@@ -1549,7 +1598,7 @@ class AffectedFilesHandler {
|
|
|
1549
1598
|
const info = this.snapshot.fileInfos.get(file.path);
|
|
1550
1599
|
if (info !== undefined && info.affectsGlobalScope) {
|
|
1551
1600
|
this.hasAllFilesExcludingDefaultLibraryFile = true;
|
|
1552
|
-
this.snapshot.getAllFilesExcludingDefaultLibraryFile(this.program, file);
|
|
1601
|
+
return this.snapshot.getAllFilesExcludingDefaultLibraryFile(this.program, file);
|
|
1553
1602
|
}
|
|
1554
1603
|
if (this.snapshot.options.isolatedModules === true) return [file];
|
|
1555
1604
|
const seen = this.forEachFileReferencedBy(file, (currentFile) => {
|
|
@@ -1864,8 +1913,21 @@ class EmitFilesHandler {
|
|
|
1864
1913
|
const files = program.program.getSourceFiles();
|
|
1865
1914
|
const emittedOnCheckers = this.emittedOnCheckers();
|
|
1866
1915
|
const wrapped = this.wrap(writer);
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1916
|
+
const ahead = this.declarationsEmittedAhead();
|
|
1917
|
+
const result = program.checked.javaScriptEmittedOnThreads
|
|
1918
|
+
? combineEmitResults(
|
|
1919
|
+
files.map((file) =>
|
|
1920
|
+
this.emitAfterEmitThreads(
|
|
1921
|
+
file,
|
|
1922
|
+
EmitOnly.All,
|
|
1923
|
+
emittedOnCheckers.get(file),
|
|
1924
|
+
ahead.get(file),
|
|
1925
|
+
writer,
|
|
1926
|
+
wrapped,
|
|
1927
|
+
),
|
|
1928
|
+
),
|
|
1929
|
+
)
|
|
1930
|
+
: emittedOnCheckers.size === 0
|
|
1869
1931
|
? program.emitter.emit(files, EmitOnly.All, wrapped)
|
|
1870
1932
|
: combineEmitResults(
|
|
1871
1933
|
files.map((file) => {
|
|
@@ -1901,20 +1963,76 @@ class EmitFilesHandler {
|
|
|
1901
1963
|
/**
|
|
1902
1964
|
* The emit results of the files checker threads emitted right after checking them (parallel-check.ts),
|
|
1903
1965
|
* which are not emitted again here. Checker threads emit every file of a program without old build
|
|
1904
|
-
* info, with the outputs its options select, as its pending emit asks.
|
|
1966
|
+
* info, with the outputs its options select, as its pending emit asks. Emit threads emit only the
|
|
1967
|
+
* JavaScript of the files (`javaScriptEmittedOnThreads`, `emitAfterEmitThreads`).
|
|
1905
1968
|
*/
|
|
1906
1969
|
private emittedOnCheckers(): Map<SourceFile, EmitResult> {
|
|
1970
|
+
return this.byFile(this.program.checked.emittedInParallel);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
/** The declaration emit of the files the declaration thread emitted (parallel-emit.ts). */
|
|
1974
|
+
private declarationsEmittedAhead(): Map<SourceFile, EmitResult> {
|
|
1975
|
+
return this.byFile(this.program.checked.declarationsEmittedAhead);
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/** The results of `results`, by file index, by file. */
|
|
1979
|
+
private byFile(results: readonly (EmitResult | undefined)[] | undefined): Map<SourceFile, EmitResult> {
|
|
1907
1980
|
const result = new Map<SourceFile, EmitResult>();
|
|
1908
|
-
|
|
1909
|
-
if (emitted === undefined) return result;
|
|
1981
|
+
if (results === undefined) return result;
|
|
1910
1982
|
const files = this.program.program.getSourceFiles();
|
|
1911
1983
|
for (let i = 0; i < files.length; i++) {
|
|
1912
|
-
const fileResult =
|
|
1984
|
+
const fileResult = results[i];
|
|
1913
1985
|
if (fileResult !== undefined) result.set(files[i]!, fileResult);
|
|
1914
1986
|
}
|
|
1915
1987
|
return result;
|
|
1916
1988
|
}
|
|
1917
1989
|
|
|
1990
|
+
/**
|
|
1991
|
+
* The emit of `file` with `emitOnly` where emit threads emitted the JavaScript of the program's files
|
|
1992
|
+
* while this thread checked it (`javaScriptEmittedOnThreads`, parallel-emit.ts): the outputs an emit thread
|
|
1993
|
+
* emitted of its JavaScript (`javaScript`) and the declaration thread of its declarations (`declarations`),
|
|
1994
|
+
* and the rest emitted here. A file no thread emitted is emitted here as without the threads.
|
|
1995
|
+
*/
|
|
1996
|
+
private emitAfterEmitThreads(
|
|
1997
|
+
file: SourceFile,
|
|
1998
|
+
emitOnly: EmitOnly,
|
|
1999
|
+
javaScript: EmitResult | undefined,
|
|
2000
|
+
declarations: EmitResult | undefined,
|
|
2001
|
+
writer: OutputWriter,
|
|
2002
|
+
wrapped: OutputWriter,
|
|
2003
|
+
): EmitResult {
|
|
2004
|
+
const program = this.program;
|
|
2005
|
+
if (wrapped instanceof SignatureRecordingWriter) wrapped.file = file;
|
|
2006
|
+
if (javaScript === undefined && declarations === undefined) return program.emitter.emit([file], emitOnly, wrapped);
|
|
2007
|
+
const results: EmitResult[] = [];
|
|
2008
|
+
if (emitOnly !== EmitOnly.Dts)
|
|
2009
|
+
results.push(
|
|
2010
|
+
javaScript !== undefined
|
|
2011
|
+
? this.writeThreadOutputs(file, javaScript, writer)
|
|
2012
|
+
: program.emitter.emit([file], EmitOnly.Js, writer),
|
|
2013
|
+
);
|
|
2014
|
+
if (emitOnly !== EmitOnly.Js && getEmitDeclarations(program.snapshot.options))
|
|
2015
|
+
results.push(
|
|
2016
|
+
declarations !== undefined
|
|
2017
|
+
? this.writeThreadOutputs(file, declarations, writer)
|
|
2018
|
+
: program.emitter.emit([file], emitOnly === EmitOnly.Dts ? EmitOnly.Dts : EmitOnly.DtsAfterJs, wrapped),
|
|
2019
|
+
);
|
|
2020
|
+
return combineEmitResults(results);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
/**
|
|
2024
|
+
* Writes the outputs a thread emitted for `file` with `writer`, as this thread would have written them:
|
|
2025
|
+
* its declaration signatures are recorded (`recordDeclarationSignatures`), and the unchanged declaration
|
|
2026
|
+
* files of a composite program are left unwritten.
|
|
2027
|
+
*/
|
|
2028
|
+
private writeThreadOutputs(file: SourceFile, emitted: EmitResult, writer: OutputWriter): EmitResult {
|
|
2029
|
+
const skips = this.recordDeclarationSignatures(file, emitted.declarationSignatures);
|
|
2030
|
+
return writeHeldOutputs(
|
|
2031
|
+
emitted,
|
|
2032
|
+
skips === undefined ? writer : new HeldDeclarationWriter(writer, skips, this.program.host),
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1918
2036
|
/** Records declaration signatures when declarations are emitted. */
|
|
1919
2037
|
private wrap(writer: OutputWriter): OutputWriter {
|
|
1920
2038
|
return getEmitDeclarations(this.program.snapshot.options) ? new SignatureRecordingWriter(this, writer) : writer;
|
|
@@ -1926,6 +2044,7 @@ class EmitFilesHandler {
|
|
|
1926
2044
|
collectAllAffectedFiles(program);
|
|
1927
2045
|
const wrapped = this.wrap(writer);
|
|
1928
2046
|
const emittedOnCheckers = this.emittedOnCheckers();
|
|
2047
|
+
const ahead = this.declarationsEmittedAhead();
|
|
1929
2048
|
for (const [path, emitKind] of snapshot.affectedFilesPendingEmit) {
|
|
1930
2049
|
const affectedFile = program.program.getSourceFileByPath(path);
|
|
1931
2050
|
if (affectedFile === undefined || !program.program.sourceFileMayBeEmitted(affectedFile, false)) {
|
|
@@ -1939,13 +2058,10 @@ class EmitFilesHandler {
|
|
|
1939
2058
|
if (!this.isForDtsErrors) {
|
|
1940
2059
|
const emitOnly = emitOnlyOfPendingKind(pendingKind);
|
|
1941
2060
|
const emitted = emittedOnCheckers.get(affectedFile);
|
|
1942
|
-
if (
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
skips === undefined ? writer : new HeldDeclarationWriter(writer, skips, program.host),
|
|
1947
|
-
);
|
|
1948
|
-
} else {
|
|
2061
|
+
if (program.checked.javaScriptEmittedOnThreads)
|
|
2062
|
+
result = this.emitAfterEmitThreads(affectedFile, emitOnly, emitted, ahead.get(affectedFile), writer, wrapped);
|
|
2063
|
+
else if (emitted !== undefined) result = this.writeThreadOutputs(affectedFile, emitted, writer);
|
|
2064
|
+
else {
|
|
1949
2065
|
if (wrapped instanceof SignatureRecordingWriter) wrapped.file = affectedFile;
|
|
1950
2066
|
result = program.emitter.emit([affectedFile], emitOnly, wrapped);
|
|
1951
2067
|
}
|
|
@@ -2491,6 +2607,7 @@ export class IncrementalProgram extends CompilerProgram {
|
|
|
2491
2607
|
readonly signatures: ReadonlyMap<string, string> = new Map(),
|
|
2492
2608
|
) {
|
|
2493
2609
|
super(checked, times);
|
|
2610
|
+
checked.globalsInFileDiagnostics = true;
|
|
2494
2611
|
this.snapshot = programToSnapshot(checked, oldSnapshot);
|
|
2495
2612
|
}
|
|
2496
2613
|
|
|
@@ -2498,6 +2615,25 @@ export class IncrementalProgram extends CompilerProgram {
|
|
|
2498
2615
|
return this.snapshot.hasChangedDtsFile;
|
|
2499
2616
|
}
|
|
2500
2617
|
|
|
2618
|
+
/** Time spent in declaration emit for signatures while checking (`computeDtsSignature`), not yet taken. */
|
|
2619
|
+
private nestedEmitTime = 0;
|
|
2620
|
+
private nestedEmitDepth = 0;
|
|
2621
|
+
private nestedEmitStart = 0;
|
|
2622
|
+
|
|
2623
|
+
/** Starts timing a nested declaration emit; returns the function that ends it. */
|
|
2624
|
+
beginNestedEmit(): () => void {
|
|
2625
|
+
if (this.nestedEmitDepth++ === 0) this.nestedEmitStart = performance.now();
|
|
2626
|
+
return () => {
|
|
2627
|
+
if (--this.nestedEmitDepth === 0) this.nestedEmitTime += performance.now() - this.nestedEmitStart;
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
override takeNestedEmitTime(): number {
|
|
2632
|
+
const time = this.nestedEmitTime;
|
|
2633
|
+
this.nestedEmitTime = 0;
|
|
2634
|
+
return time;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2501
2637
|
/**
|
|
2502
2638
|
* The global diagnostics found before `filesToCheck` computed the affected files, which the program
|
|
2503
2639
|
* reports before its semantic diagnostics (`getGlobalDiagnostics(false)`), as when they are computed
|
|
@@ -2630,10 +2766,9 @@ export class IncrementalProgram extends CompilerProgram {
|
|
|
2630
2766
|
emit(writer: OutputWriter): EmitResult {
|
|
2631
2767
|
const options = this.snapshot.options;
|
|
2632
2768
|
let result: EmitResult | undefined;
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
} else result = handleNoEmitOnError(this);
|
|
2769
|
+
// A `noEmit` program emits only its build info, and its emit is not skipped (tsgo's `HandleNoEmitOptions`).
|
|
2770
|
+
if (options.noEmit === true) result = new EmitResult();
|
|
2771
|
+
else result = handleNoEmitOnError(this);
|
|
2637
2772
|
if (result !== undefined) {
|
|
2638
2773
|
const buildInfoResult = this.emitBuildInfo(writer);
|
|
2639
2774
|
if (buildInfoResult !== undefined) {
|
package/src/compiler/init.ts
CHANGED
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
* The tsconfig.json written by `tsc --init`.
|
|
3
3
|
*/
|
|
4
4
|
import { Diagnostics, localizeMessage, type DiagnosticMessage, type Locale } from './diagnostics.js';
|
|
5
|
-
import {
|
|
6
|
-
compilerOptionsByName,
|
|
7
|
-
sameEnumValue,
|
|
8
|
-
watchOptionsByName,
|
|
9
|
-
type OptionDeclaration,
|
|
10
|
-
} from './option-declarations.js';
|
|
5
|
+
import { compilerOptionsByName, sameEnumValue, type OptionDeclaration } from './option-declarations.js';
|
|
11
6
|
import { JsxEmit, ModuleDetectionKind, ModuleKind, ScriptTarget, type OptionValue } from './options.js';
|
|
12
7
|
|
|
13
8
|
const enum Commented {
|
|
@@ -124,7 +119,7 @@ class ConfigWriter {
|
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
function formatValue(name: string, value: OptionValue): string {
|
|
127
|
-
const option = compilerOptionsByName.get(name)
|
|
122
|
+
const option = compilerOptionsByName.get(name);
|
|
128
123
|
if (value === null) return 'null';
|
|
129
124
|
if (typeof value === 'boolean') return value ? 'true' : 'false';
|
|
130
125
|
if (typeof value === 'number' || typeof value === 'string') return formatScalar(value, option);
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
newTypeMapper,
|
|
44
44
|
SimpleTypeMapper,
|
|
45
45
|
TypeListCache,
|
|
46
|
+
getMappedType,
|
|
46
47
|
} from './checker-types.js';
|
|
47
48
|
import {
|
|
48
49
|
IntersectionFlags,
|
|
@@ -87,6 +88,7 @@ import {
|
|
|
87
88
|
type Symbol,
|
|
88
89
|
SymbolFlags,
|
|
89
90
|
} from './symbol.js';
|
|
91
|
+
import { symbolToString } from './type-printer.js';
|
|
90
92
|
|
|
91
93
|
// ---- Mappers that need the checker
|
|
92
94
|
|
|
@@ -104,8 +106,8 @@ export class CompositeTypeMapper extends TypeMapper {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
map(type: Type): Type {
|
|
107
|
-
const t1 = this.m1
|
|
108
|
-
return t1 !== type ? instantiateType(this.c, t1, this.m2) : this.m2
|
|
109
|
+
const t1 = getMappedType(type, this.m1);
|
|
110
|
+
return t1 !== type ? instantiateType(this.c, t1, this.m2) : getMappedType(type, this.m2);
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -202,23 +204,37 @@ export function instantiateTypeWithAlias(
|
|
|
202
204
|
}
|
|
203
205
|
if (!could && (type.alias === undefined || !aliasCouldContainTypeVariables(c, type))) return type;
|
|
204
206
|
if (c.instantiationDepth === 100 || c.instantiationCount >= 5000000) {
|
|
205
|
-
// Probably infinitely expanding generic types; stop with the error type
|
|
206
|
-
|
|
207
|
+
// Probably infinitely expanding generic types; stop with the error type, naming the types whose
|
|
208
|
+
// instantiations nest three or more times.
|
|
209
|
+
const circularTypeNames = getCircularTypeNames(c);
|
|
210
|
+
if (circularTypeNames.length === 1)
|
|
211
|
+
c.error(c.currentNode, Diagnostics.Instantiations_of_type_0_appear_infinitely_circular, circularTypeNames[0]!);
|
|
212
|
+
else if (circularTypeNames.length > 1)
|
|
213
|
+
c.error(
|
|
214
|
+
c.currentNode,
|
|
215
|
+
Diagnostics.Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0,
|
|
216
|
+
quotedAndCommaSeparated(circularTypeNames),
|
|
217
|
+
);
|
|
218
|
+
else c.error(c.currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
207
219
|
return c.errorType;
|
|
208
220
|
}
|
|
209
|
-
const depth = c.activeMapperDepth;
|
|
210
|
-
const
|
|
211
|
-
let index = depth - 1;
|
|
212
|
-
while (index >= 0 &&
|
|
221
|
+
const depth = c.activeMapperDepth | 0;
|
|
222
|
+
const mapperId = mapper.id | 0;
|
|
223
|
+
let index = (depth - 1) | 0;
|
|
224
|
+
while (index >= 0 && c.activeMapperIds[index]! !== mapperId) index = (index - 1) | 0;
|
|
213
225
|
if (index === -1) {
|
|
214
226
|
// A newly active mapper has no cached instantiations; its cache is created when a nested
|
|
215
227
|
// instantiation with the same mapper stores one.
|
|
216
|
-
if (depth
|
|
217
|
-
|
|
228
|
+
if (depth === c.activeMapperIds.length) {
|
|
229
|
+
const grown = new Int32Array(depth * 2);
|
|
230
|
+
grown.set(c.activeMapperIds);
|
|
231
|
+
c.activeMapperIds = grown;
|
|
232
|
+
}
|
|
233
|
+
c.activeMapperIds[depth] = mapperId;
|
|
234
|
+
if (depth < c.activeMapperCaches.length) {
|
|
218
235
|
c.activeMapperCaches[depth] = undefined;
|
|
219
236
|
c.activeMapperAliasCaches[depth] = undefined;
|
|
220
237
|
} else {
|
|
221
|
-
activeMappers.push(mapper);
|
|
222
238
|
c.activeMapperCaches.push(undefined);
|
|
223
239
|
c.activeMapperAliasCaches.push(undefined);
|
|
224
240
|
}
|
|
@@ -236,7 +252,11 @@ export function instantiateTypeWithAlias(
|
|
|
236
252
|
}
|
|
237
253
|
c.instantiationCount++;
|
|
238
254
|
c.totalInstantiations++;
|
|
239
|
-
c.instantiationDepth
|
|
255
|
+
const instantiationDepth = c.instantiationDepth;
|
|
256
|
+
const instantiationStack = c.instantiationStack;
|
|
257
|
+
if (instantiationDepth < instantiationStack.length) instantiationStack[instantiationDepth] = type;
|
|
258
|
+
else instantiationStack.push(type);
|
|
259
|
+
c.instantiationDepth = instantiationDepth + 1;
|
|
240
260
|
const result = instantiateTypeWorker(c, type, mapper, alias);
|
|
241
261
|
if (index === -1) {
|
|
242
262
|
// The mapper's slot stays until it is reused; its caches are released now.
|
|
@@ -274,6 +294,32 @@ export function instantiateTypeWithAlias(
|
|
|
274
294
|
return result;
|
|
275
295
|
}
|
|
276
296
|
|
|
297
|
+
/**
|
|
298
|
+
* The names of the types that are instantiated three or more times on the current instantiation stack, by
|
|
299
|
+
* their alias where they have one, in the order they reach the third, each once.
|
|
300
|
+
*/
|
|
301
|
+
function getCircularTypeNames(c: Checker): string[] {
|
|
302
|
+
const counts = new Map<Type, number>();
|
|
303
|
+
const names: string[] = [];
|
|
304
|
+
const stack = c.instantiationStack;
|
|
305
|
+
for (let i = 0; i < c.instantiationDepth; i++) {
|
|
306
|
+
const t = stack[i]!;
|
|
307
|
+
const count = (counts.get(t) ?? 0) + 1;
|
|
308
|
+
counts.set(t, count);
|
|
309
|
+
if (count !== 3) continue;
|
|
310
|
+
const symbol = t.alias !== undefined ? t.alias.symbol : t.symbol;
|
|
311
|
+
if (symbol === undefined || symbol.name.length === 0 || symbol.name.charCodeAt(0) === 0xfffe) continue;
|
|
312
|
+
const name = symbolToString(c, symbol);
|
|
313
|
+
if (!names.includes(name)) names.push(name);
|
|
314
|
+
}
|
|
315
|
+
return names;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** `'a', 'b', 'c'`. */
|
|
319
|
+
export function quotedAndCommaSeparated(items: readonly string[]): string {
|
|
320
|
+
return items.map((item) => "'" + item + "'").join(', ');
|
|
321
|
+
}
|
|
322
|
+
|
|
277
323
|
function aliasCouldContainTypeVariables(c: Checker, type: Type): boolean {
|
|
278
324
|
const alias = type.alias;
|
|
279
325
|
if (alias === undefined || alias.typeArguments.length === 0) return false;
|
|
@@ -358,7 +404,7 @@ function isNonGenericTopLevelType(type: Type): boolean {
|
|
|
358
404
|
|
|
359
405
|
function instantiateTypeWorker(c: Checker, type: Type, mapper: TypeMapper, alias: TypeAlias | undefined): Type {
|
|
360
406
|
const flags = type.flags;
|
|
361
|
-
if ((flags & TypeFlags.TypeParameter) !== 0) return
|
|
407
|
+
if ((flags & TypeFlags.TypeParameter) !== 0) return getMappedType(type, mapper);
|
|
362
408
|
if ((flags & TypeFlags.Object) !== 0) {
|
|
363
409
|
const objectFlags = type.objectFlags;
|
|
364
410
|
if ((objectFlags & (ObjectFlags.Reference | ObjectFlags.Anonymous | ObjectFlags.Mapped)) === 0) return type;
|
|
@@ -447,7 +493,7 @@ function getObjectTypeInstantiation(
|
|
|
447
493
|
mapper: TypeMapper,
|
|
448
494
|
alias: TypeAlias | undefined,
|
|
449
495
|
): Type {
|
|
450
|
-
if ((type.objectFlags & ObjectFlags.Reference) === 0 && c.withoutOuterTypeParameters.
|
|
496
|
+
if ((type.objectFlags & ObjectFlags.Reference) === 0 && c.withoutOuterTypeParameters.has(type.id)) return type;
|
|
451
497
|
let declaration: Node;
|
|
452
498
|
if ((type.objectFlags & ObjectFlags.Reference) !== 0) declaration = (type as TypeReference).node!;
|
|
453
499
|
else if ((type.objectFlags & ObjectFlags.InstantiationExpressionType) !== 0)
|
|
@@ -483,7 +529,7 @@ function getObjectTypeInstantiation(
|
|
|
483
529
|
links.outerTypeParameters = typeParameters;
|
|
484
530
|
}
|
|
485
531
|
if (typeParameters.length === 0) {
|
|
486
|
-
if ((type.objectFlags & ObjectFlags.Reference) === 0) c.withoutOuterTypeParameters.
|
|
532
|
+
if ((type.objectFlags & ObjectFlags.Reference) === 0) c.withoutOuterTypeParameters.add(type.id);
|
|
487
533
|
return type;
|
|
488
534
|
}
|
|
489
535
|
// The type arguments, mapped as `combineTypeMappers(c, type.mapper, mapper)` maps them, into a
|
|
@@ -491,10 +537,10 @@ function getObjectTypeInstantiation(
|
|
|
491
537
|
const typeMapper = type.mapper;
|
|
492
538
|
const mapped = c.freeTypeLists.pop() ?? [];
|
|
493
539
|
for (const tp of typeParameters) {
|
|
494
|
-
if (typeMapper === undefined) mapped.push(
|
|
540
|
+
if (typeMapper === undefined) mapped.push(getMappedType(tp, mapper));
|
|
495
541
|
else {
|
|
496
|
-
const t1 =
|
|
497
|
-
mapped.push(t1 !== tp ? instantiateType(c, t1, mapper) :
|
|
542
|
+
const t1 = getMappedType(tp, typeMapper);
|
|
543
|
+
mapped.push(t1 !== tp ? instantiateType(c, t1, mapper) : getMappedType(tp, mapper));
|
|
498
544
|
}
|
|
499
545
|
}
|
|
500
546
|
const newAlias = alias ?? instantiateTypeAlias(c, type.alias, mapper);
|
|
@@ -804,10 +850,19 @@ export function instantiateSymbol(c: Checker, symbol: Symbol, mapper: TypeMapper
|
|
|
804
850
|
* is resolved yet, so lazily instantiated members record it when tsgo would instantiate them.
|
|
805
851
|
*/
|
|
806
852
|
export function keepsSymbolUnderInstantiation(c: Checker, symbol: Symbol, mapper: TypeMapper): boolean {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
853
|
+
if (mapper.mapsThisOnly() && isThisless(symbol)) {
|
|
854
|
+
getSymbolId(symbol);
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
return keepsSymbolTypeUnderInstantiation(c, symbol);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Whether the resolved type of `symbol` (and its write type) can't change under instantiation, so that
|
|
862
|
+
* `instantiateSymbol` keeps it whatever the mapper. Once true, it stays true: types are resolved once.
|
|
863
|
+
*/
|
|
864
|
+
export function keepsSymbolTypeUnderInstantiation(c: Checker, symbol: Symbol): boolean {
|
|
865
|
+
const type = c.symbolTypes.get(getSymbolId(symbol));
|
|
811
866
|
if (type !== undefined && !couldContainTypeVariables(c, type)) {
|
|
812
867
|
if ((symbol.flags & SymbolFlags.SetAccessor) === 0) return true;
|
|
813
868
|
const writeType = c.existingSymbolLinks(symbol)?.writeType;
|
package/src/compiler/jsdoc.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
getTagName,
|
|
47
47
|
getType,
|
|
48
48
|
type EntityName,
|
|
49
|
+
getText,
|
|
49
50
|
} from './ast.js';
|
|
50
51
|
import { isReservedWord, tokenIsIdentifierOrKeyword } from './ast-utilities.js';
|
|
51
52
|
import { CharacterCodes, isWhiteSpaceLike } from './character-codes.js';
|
|
@@ -937,6 +938,7 @@ export class JSDocParser {
|
|
|
937
938
|
undefined,
|
|
938
939
|
SyntaxKind.NamespaceKeyword,
|
|
939
940
|
typeNameOrNamespaceName,
|
|
941
|
+
undefined,
|
|
940
942
|
body,
|
|
941
943
|
);
|
|
942
944
|
if (nested) jsDocNamespaceNode.flags |= NodeFlags.NestedNamespace;
|
|
@@ -1270,7 +1272,7 @@ function textsEqual(a: Node, b: Node): boolean {
|
|
|
1270
1272
|
if (
|
|
1271
1273
|
a instanceof QualifiedName &&
|
|
1272
1274
|
b instanceof QualifiedName &&
|
|
1273
|
-
(a as QualifiedName).right
|
|
1275
|
+
getText((a as QualifiedName).right) === getText((b as QualifiedName).right)
|
|
1274
1276
|
) {
|
|
1275
1277
|
a = (a as QualifiedName).left;
|
|
1276
1278
|
b = (b as QualifiedName).left;
|