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
|
@@ -128,11 +128,13 @@ import {
|
|
|
128
128
|
getBaseTypeVariableOfClass,
|
|
129
129
|
getNonMissingTypeOfSymbol,
|
|
130
130
|
getOptionalType,
|
|
131
|
+
getTypeForVariableLikeDeclaration,
|
|
131
132
|
getTypeOfSymbol,
|
|
132
133
|
getWriteTypeOfSymbol,
|
|
133
134
|
isReadonlySymbol,
|
|
134
135
|
removeMissingType,
|
|
135
136
|
} from './checker-symbol-types.js';
|
|
137
|
+
import { isVariableLike } from './checker-declarations.js';
|
|
136
138
|
import {
|
|
137
139
|
getFirstIdentifier,
|
|
138
140
|
getGlobalTypeAliasSymbol,
|
|
@@ -143,15 +145,18 @@ import {
|
|
|
143
145
|
} from './checker-symbols.js';
|
|
144
146
|
import {
|
|
145
147
|
createArrayType,
|
|
148
|
+
createTypeReference,
|
|
146
149
|
filterType,
|
|
147
150
|
getIntersectionType,
|
|
148
151
|
getTypeArguments,
|
|
149
152
|
getTypeReferenceArity,
|
|
150
153
|
getWidenedLiteralType,
|
|
154
|
+
isArrayOrTupleType,
|
|
151
155
|
isErrorType,
|
|
152
156
|
isTupleType,
|
|
153
157
|
inDeclarationOrder,
|
|
154
158
|
newAnonymousType,
|
|
159
|
+
typeListKey,
|
|
155
160
|
} from './checker-type-factory.js';
|
|
156
161
|
import { getTypeFromTypeNode } from './checker-type-nodes.js';
|
|
157
162
|
import {
|
|
@@ -180,6 +185,7 @@ import {
|
|
|
180
185
|
type LiteralType,
|
|
181
186
|
type MappedType,
|
|
182
187
|
ObjectFlags,
|
|
188
|
+
type ReverseMappedType,
|
|
183
189
|
Signature,
|
|
184
190
|
SignatureFlags,
|
|
185
191
|
SignatureKind,
|
|
@@ -199,6 +205,7 @@ import {
|
|
|
199
205
|
type UnionOrIntersectionType,
|
|
200
206
|
newTypeMapper,
|
|
201
207
|
prependTypeMapping,
|
|
208
|
+
getNonDistributedTypeParameter,
|
|
202
209
|
} from './checker-types.js';
|
|
203
210
|
import {
|
|
204
211
|
hasLateBindableIndexSignature,
|
|
@@ -289,6 +296,20 @@ export class TrackedSymbol {
|
|
|
289
296
|
}
|
|
290
297
|
}
|
|
291
298
|
|
|
299
|
+
/**
|
|
300
|
+
* The caches of tsgo's node builder that outlive one request: an emit resolver keeps one node builder, so the types
|
|
301
|
+
* serialized for one declaration are reused, as copies without positions, by the next ones in the file.
|
|
302
|
+
*/
|
|
303
|
+
export class NodeBuilderCaches {
|
|
304
|
+
readonly serializedTypes: Map<number, Map<string, SerializedTypeEntry>>;
|
|
305
|
+
readonly fakeScopes: Map<Node, string>;
|
|
306
|
+
|
|
307
|
+
constructor() {
|
|
308
|
+
this.serializedTypes = new Map<number, Map<string, SerializedTypeEntry>>();
|
|
309
|
+
this.fakeScopes = new Map<Node, string>();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
292
313
|
class SerializedTypeEntry {
|
|
293
314
|
readonly node: Node;
|
|
294
315
|
readonly truncating: boolean;
|
|
@@ -463,6 +484,8 @@ export class NodeBuilder {
|
|
|
463
484
|
pseudo: PseudoChecker | undefined = undefined;
|
|
464
485
|
/** Set for declaration emit, which writes unions in an order that doesn't depend on the checker's history. */
|
|
465
486
|
declarationOrder = false;
|
|
487
|
+
/** When set, the symbol each identifier naming a symbol refers to. */
|
|
488
|
+
idToSymbol: Map<Node, Symbol> | undefined = undefined;
|
|
466
489
|
|
|
467
490
|
constructor(
|
|
468
491
|
c: Checker,
|
|
@@ -532,6 +555,12 @@ export class NodeBuilder {
|
|
|
532
555
|
return (this.fakeScopesStore ??= new Map<Node, string>());
|
|
533
556
|
}
|
|
534
557
|
|
|
558
|
+
/** Uses `caches` for the types this builder serializes and its fake scopes, sharing them with other builders. */
|
|
559
|
+
useCaches(caches: NodeBuilderCaches): void {
|
|
560
|
+
this.serializedTypesStore = caches.serializedTypes;
|
|
561
|
+
this.fakeScopesStore = caches.fakeScopes;
|
|
562
|
+
}
|
|
563
|
+
|
|
535
564
|
/** `result`, or undefined if serialization failed. */
|
|
536
565
|
finish<T>(result: T | undefined): T | undefined {
|
|
537
566
|
if (this.truncating && (this.flags & NodeBuilderFlags.NoTruncation) !== 0) this.tracker.reportTruncationError();
|
|
@@ -581,6 +610,13 @@ export class NodeBuilder {
|
|
|
581
610
|
return this.factory.createIdentifier(text);
|
|
582
611
|
}
|
|
583
612
|
|
|
613
|
+
/** An identifier naming `symbol`, recorded in `idToSymbol`. */
|
|
614
|
+
symbolIdentifier(text: string, symbol: Symbol): Identifier {
|
|
615
|
+
const identifier = this.factory.createIdentifier(text);
|
|
616
|
+
this.idToSymbol?.set(identifier, symbol);
|
|
617
|
+
return identifier;
|
|
618
|
+
}
|
|
619
|
+
|
|
584
620
|
stringLiteral(text: string, isSingleQuote: boolean): StringLiteral {
|
|
585
621
|
const flags =
|
|
586
622
|
isSingleQuote || (this.flags & NodeBuilderFlags.UseSingleQuotesForStringLiteralType) !== 0
|
|
@@ -868,7 +904,8 @@ export class NodeBuilder {
|
|
|
868
904
|
this.approximateLength += 3;
|
|
869
905
|
return this.keyword(SyntaxKind.AnyKeyword);
|
|
870
906
|
}
|
|
871
|
-
|
|
907
|
+
// A distributed type parameter prints as the type parameter it was made from.
|
|
908
|
+
let t = getNonDistributedTypeParameter(type);
|
|
872
909
|
if ((this.flags & NodeBuilderFlags.NoTypeReduction) === 0) t = getReducedType(c, t);
|
|
873
910
|
const flags = t.flags;
|
|
874
911
|
if ((flags & TypeFlags.Any) !== 0) {
|
|
@@ -1033,7 +1070,9 @@ export class NodeBuilder {
|
|
|
1033
1070
|
}
|
|
1034
1071
|
const objectFlags = t.objectFlags;
|
|
1035
1072
|
if ((objectFlags & ObjectFlags.Reference) !== 0) {
|
|
1036
|
-
|
|
1073
|
+
// Arrays and tuples are checked for cycles, as their element types can refer back to them.
|
|
1074
|
+
if (isArrayOrTupleType(c, t) || (t as TypeReference).node !== undefined)
|
|
1075
|
+
return this.visitAndTransformType(t, TransformKind.TypeReference);
|
|
1037
1076
|
return this.typeReferenceToTypeNode(t as TypeReference);
|
|
1038
1077
|
}
|
|
1039
1078
|
if ((flags & TypeFlags.TypeParameter) !== 0 || (objectFlags & ObjectFlags.ClassOrInterface) !== 0) {
|
|
@@ -1142,19 +1181,31 @@ export class NodeBuilder {
|
|
|
1142
1181
|
|
|
1143
1182
|
/** Writes `t` with `transform`, eliding its circular references; cached per enclosing declaration. */
|
|
1144
1183
|
visitAndTransformType(t: Type, transform: TransformKind): Node | undefined {
|
|
1145
|
-
|
|
1184
|
+
if (this.checkTruncationLength()) return this.createElidedInformationPlaceholder();
|
|
1185
|
+
const c = this.c;
|
|
1186
|
+
let typeId = t.id;
|
|
1187
|
+
const isArrayOrTuple = isArrayOrTupleType(c, t);
|
|
1188
|
+
// A deferred reference and the regular reference to the same array or tuple are one cycle identity.
|
|
1189
|
+
if (isArrayOrTuple) typeId = createTypeReference(c, (t as TypeReference).target!, getTypeArguments(c, t)).id;
|
|
1190
|
+
if (this.visitedTypes.has(typeId)) return this.createCyclicStructurePlaceholder();
|
|
1146
1191
|
const isConstructorObject =
|
|
1147
1192
|
(t.objectFlags & ObjectFlags.Anonymous) !== 0 &&
|
|
1148
1193
|
t.symbol !== undefined &&
|
|
1149
1194
|
(t.symbol.flags & SymbolFlags.Class) !== 0;
|
|
1150
1195
|
// Instantiations of one anonymous type share a symbol, so tracking symbols rather than
|
|
1151
|
-
// types catches circular references through them.
|
|
1196
|
+
// types catches circular references through them. Nesting of arrays and tuples, which share the Array
|
|
1197
|
+
// symbol or a tuple target, is not bounded by it. A deferred array or tuple reference is bounded by its
|
|
1198
|
+
// node, which stops a recursive alias whose type arguments grow at each level (`type R<T> = R<T[]>[]`).
|
|
1152
1199
|
let id: string | undefined = undefined;
|
|
1153
|
-
if (
|
|
1200
|
+
if (isArrayOrTuple) {
|
|
1201
|
+
const node = (t as TypeReference).node;
|
|
1202
|
+
if (node !== undefined) id = 'n' + getNodeId(node);
|
|
1203
|
+
} else if ((t.objectFlags & ObjectFlags.Reference) !== 0 && (t as TypeReference).node !== undefined)
|
|
1154
1204
|
id = 'n' + getNodeId((t as TypeReference).node!);
|
|
1155
1205
|
else if ((t.flags & TypeFlags.Conditional) !== 0) id = 'n' + getNodeId((t as ConditionalType).root.node);
|
|
1156
1206
|
else if (t.symbol !== undefined) id = (isConstructorObject ? 'c' : 's') + getSymbolId(t.symbol);
|
|
1157
|
-
|
|
1207
|
+
let key = typeId + ':' + this.flags + ':' + this.internalFlags;
|
|
1208
|
+
if (this.inferTypeParameters.length !== 0) key += ':' + typeListKey(this.inferTypeParameters);
|
|
1158
1209
|
if (this.enclosingDeclaration !== undefined) {
|
|
1159
1210
|
const cached = this.serializedTypes.get(getNodeId(this.enclosingDeclaration))?.get(key);
|
|
1160
1211
|
if (cached !== undefined) {
|
|
@@ -1165,10 +1216,27 @@ export class NodeBuilder {
|
|
|
1165
1216
|
return this.deepCloneNode(cached.node);
|
|
1166
1217
|
}
|
|
1167
1218
|
}
|
|
1219
|
+
// Growing type arguments can keep a reverse mapped type from repeating, so its expansion is also bounded by
|
|
1220
|
+
// its mapped type's declaration.
|
|
1221
|
+
let origin: string | undefined = undefined;
|
|
1222
|
+
let originDepth = 0;
|
|
1223
|
+
if ((t.objectFlags & ObjectFlags.ReverseMapped) !== 0) {
|
|
1224
|
+
origin = 'n' + getNodeId(((t as ReverseMappedType).mappedType as MappedType).declaration!);
|
|
1225
|
+
originDepth = this.symbolDepth.get(origin) ?? 0;
|
|
1226
|
+
if (originDepth >= 100) {
|
|
1227
|
+
this.truncating = true;
|
|
1228
|
+
return this.createElidedInformationPlaceholder();
|
|
1229
|
+
}
|
|
1230
|
+
this.symbolDepth.set(origin, originDepth + 1);
|
|
1231
|
+
}
|
|
1168
1232
|
let depth = 0;
|
|
1169
1233
|
if (id !== undefined) {
|
|
1170
1234
|
depth = this.symbolDepth.get(id) ?? 0;
|
|
1171
|
-
if (depth > 10)
|
|
1235
|
+
if (depth > 10) {
|
|
1236
|
+
this.truncating = true;
|
|
1237
|
+
if (origin !== undefined) this.symbolDepth.set(origin, originDepth);
|
|
1238
|
+
return this.createElidedInformationPlaceholder();
|
|
1239
|
+
}
|
|
1172
1240
|
this.symbolDepth.set(id, depth + 1);
|
|
1173
1241
|
}
|
|
1174
1242
|
this.visitedTypes.add(typeId);
|
|
@@ -1207,24 +1275,28 @@ export class NodeBuilder {
|
|
|
1207
1275
|
}
|
|
1208
1276
|
this.visitedTypes.delete(typeId);
|
|
1209
1277
|
if (id !== undefined) this.symbolDepth.set(id, depth);
|
|
1278
|
+
if (origin !== undefined) this.symbolDepth.set(origin, originDepth);
|
|
1210
1279
|
this.trackedSymbols = prevTrackedSymbols;
|
|
1211
1280
|
return result;
|
|
1212
1281
|
}
|
|
1213
1282
|
|
|
1214
1283
|
private typeToTypeNodeOrCircularityElision(t: Type): Node | undefined {
|
|
1215
1284
|
if ((t.flags & TypeFlags.Union) !== 0) {
|
|
1216
|
-
if (this.visitedTypes.has(t.id))
|
|
1217
|
-
if ((this.flags & NodeBuilderFlags.AllowAnonymousIdentifier) === 0) {
|
|
1218
|
-
this.encounteredError = true;
|
|
1219
|
-
this.tracker.reportCyclicStructureError();
|
|
1220
|
-
}
|
|
1221
|
-
return this.createElidedInformationPlaceholder();
|
|
1222
|
-
}
|
|
1285
|
+
if (this.visitedTypes.has(t.id)) return this.createCyclicStructurePlaceholder();
|
|
1223
1286
|
return this.visitAndTransformType(t, TransformKind.Type);
|
|
1224
1287
|
}
|
|
1225
1288
|
return this.typeToTypeNode(t);
|
|
1226
1289
|
}
|
|
1227
1290
|
|
|
1291
|
+
/** The placeholder for a circular reference; outside of display, it is an error. */
|
|
1292
|
+
private createCyclicStructurePlaceholder(): Node {
|
|
1293
|
+
if ((this.flags & NodeBuilderFlags.AllowAnonymousIdentifier) === 0) {
|
|
1294
|
+
this.encounteredError = true;
|
|
1295
|
+
this.tracker.reportCyclicStructureError();
|
|
1296
|
+
}
|
|
1297
|
+
return this.createElidedInformationPlaceholder();
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1228
1300
|
private conditionalTypeToTypeNode(t: ConditionalType): Node | undefined {
|
|
1229
1301
|
const c = this.c;
|
|
1230
1302
|
if (this.checkTruncationLength()) return this.createElidedInformationPlaceholder();
|
|
@@ -1438,7 +1510,8 @@ export class NodeBuilder {
|
|
|
1438
1510
|
private shouldWriteTypeOfFunctionSymbol(symbol: Symbol, typeId: number): Symbol | undefined {
|
|
1439
1511
|
const c = this.c;
|
|
1440
1512
|
let isStaticMethodSymbol = false;
|
|
1441
|
-
|
|
1513
|
+
// `typeof C.name` can only be written when the member's name is an identifier.
|
|
1514
|
+
if ((symbol.flags & SymbolFlags.Method) !== 0 && isIdentifierText(symbol.name))
|
|
1442
1515
|
for (const d of getDeclarations(symbol))
|
|
1443
1516
|
if (isStatic(d) && !hasLateBindableIndexSignature(c, d)) isStaticMethodSymbol = true;
|
|
1444
1517
|
let isNonLocalFunctionSymbol = false;
|
|
@@ -1525,8 +1598,18 @@ export class NodeBuilder {
|
|
|
1525
1598
|
const c = this.c;
|
|
1526
1599
|
const typeId = t.id;
|
|
1527
1600
|
const symbol = t.symbol;
|
|
1528
|
-
|
|
1529
|
-
|
|
1601
|
+
if (symbol === undefined) {
|
|
1602
|
+
// In declaration emit a reverse mapped type is written out, so it can be circular; for display, its
|
|
1603
|
+
// properties and index signatures use placeholders.
|
|
1604
|
+
if (
|
|
1605
|
+
(t.objectFlags & ObjectFlags.ReverseMapped) !== 0 &&
|
|
1606
|
+
(this.flags & NodeBuilderFlags.AllowAnonymousIdentifier) === 0
|
|
1607
|
+
) {
|
|
1608
|
+
if (this.visitedTypes.has(typeId)) return this.createCyclicStructurePlaceholder();
|
|
1609
|
+
return this.visitAndTransformType(t, TransformKind.ObjectType);
|
|
1610
|
+
}
|
|
1611
|
+
return this.createTypeNodeFromObjectType(t);
|
|
1612
|
+
}
|
|
1530
1613
|
if ((t.objectFlags & ObjectFlags.InstantiationExpressionType) !== 0) {
|
|
1531
1614
|
const existing = (t as InstantiationExpressionType).node;
|
|
1532
1615
|
// The node is unreliable for members of unions and intersections, so it's checked.
|
|
@@ -1535,13 +1618,13 @@ export class NodeBuilder {
|
|
|
1535
1618
|
existing.kind === SyntaxKind.TypeQuery &&
|
|
1536
1619
|
this.getTypeFromTypeNode(existing, false) === t
|
|
1537
1620
|
) {
|
|
1538
|
-
if (this.visitedTypes.has(typeId)) return this.
|
|
1621
|
+
if (this.visitedTypes.has(typeId)) return this.createCyclicStructurePlaceholder();
|
|
1539
1622
|
this.visitedTypes.add(typeId);
|
|
1540
1623
|
const typeNode = this.tryReuseExistingNonParameterTypeNode(existing, t, undefined, undefined);
|
|
1541
1624
|
this.visitedTypes.delete(typeId);
|
|
1542
1625
|
if (typeNode !== undefined) return typeNode;
|
|
1543
1626
|
}
|
|
1544
|
-
if (this.visitedTypes.has(typeId)) return this.
|
|
1627
|
+
if (this.visitedTypes.has(typeId)) return this.createCyclicStructurePlaceholder();
|
|
1545
1628
|
return this.visitAndTransformType(t, TransformKind.ObjectType);
|
|
1546
1629
|
}
|
|
1547
1630
|
const isInstanceType = isClassInstanceSide(c, t) ? SymbolFlags.Type : SymbolFlags.Value;
|
|
@@ -1557,7 +1640,7 @@ export class NodeBuilder {
|
|
|
1557
1640
|
// An anonymous type literal in a type alias is written as the alias.
|
|
1558
1641
|
const typeAlias = getTypeAliasForTypeLiteral(c, t);
|
|
1559
1642
|
if (typeAlias !== undefined) return symbolToTypeNode(this, typeAlias, SymbolFlags.Type, undefined);
|
|
1560
|
-
return this.
|
|
1643
|
+
return this.createCyclicStructurePlaceholder();
|
|
1561
1644
|
}
|
|
1562
1645
|
return this.visitAndTransformType(t, TransformKind.ObjectType);
|
|
1563
1646
|
}
|
|
@@ -1638,9 +1721,11 @@ export class NodeBuilder {
|
|
|
1638
1721
|
typeElements.push(this.signatureToSignatureDeclaration(signature, SyntaxKind.ConstructSignature, undefined));
|
|
1639
1722
|
}
|
|
1640
1723
|
for (const info of resolved.indexInfos) {
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1724
|
+
const typeNode =
|
|
1725
|
+
(t.objectFlags & ObjectFlags.ReverseMapped) !== 0 &&
|
|
1726
|
+
(this.flags & NodeBuilderFlags.AllowAnonymousIdentifier) !== 0
|
|
1727
|
+
? this.createElidedInformationPlaceholder()
|
|
1728
|
+
: undefined;
|
|
1644
1729
|
for (const element of this.indexInfoToObjectComputedNamesOrSignatureDeclaration(info, typeNode))
|
|
1645
1730
|
typeElements.push(element);
|
|
1646
1731
|
}
|
|
@@ -1691,7 +1776,9 @@ export class NodeBuilder {
|
|
|
1691
1776
|
|
|
1692
1777
|
private shouldUsePlaceholderForProperty(propertySymbol: Symbol): boolean {
|
|
1693
1778
|
// Placeholders for reverse mapped types (1) already being written, (2) nested in a mapping
|
|
1694
|
-
// over a non-anonymous type, or (3) nested deeply in the same mapped type.
|
|
1779
|
+
// over a non-anonymous type, or (3) nested deeply in the same mapped type. They are for display only:
|
|
1780
|
+
// declaration emit writes the types.
|
|
1781
|
+
if ((this.flags & NodeBuilderFlags.AllowAnonymousIdentifier) === 0) return false;
|
|
1695
1782
|
if ((propertySymbol.checkFlags & CheckFlags.ReverseMapped) === 0) return false;
|
|
1696
1783
|
const stack = this.reverseMappedStack;
|
|
1697
1784
|
if (stack.indexOf(propertySymbol) >= 0) return true;
|
|
@@ -1765,7 +1852,7 @@ export class NodeBuilder {
|
|
|
1765
1852
|
this.enclosingDeclaration =
|
|
1766
1853
|
propertySymbol.valueDeclaration ??
|
|
1767
1854
|
(declarationCount(propertySymbol) > 0 ? propertySymbol.declaration! : saveEnclosingDeclaration);
|
|
1768
|
-
const propertyName = getPropertyNameNodeForSymbol(this, propertySymbol);
|
|
1855
|
+
const propertyName = getPropertyNameNodeForSymbol(this, propertySymbol, saveEnclosingDeclaration);
|
|
1769
1856
|
this.enclosingDeclaration = saveEnclosingDeclaration;
|
|
1770
1857
|
this.approximateLength += symbolName(propertySymbol).length + 1;
|
|
1771
1858
|
if ((propertySymbol.flags & SymbolFlags.Accessor) !== 0) {
|
|
@@ -2495,6 +2582,9 @@ export class NodeBuilder {
|
|
|
2495
2582
|
declaration = symbol.valueDeclaration ?? (declarationCount(symbol) > 0 ? symbol.declaration! : undefined);
|
|
2496
2583
|
if (symbol === undefined && declaration !== undefined) symbol = getSymbolOfDeclaration(c, declaration);
|
|
2497
2584
|
let t = type;
|
|
2585
|
+
// A variable named by a binding pattern has no symbol.
|
|
2586
|
+
if (t === undefined && symbol === undefined && declaration !== undefined && isVariableLike(declaration))
|
|
2587
|
+
t = getTypeForVariableLikeDeclaration(c, declaration, false);
|
|
2498
2588
|
if (t === undefined && symbol !== undefined) {
|
|
2499
2589
|
t = this.enclosingSymbolTypes.get(getSymbolId(symbol));
|
|
2500
2590
|
if (t === undefined) {
|
|
@@ -2563,20 +2653,27 @@ export class NodeBuilder {
|
|
|
2563
2653
|
tryReuse &&
|
|
2564
2654
|
this.enclosingDeclaration !== undefined &&
|
|
2565
2655
|
declaration !== undefined &&
|
|
2566
|
-
symbol !== undefined &&
|
|
2567
2656
|
(isAccessorKind(declaration) ||
|
|
2568
2657
|
(hasInferredTypeKind(declaration) &&
|
|
2569
2658
|
(declaration.flags & NodeFlags.Synthesized) === 0 &&
|
|
2570
2659
|
(t.objectFlags & ObjectFlags.RequiresWidening) === 0))
|
|
2571
2660
|
) {
|
|
2572
|
-
const remove = this.addSymbolTypeToContext(symbol, t);
|
|
2661
|
+
const remove = symbol !== undefined ? this.addSymbolTypeToContext(symbol, t) : undefined;
|
|
2573
2662
|
let pt: PseudoType = isAccessorKind(declaration)
|
|
2574
2663
|
? pseudo.getTypeOfAccessor(declaration)
|
|
2575
2664
|
: pseudo.getTypeOfDeclaration(declaration);
|
|
2576
|
-
if (
|
|
2577
|
-
|
|
2665
|
+
if (
|
|
2666
|
+
pt.kind === PseudoTypeKind.NoResult &&
|
|
2667
|
+
declaration.kind === SyntaxKind.BinaryExpression &&
|
|
2668
|
+
symbol !== undefined
|
|
2669
|
+
) {
|
|
2670
|
+
// The first annotated assignment declares the type for the rest. A type alias's type isn't an annotation.
|
|
2578
2671
|
for (const d of getDeclarations(symbol))
|
|
2579
|
-
if (
|
|
2672
|
+
if (
|
|
2673
|
+
getType(d) !== undefined &&
|
|
2674
|
+
d.kind !== SyntaxKind.TypeAliasDeclaration &&
|
|
2675
|
+
d.kind !== SyntaxKind.JSTypeAliasDeclaration
|
|
2676
|
+
) {
|
|
2580
2677
|
pt = pseudo.getTypeOfDeclaration(d);
|
|
2581
2678
|
break;
|
|
2582
2679
|
}
|
|
@@ -2617,7 +2714,7 @@ export class NodeBuilder {
|
|
|
2617
2714
|
}
|
|
2618
2715
|
}
|
|
2619
2716
|
}
|
|
2620
|
-
remove();
|
|
2717
|
+
if (remove !== undefined) remove();
|
|
2621
2718
|
}
|
|
2622
2719
|
if (result === undefined) {
|
|
2623
2720
|
if (reportedInferenceFallback) {
|
|
@@ -3283,9 +3380,11 @@ export function typeToTypeNode(
|
|
|
3283
3380
|
flags: number,
|
|
3284
3381
|
internalFlags: NodeBuilderInternalFlags = NodeBuilderInternalFlags.None,
|
|
3285
3382
|
tracker: SymbolTracker | undefined = undefined,
|
|
3383
|
+
idToSymbol: Map<Node, Symbol> | undefined = undefined,
|
|
3286
3384
|
): Node | undefined {
|
|
3287
3385
|
const b = new NodeBuilder(c, enclosingDeclaration, flags, internalFlags, tracker);
|
|
3288
3386
|
b.pseudo = newPseudoChecker(c);
|
|
3387
|
+
b.idToSymbol = idToSymbol;
|
|
3289
3388
|
return b.finish(b.typeToTypeNode(type));
|
|
3290
3389
|
}
|
|
3291
3390
|
|
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
ModuleKind,
|
|
10
10
|
ModuleResolutionKind,
|
|
11
11
|
NewLineKind,
|
|
12
|
-
PollingKind,
|
|
13
12
|
ScriptTarget,
|
|
14
|
-
WatchDirectoryKind,
|
|
15
|
-
WatchFileKind,
|
|
16
13
|
} from './options.js';
|
|
17
14
|
import { Diagnostics, type DiagnosticMessage } from './diagnostics.js';
|
|
18
15
|
|
|
@@ -88,6 +85,7 @@ export const targetValues: EnumValues = new Map<string, number | string>([
|
|
|
88
85
|
['es2023', ScriptTarget.ES2023],
|
|
89
86
|
['es2024', ScriptTarget.ES2024],
|
|
90
87
|
['es2025', ScriptTarget.ES2025],
|
|
88
|
+
['es2026', ScriptTarget.ES2026],
|
|
91
89
|
['esnext', ScriptTarget.ESNext],
|
|
92
90
|
]);
|
|
93
91
|
|
|
@@ -124,6 +122,7 @@ export const libMap: EnumValues = new Map<string, number | string>([
|
|
|
124
122
|
['es2023', 'lib.es2023.d.ts'],
|
|
125
123
|
['es2024', 'lib.es2024.d.ts'],
|
|
126
124
|
['es2025', 'lib.es2025.d.ts'],
|
|
125
|
+
['es2026', 'lib.es2026.d.ts'],
|
|
127
126
|
['esnext', 'lib.esnext.d.ts'],
|
|
128
127
|
['dom', 'lib.dom.d.ts'],
|
|
129
128
|
['dom.iterable', 'lib.dom.iterable.d.ts'],
|
|
@@ -195,6 +194,13 @@ export const libMap: EnumValues = new Map<string, number | string>([
|
|
|
195
194
|
['es2025.iterator', 'lib.es2025.iterator.d.ts'],
|
|
196
195
|
['es2025.promise', 'lib.es2025.promise.d.ts'],
|
|
197
196
|
['es2025.regexp', 'lib.es2025.regexp.d.ts'],
|
|
197
|
+
['es2026.array', 'lib.es2026.array.d.ts'],
|
|
198
|
+
['es2026.collection', 'lib.es2026.collection.d.ts'],
|
|
199
|
+
['es2026.error', 'lib.es2026.error.d.ts'],
|
|
200
|
+
['es2026.iterator', 'lib.es2026.iterator.d.ts'],
|
|
201
|
+
['es2026.json', 'lib.es2026.json.d.ts'],
|
|
202
|
+
['es2026.math', 'lib.es2026.math.d.ts'],
|
|
203
|
+
['es2026.typedarrays', 'lib.es2026.typedarrays.d.ts'],
|
|
198
204
|
['esnext.asynciterable', 'lib.es2018.asynciterable.d.ts'],
|
|
199
205
|
['esnext.symbol', 'lib.es2019.symbol.d.ts'],
|
|
200
206
|
['esnext.bigint', 'lib.es2020.bigint.d.ts'],
|
|
@@ -203,18 +209,19 @@ export const libMap: EnumValues = new Map<string, number | string>([
|
|
|
203
209
|
['esnext.regexp', 'lib.es2024.regexp.d.ts'],
|
|
204
210
|
['esnext.string', 'lib.es2024.string.d.ts'],
|
|
205
211
|
['esnext.float16', 'lib.es2025.float16.d.ts'],
|
|
206
|
-
['esnext.
|
|
207
|
-
['esnext.
|
|
208
|
-
['esnext.
|
|
209
|
-
['esnext.
|
|
212
|
+
['esnext.array', 'lib.es2026.array.d.ts'],
|
|
213
|
+
['esnext.collection', 'lib.es2026.collection.d.ts'],
|
|
214
|
+
['esnext.error', 'lib.es2026.error.d.ts'],
|
|
215
|
+
['esnext.typedarrays', 'lib.es2026.typedarrays.d.ts'],
|
|
216
|
+
['esnext.iterator', 'lib.esnext.iterator.d.ts'],
|
|
217
|
+
['esnext.promise', 'lib.esnext.promise.d.ts'],
|
|
210
218
|
['esnext.date', 'lib.esnext.date.d.ts'],
|
|
211
219
|
['esnext.decorators', 'lib.esnext.decorators.d.ts'],
|
|
212
220
|
['esnext.disposable', 'lib.esnext.disposable.d.ts'],
|
|
213
|
-
['esnext.error', 'lib.esnext.error.d.ts'],
|
|
214
221
|
['esnext.intl', 'lib.esnext.intl.d.ts'],
|
|
222
|
+
['esnext.modulesource', 'lib.esnext.modulesource.d.ts'],
|
|
215
223
|
['esnext.sharedmemory', 'lib.esnext.sharedmemory.d.ts'],
|
|
216
224
|
['esnext.temporal', 'lib.esnext.temporal.d.ts'],
|
|
217
|
-
['esnext.typedarrays', 'lib.esnext.typedarrays.d.ts'],
|
|
218
225
|
['decorators', 'lib.decorators.d.ts'],
|
|
219
226
|
['decorators.legacy', 'lib.decorators.legacy.d.ts'],
|
|
220
227
|
]);
|
|
@@ -247,29 +254,6 @@ export const moduleDetectionValues: EnumValues = new Map<string, number | string
|
|
|
247
254
|
['force', ModuleDetectionKind.Force],
|
|
248
255
|
]);
|
|
249
256
|
|
|
250
|
-
export const watchFileValues: EnumValues = new Map<string, number | string>([
|
|
251
|
-
['fixedpollinginterval', WatchFileKind.FixedPollingInterval],
|
|
252
|
-
['prioritypollinginterval', WatchFileKind.PriorityPollingInterval],
|
|
253
|
-
['dynamicprioritypolling', WatchFileKind.DynamicPriorityPolling],
|
|
254
|
-
['fixedchunksizepolling', WatchFileKind.FixedChunkSizePolling],
|
|
255
|
-
['usefsevents', WatchFileKind.UseFsEvents],
|
|
256
|
-
['usefseventsonparentdirectory', WatchFileKind.UseFsEventsOnParentDirectory],
|
|
257
|
-
]);
|
|
258
|
-
|
|
259
|
-
export const watchDirectoryValues: EnumValues = new Map<string, number | string>([
|
|
260
|
-
['usefsevents', WatchDirectoryKind.UseFsEvents],
|
|
261
|
-
['fixedpollinginterval', WatchDirectoryKind.FixedPollingInterval],
|
|
262
|
-
['dynamicprioritypolling', WatchDirectoryKind.DynamicPriorityPolling],
|
|
263
|
-
['fixedchunksizepolling', WatchDirectoryKind.FixedChunkSizePolling],
|
|
264
|
-
]);
|
|
265
|
-
|
|
266
|
-
export const fallbackPollingValues: EnumValues = new Map<string, number | string>([
|
|
267
|
-
['fixedinterval', PollingKind.FixedInterval],
|
|
268
|
-
['priorityinterval', PollingKind.PriorityInterval],
|
|
269
|
-
['dynamicpriority', PollingKind.DynamicPriority],
|
|
270
|
-
['fixedchunksize', PollingKind.FixedChunkSize],
|
|
271
|
-
]);
|
|
272
|
-
|
|
273
257
|
/** `--build`, `-b`. Only valid as the first argument. */
|
|
274
258
|
export const buildOption: OptionDeclaration = {
|
|
275
259
|
name: 'build',
|
|
@@ -506,6 +490,15 @@ export const commonOptionsWithBuild: readonly OptionDeclaration[] = [
|
|
|
506
490
|
defaultValueMessage: Diagnostics.X_4_unless_singleThreaded_is_passed,
|
|
507
491
|
minValue: 1,
|
|
508
492
|
},
|
|
493
|
+
{
|
|
494
|
+
// Content mappers aren't supported; the option is accepted and has no effect.
|
|
495
|
+
name: 'runExternalCode',
|
|
496
|
+
kind: 'boolean',
|
|
497
|
+
isCommandLineOnly: true,
|
|
498
|
+
category: Diagnostics.Command_line_Options,
|
|
499
|
+
description: Diagnostics.Allow_loading_external_content_mapper_plugins_that_execute_code_during_compilation,
|
|
500
|
+
defaultValueDescription: false,
|
|
501
|
+
},
|
|
509
502
|
];
|
|
510
503
|
|
|
511
504
|
/** Options of `tsc` that `tsc --build` rejects. */
|
|
@@ -581,7 +574,7 @@ export const optionsForCompiler: readonly OptionDeclaration[] = [
|
|
|
581
574
|
category: Diagnostics.Language_and_Environment,
|
|
582
575
|
description:
|
|
583
576
|
Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
|
|
584
|
-
defaultValueDescription: ScriptTarget.
|
|
577
|
+
defaultValueDescription: ScriptTarget.ES2026,
|
|
585
578
|
affects: Affects.BuildInfo | Affects.SourceFile | Affects.ModuleResolution | Affects.Emit,
|
|
586
579
|
},
|
|
587
580
|
{
|
|
@@ -1426,75 +1419,6 @@ export const optionsForBuild: readonly OptionDeclaration[] = [
|
|
|
1426
1419
|
},
|
|
1427
1420
|
];
|
|
1428
1421
|
|
|
1429
|
-
/** Watch options, accepted on the command line and in `watchOptions`. */
|
|
1430
|
-
export const optionsForWatch: readonly OptionDeclaration[] = [
|
|
1431
|
-
{
|
|
1432
|
-
name: 'watchInterval',
|
|
1433
|
-
kind: 'number',
|
|
1434
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1435
|
-
},
|
|
1436
|
-
{
|
|
1437
|
-
name: 'watchFile',
|
|
1438
|
-
kind: 'enum',
|
|
1439
|
-
values: watchFileValues,
|
|
1440
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1441
|
-
description: Diagnostics.Specify_how_the_TypeScript_watch_mode_works,
|
|
1442
|
-
defaultValueDescription: WatchFileKind.UseFsEvents,
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
name: 'watchDirectory',
|
|
1446
|
-
kind: 'enum',
|
|
1447
|
-
values: watchDirectoryValues,
|
|
1448
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1449
|
-
description:
|
|
1450
|
-
Diagnostics.Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality,
|
|
1451
|
-
defaultValueDescription: WatchDirectoryKind.UseFsEvents,
|
|
1452
|
-
},
|
|
1453
|
-
{
|
|
1454
|
-
name: 'fallbackPolling',
|
|
1455
|
-
kind: 'enum',
|
|
1456
|
-
values: fallbackPollingValues,
|
|
1457
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1458
|
-
description:
|
|
1459
|
-
Diagnostics.Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers,
|
|
1460
|
-
defaultValueDescription: PollingKind.PriorityInterval,
|
|
1461
|
-
},
|
|
1462
|
-
{
|
|
1463
|
-
name: 'synchronousWatchDirectory',
|
|
1464
|
-
kind: 'boolean',
|
|
1465
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1466
|
-
description:
|
|
1467
|
-
Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
|
|
1468
|
-
defaultValueDescription: false,
|
|
1469
|
-
},
|
|
1470
|
-
{
|
|
1471
|
-
name: 'excludeDirectories',
|
|
1472
|
-
kind: 'list',
|
|
1473
|
-
element: {
|
|
1474
|
-
name: 'excludeDirectory',
|
|
1475
|
-
kind: 'string',
|
|
1476
|
-
isFilePath: true,
|
|
1477
|
-
extraValidation: 'spec',
|
|
1478
|
-
},
|
|
1479
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1480
|
-
description: Diagnostics.Remove_a_list_of_directories_from_the_watch_process,
|
|
1481
|
-
allowConfigDirTemplateSubstitution: true,
|
|
1482
|
-
},
|
|
1483
|
-
{
|
|
1484
|
-
name: 'excludeFiles',
|
|
1485
|
-
kind: 'list',
|
|
1486
|
-
element: {
|
|
1487
|
-
name: 'excludeFile',
|
|
1488
|
-
kind: 'string',
|
|
1489
|
-
isFilePath: true,
|
|
1490
|
-
extraValidation: 'spec',
|
|
1491
|
-
},
|
|
1492
|
-
category: Diagnostics.Watch_and_Build_Modes,
|
|
1493
|
-
description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing,
|
|
1494
|
-
allowConfigDirTemplateSubstitution: true,
|
|
1495
|
-
},
|
|
1496
|
-
];
|
|
1497
|
-
|
|
1498
1422
|
/** Keys of `typeAcquisition` in tsconfig.json. */
|
|
1499
1423
|
export const typeAcquisitionDeclarations: readonly OptionDeclaration[] = [
|
|
1500
1424
|
{
|
|
@@ -1547,6 +1471,13 @@ export class OptionNameMap {
|
|
|
1547
1471
|
return this.byName.get(name.toLowerCase());
|
|
1548
1472
|
}
|
|
1549
1473
|
|
|
1474
|
+
/** The declared names, for spelling suggestions. */
|
|
1475
|
+
names(): string[] {
|
|
1476
|
+
const names: string[] = [];
|
|
1477
|
+
for (const declaration of this.byName.values()) names.push(declaration.name);
|
|
1478
|
+
return names;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1550
1481
|
/** Looks up `name`, or with `allowShort` the option it abbreviates. */
|
|
1551
1482
|
find(name: string, allowShort: boolean): OptionDeclaration | undefined {
|
|
1552
1483
|
const lower = name.toLowerCase();
|
|
@@ -1557,4 +1488,3 @@ export class OptionNameMap {
|
|
|
1557
1488
|
|
|
1558
1489
|
export const compilerOptionsByName = new OptionNameMap(optionDeclarations);
|
|
1559
1490
|
export const buildOptionsByName = new OptionNameMap(buildOptionDeclarations);
|
|
1560
|
-
export const watchOptionsByName = new OptionNameMap(optionsForWatch);
|