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
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
UniqueESSymbolType,
|
|
55
55
|
emptyTypes,
|
|
56
56
|
newTypeMapper,
|
|
57
|
+
TypeParameter,
|
|
57
58
|
} from './checker-types.js';
|
|
58
59
|
import {
|
|
59
60
|
createArrayType,
|
|
@@ -115,6 +116,7 @@ import { checkExpressionWithTypeArguments } from './checker-calls.js';
|
|
|
115
116
|
import { getIntendedTypeFromJSDocTypeReference } from './checker-jsdoc.js';
|
|
116
117
|
import { getCombinedNodeFlags, hasSyntacticModifier } from './binder-utilities.js';
|
|
117
118
|
import { CheckFlags, getDeclarations, getSymbolId, type Symbol, SymbolFlags } from './symbol.js';
|
|
119
|
+
import { isStatement } from './printer/utilities.js';
|
|
118
120
|
|
|
119
121
|
export function getTypeFromTypeNode(c: Checker, node: Node): Type {
|
|
120
122
|
return getConditionalFlowTypeOfType(c, getTypeFromTypeNodeWorker(c, node), node);
|
|
@@ -417,13 +419,19 @@ function isValidESSymbolDeclaration(node: Node): boolean {
|
|
|
417
419
|
return false;
|
|
418
420
|
}
|
|
419
421
|
|
|
422
|
+
/** tsgo's ast.BlockIdOffset, the first id of the symbols a checker numbers. */
|
|
423
|
+
const symbolBlockIdOffset = 2 ** 48;
|
|
424
|
+
|
|
420
425
|
export function getESSymbolLikeTypeForNode(c: Checker, node: Node): Type {
|
|
421
426
|
if (isValidESSymbolDeclaration(node)) {
|
|
422
427
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
423
428
|
if (symbol !== undefined) {
|
|
424
429
|
let uniqueType = c.uniqueESSymbolTypes.get(symbol);
|
|
425
430
|
if (uniqueType === undefined) {
|
|
426
|
-
|
|
431
|
+
// tsgo numbers the symbols its checker keeps links for from 2^48 (ast.BlockIdOffset), and the name's length
|
|
432
|
+
// counts toward the node builder's truncation.
|
|
433
|
+
const name = '@' + symbol.name + '@' + (symbolBlockIdOffset + getSymbolId(symbol));
|
|
434
|
+
uniqueType = new UniqueESSymbolType(c.nextTypeId(), symbol, name);
|
|
427
435
|
c.uniqueESSymbolTypes.set(symbol, uniqueType);
|
|
428
436
|
}
|
|
429
437
|
return uniqueType;
|
|
@@ -442,7 +450,7 @@ function isConstTypeReference(node: Node): boolean {
|
|
|
442
450
|
);
|
|
443
451
|
}
|
|
444
452
|
|
|
445
|
-
function isAssertionExpression(node: Node | undefined): boolean {
|
|
453
|
+
export function isAssertionExpression(node: Node | undefined): boolean {
|
|
446
454
|
return (
|
|
447
455
|
node !== undefined && (node.kind === SyntaxKind.AsExpression || node.kind === SyntaxKind.TypeAssertionExpression)
|
|
448
456
|
);
|
|
@@ -456,12 +464,47 @@ export function getTypeFromTypeReference(c: Checker, node: Node): Type {
|
|
|
456
464
|
else
|
|
457
465
|
type =
|
|
458
466
|
getIntendedTypeFromJSDocTypeReference(c, node) ??
|
|
459
|
-
getTypeReferenceType(c, node, getSymbolFromTypeReference(c, node));
|
|
467
|
+
getDistributedTypeParameter(c, node, getTypeReferenceType(c, node, getSymbolFromTypeReference(c, node)));
|
|
460
468
|
c.resolvedTypes.set(node.id, type);
|
|
461
469
|
}
|
|
462
470
|
return type;
|
|
463
471
|
}
|
|
464
472
|
|
|
473
|
+
/**
|
|
474
|
+
* The distributed form of a type parameter `t` that `node` references inside a distributive conditional type on
|
|
475
|
+
* it (one whose check type is a bare reference to the type parameter), up to the enclosing statement; otherwise `t`.
|
|
476
|
+
*/
|
|
477
|
+
function getDistributedTypeParameter(c: Checker, node: Node, t: Type): Type {
|
|
478
|
+
if ((t.flags & TypeFlags.TypeParameter) === 0 || (t as TypeParameter).isDistributed) return t;
|
|
479
|
+
for (let n = node.parent; n !== undefined && !isStatement(n); n = n.parent) {
|
|
480
|
+
if (n.kind !== SyntaxKind.ConditionalType) continue;
|
|
481
|
+
const checkTypeNode = (n as ConditionalTypeNode).checkType;
|
|
482
|
+
if (isSimpleIdentifierTypeReference(checkTypeNode) && getSymbolFromTypeReference(c, checkTypeNode) === t.symbol)
|
|
483
|
+
return getDistributedTypeFromTypeParameter(c, t as TypeParameter);
|
|
484
|
+
}
|
|
485
|
+
return t;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function getDistributedTypeFromTypeParameter(c: Checker, t: TypeParameter): TypeParameter {
|
|
489
|
+
let distributed = t.distributedType;
|
|
490
|
+
if (distributed === undefined) {
|
|
491
|
+
distributed = c.newTypeParameter(t.symbol);
|
|
492
|
+
distributed.isDistributed = true;
|
|
493
|
+
distributed.constraint = t;
|
|
494
|
+
t.distributedType = distributed;
|
|
495
|
+
}
|
|
496
|
+
return distributed;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** A type reference that is a bare identifier without type arguments. */
|
|
500
|
+
function isSimpleIdentifierTypeReference(node: Node): boolean {
|
|
501
|
+
return (
|
|
502
|
+
node.kind === SyntaxKind.TypeReference &&
|
|
503
|
+
(node as TypeReferenceNode).typeName.kind === SyntaxKind.Identifier &&
|
|
504
|
+
(node as TypeReferenceNode).typeArguments === undefined
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
465
508
|
export function getSymbolFromTypeReference(c: Checker, node: Node): Symbol {
|
|
466
509
|
let symbol = c.resolvedSymbols.get(node.id);
|
|
467
510
|
if (symbol === undefined) {
|
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
IndexFlags,
|
|
38
38
|
IndexInfo,
|
|
39
39
|
type IndexType,
|
|
40
|
+
ConditionalResultKey,
|
|
41
|
+
DistributedConditional,
|
|
40
42
|
IndexedAccessType,
|
|
41
43
|
type IntersectionType,
|
|
42
44
|
type LiteralType,
|
|
@@ -61,6 +63,8 @@ import {
|
|
|
61
63
|
ReferenceArgs,
|
|
62
64
|
type TypeReference,
|
|
63
65
|
VarianceFlags,
|
|
66
|
+
getMappedType,
|
|
67
|
+
getNonDistributedTypeParameter,
|
|
64
68
|
} from './checker-types.js';
|
|
65
69
|
import {
|
|
66
70
|
UnionReduction,
|
|
@@ -119,7 +123,6 @@ import {
|
|
|
119
123
|
getIndexTypeOfType,
|
|
120
124
|
hasPropertiesOfType,
|
|
121
125
|
keepPropertiesOnly,
|
|
122
|
-
memberResolutionFlags,
|
|
123
126
|
} from './checker-members.js';
|
|
124
127
|
import {
|
|
125
128
|
getLateBoundSymbol,
|
|
@@ -328,13 +331,7 @@ function getIndexTypeForGenericType(c: Checker, t: Type, indexFlags: IndexFlags)
|
|
|
328
331
|
}
|
|
329
332
|
|
|
330
333
|
export function getLiteralTypeFromProperties(c: Checker, t: Type, include: TypeFlags, includeOrigin: boolean): Type {
|
|
331
|
-
const key =
|
|
332
|
-
'props' +
|
|
333
|
-
t.id +
|
|
334
|
-
':' +
|
|
335
|
-
include +
|
|
336
|
-
(includeOrigin ? 'o' : '') +
|
|
337
|
-
((memberResolutionFlags(c, t) & ObjectFlags.UnresolvedMembers) !== 0 ? 'u' : '');
|
|
334
|
+
const key = 'props' + t.id + ':' + include + (includeOrigin ? 'o' : '');
|
|
338
335
|
const cached = c.cachedTypes.get(key);
|
|
339
336
|
if (cached !== undefined) return cached;
|
|
340
337
|
const origin =
|
|
@@ -594,6 +591,7 @@ export function getIndexedAccessTypeOrUndefinedEx(
|
|
|
594
591
|
let t = c.indexedAccessTypes.get(key);
|
|
595
592
|
if (t === undefined) {
|
|
596
593
|
t = newIndexedAccessType(c, objectType, indexType, persistent);
|
|
594
|
+
if (c.indexedAccessKeyFlags !== undefined) c.indexedAccessKeyFlags.set(t, accessFlags);
|
|
597
595
|
t.alias = alias;
|
|
598
596
|
c.indexedAccessTypes.set(key, t);
|
|
599
597
|
}
|
|
@@ -1193,11 +1191,36 @@ export function getSimplifiedType(c: Checker, t: Type, writing: boolean): Type {
|
|
|
1193
1191
|
if ((t.flags & TypeFlags.IndexedAccess) !== 0)
|
|
1194
1192
|
return getSimplifiedIndexedAccessType(c, t as IndexedAccessType, writing);
|
|
1195
1193
|
if ((t.flags & TypeFlags.Conditional) !== 0) return getSimplifiedConditionalType(c, t as ConditionalType, writing);
|
|
1194
|
+
if ((t.flags & TypeFlags.Index) !== 0) return getSimplifiedIndexType(c, t as IndexType);
|
|
1195
|
+
return t;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/** Simplifies `keyof` a generic mapped type with an `as` clause to the type of the keys it produces. */
|
|
1199
|
+
function getSimplifiedIndexType(c: Checker, t: IndexType): Type {
|
|
1200
|
+
const target = t.target;
|
|
1201
|
+
if (
|
|
1202
|
+
isGenericMappedType(c, target) &&
|
|
1203
|
+
getNameTypeFromMappedType(c, target as MappedType) !== undefined &&
|
|
1204
|
+
!isMappedTypeWithKeyofConstraintDeclaration(c, target as MappedType)
|
|
1205
|
+
)
|
|
1206
|
+
return getIndexForMappedType(c, target as MappedType, IndexFlags.None);
|
|
1196
1207
|
return t;
|
|
1197
1208
|
}
|
|
1198
1209
|
|
|
1199
1210
|
/** Simplifies `T extends U ? T : never` and `T extends U ? never : T` when the outcome is known. */
|
|
1200
1211
|
function getSimplifiedConditionalType(c: Checker, t: ConditionalType, writing: boolean): Type {
|
|
1212
|
+
const key = cachedTypeKey(
|
|
1213
|
+
writing ? CachedTypeKind.SimplifiedConditionalForWriting : CachedTypeKind.SimplifiedConditionalForReading,
|
|
1214
|
+
t.id,
|
|
1215
|
+
);
|
|
1216
|
+
const cached = c.cachedTypesById.get(key);
|
|
1217
|
+
if (cached !== undefined) return cached;
|
|
1218
|
+
const result = getSimplifiedConditionalTypeWorker(c, t, writing);
|
|
1219
|
+
c.cachedTypesById.set(key, result);
|
|
1220
|
+
return result;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
function getSimplifiedConditionalTypeWorker(c: Checker, t: ConditionalType, writing: boolean): Type {
|
|
1201
1224
|
const checkType = t.checkType;
|
|
1202
1225
|
const extendsType = t.extendsType;
|
|
1203
1226
|
const trueType = getTrueTypeFromConditionalType(c, t);
|
|
@@ -1561,7 +1584,9 @@ export function getModifiersTypeFromMappedType(c: Checker, t: MappedType): Type
|
|
|
1561
1584
|
const declaredType = getTypeFromMappedTypeNode(c, t.declaration!) as MappedType;
|
|
1562
1585
|
const constraint = getConstraintTypeFromMappedType(c, declaredType);
|
|
1563
1586
|
const extended =
|
|
1564
|
-
(constraint.flags & TypeFlags.TypeParameter) !== 0
|
|
1587
|
+
(constraint.flags & TypeFlags.TypeParameter) !== 0
|
|
1588
|
+
? getConstraintOfTypeParameter(c, getNonDistributedTypeParameter(constraint))
|
|
1589
|
+
: constraint;
|
|
1565
1590
|
side.modifiersType =
|
|
1566
1591
|
extended !== undefined && (extended.flags & TypeFlags.Index) !== 0
|
|
1567
1592
|
? instantiateType(c, (extended as IndexType).target, t.mapper)
|
|
@@ -1584,17 +1609,12 @@ export function getActualTypeVariable(c: Checker, t: Type): Type {
|
|
|
1584
1609
|
if ((t.flags & TypeFlags.Substitution) !== 0) return getActualTypeVariable(c, (t as SubstitutionType).baseType);
|
|
1585
1610
|
if ((t.flags & TypeFlags.IndexedAccess) !== 0) {
|
|
1586
1611
|
const access = t as IndexedAccessType;
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
return getIndexedAccessType(
|
|
1592
|
-
c,
|
|
1593
|
-
getActualTypeVariable(c, access.objectType),
|
|
1594
|
-
getActualTypeVariable(c, access.indexType),
|
|
1595
|
-
);
|
|
1612
|
+
const objectType = getActualTypeVariable(c, access.objectType);
|
|
1613
|
+
const indexType = getActualTypeVariable(c, access.indexType);
|
|
1614
|
+
if (objectType !== access.objectType || indexType !== access.indexType)
|
|
1615
|
+
return getIndexedAccessType(c, objectType, indexType);
|
|
1596
1616
|
}
|
|
1597
|
-
return t;
|
|
1617
|
+
return getNonDistributedTypeParameter(t);
|
|
1598
1618
|
}
|
|
1599
1619
|
|
|
1600
1620
|
export const enum MappedTypeNameTypeKind {
|
|
@@ -1907,7 +1927,7 @@ function instantiateMappedTypeTemplate(
|
|
|
1907
1927
|
)
|
|
1908
1928
|
return getOptionalType(c, propType, true);
|
|
1909
1929
|
if (c.strictNullChecks && (modifiers & MappedTypeModifiers.ExcludeOptional) !== 0 && isOptional)
|
|
1910
|
-
return
|
|
1930
|
+
return removeMissingOrUndefinedType(c, propType);
|
|
1911
1931
|
return propType;
|
|
1912
1932
|
}
|
|
1913
1933
|
|
|
@@ -1975,21 +1995,41 @@ export function getConditionalTypeInstantiation(
|
|
|
1975
1995
|
if (result === undefined) {
|
|
1976
1996
|
const newMapper = newTypeMapper(root.outerTypeParameters, typeArguments);
|
|
1977
1997
|
const checkType = root.checkType;
|
|
1978
|
-
const distributionType = root.isDistributive ? getReducedType(c,
|
|
1998
|
+
const distributionType = root.isDistributive ? getReducedType(c, getMappedType(checkType, newMapper)) : undefined;
|
|
1979
1999
|
// Distributive conditional types distribute over unions.
|
|
1980
2000
|
if (
|
|
1981
2001
|
distributionType !== undefined &&
|
|
1982
2002
|
checkType !== distributionType &&
|
|
1983
2003
|
(distributionType.flags & (TypeFlags.Union | TypeFlags.Never)) !== 0
|
|
1984
|
-
)
|
|
2004
|
+
) {
|
|
2005
|
+
const distributed = c.distributedConditionals;
|
|
1985
2006
|
result = mapTypeWithAlias(
|
|
1986
2007
|
c,
|
|
1987
2008
|
distributionType,
|
|
1988
|
-
(u) =>
|
|
2009
|
+
(u) => {
|
|
2010
|
+
const member = getConditionalType(
|
|
2011
|
+
c,
|
|
2012
|
+
root,
|
|
2013
|
+
prependTypeMapping(checkType, u, newMapper),
|
|
2014
|
+
forConstraint,
|
|
2015
|
+
undefined,
|
|
2016
|
+
);
|
|
2017
|
+
// Sharing results (shared-results.ts) names a distributed member by the instantiation it is part of.
|
|
2018
|
+
if (distributed !== undefined && (member.flags & TypeFlags.Conditional) !== 0) {
|
|
2019
|
+
if (!distributed.has(member))
|
|
2020
|
+
distributed.set(member, new DistributedConditional(typeArguments.slice(), alias, tag, u));
|
|
2021
|
+
c.distributedByKey!.set(distributedKey(root.node.id, typeArguments, alias, tag, u), member);
|
|
2022
|
+
}
|
|
2023
|
+
return member;
|
|
2024
|
+
},
|
|
1989
2025
|
alias,
|
|
1990
2026
|
);
|
|
1991
|
-
else result = getConditionalType(c, root, newMapper, forConstraint, alias);
|
|
2027
|
+
} else result = getConditionalType(c, root, newMapper, forConstraint, alias);
|
|
1992
2028
|
root.instantiations.set(hash, typeArguments, alias, tag, result);
|
|
2029
|
+
// Sharing results names a conditional type made for another root (a tail or nested root) by this instantiation.
|
|
2030
|
+
const results = c.conditionalResults;
|
|
2031
|
+
if (results !== undefined && (result.flags & TypeFlags.Conditional) !== 0 && !results.has(result))
|
|
2032
|
+
results.set(result, new ConditionalResultKey(root, typeArguments.slice(), alias, tag));
|
|
1993
2033
|
}
|
|
1994
2034
|
return result;
|
|
1995
2035
|
}
|
|
@@ -2322,7 +2362,7 @@ function getTailRecursionRoot(c: Checker, newType: Type, newMapper: TypeMapper |
|
|
|
2322
2362
|
const typeArguments: Type[] = [];
|
|
2323
2363
|
for (const t of newRoot.outerTypeParameters) typeArguments.push(typeParamMapper.map(t));
|
|
2324
2364
|
const newRootMapper = newTypeMapper(newRoot.outerTypeParameters, typeArguments);
|
|
2325
|
-
const newCheckType = newRoot.isDistributive ?
|
|
2365
|
+
const newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined;
|
|
2326
2366
|
if (
|
|
2327
2367
|
newCheckType === undefined ||
|
|
2328
2368
|
newCheckType === newRoot.checkType ||
|
|
@@ -2435,7 +2475,7 @@ export function isTypeMatchedByTemplateLiteralType(
|
|
|
2435
2475
|
target: TemplateLiteralType,
|
|
2436
2476
|
compareTypes?: TemplateTypeComparer,
|
|
2437
2477
|
): boolean {
|
|
2438
|
-
const inferences = inferTypesFromTemplateLiteralType(c, source, target);
|
|
2478
|
+
const inferences = inferTypesFromTemplateLiteralType(c, source, target, compareTypes);
|
|
2439
2479
|
if (inferences === undefined) return false;
|
|
2440
2480
|
const compare = compareTypes ?? ((s: Type, t: Type) => isTypeAssignableTo(c, s, t));
|
|
2441
2481
|
for (let i = 0; i < inferences.length; i++)
|
|
@@ -2508,3 +2548,20 @@ export function mappedTypeTarget(t: MappedType): MappedType {
|
|
|
2508
2548
|
const target = t.target;
|
|
2509
2549
|
return target !== undefined ? (target as MappedType) : t;
|
|
2510
2550
|
}
|
|
2551
|
+
|
|
2552
|
+
/** The key of the member of a conditional type instantiation's distribution for one constituent (shared-results.ts). */
|
|
2553
|
+
export function distributedKey(
|
|
2554
|
+
root: number,
|
|
2555
|
+
typeArguments: readonly Type[],
|
|
2556
|
+
alias: TypeAlias | undefined,
|
|
2557
|
+
tag: number,
|
|
2558
|
+
constituent: Type,
|
|
2559
|
+
): string {
|
|
2560
|
+
let key = root + ':' + tag + ':' + constituent.id + ':';
|
|
2561
|
+
for (const t of typeArguments) key += t.id + ',';
|
|
2562
|
+
if (alias !== undefined) {
|
|
2563
|
+
key += '@' + getSymbolId(alias.symbol);
|
|
2564
|
+
for (const t of alias.typeArguments) key += ',' + t.id;
|
|
2565
|
+
}
|
|
2566
|
+
return key;
|
|
2567
|
+
}
|
|
@@ -167,8 +167,7 @@ export const enum ObjectFlags {
|
|
|
167
167
|
// Type references only.
|
|
168
168
|
IdenticalBaseTypeCalculated = 1 << 27,
|
|
169
169
|
IdenticalBaseTypeExists = 1 << 28,
|
|
170
|
-
|
|
171
|
-
FromTypeNode = 1 << 30,
|
|
170
|
+
FromTypeNode = 1 << 29,
|
|
172
171
|
/**
|
|
173
172
|
* The type keeps the state that is computed lazily in the checker's side tables instead of its
|
|
174
173
|
* own fields, which stay unset (`sideOf`). Every type with `TSC_TS_SIDE_STATE=1`.
|
|
@@ -183,6 +182,9 @@ export const enum ObjectFlags {
|
|
|
183
182
|
ContainsIntersections = 1 << 25,
|
|
184
183
|
IsUnknownLikeUnionComputed = 1 << 26,
|
|
185
184
|
IsUnknownLikeUnion = 1 << 27,
|
|
185
|
+
IsUniformEnumComputed = 1 << 28,
|
|
186
|
+
/** A primitive union in which no two literal constituents are comparable (`isUniformUnionType`). */
|
|
187
|
+
IsUniformEnum = 1 << 29,
|
|
186
188
|
// Intersections only.
|
|
187
189
|
IsNeverIntersectionComputed = 1 << 25,
|
|
188
190
|
IsNeverIntersection = 1 << 26,
|
|
@@ -361,6 +363,8 @@ export const enum CachedTypeKind {
|
|
|
361
363
|
PromisedTypeOfPromise,
|
|
362
364
|
Optional,
|
|
363
365
|
OptionalProperty,
|
|
366
|
+
SimplifiedConditionalForReading,
|
|
367
|
+
SimplifiedConditionalForWriting,
|
|
364
368
|
}
|
|
365
369
|
|
|
366
370
|
export function cachedTypeKey(kind: CachedTypeKind, id: number): number {
|
|
@@ -953,6 +957,62 @@ export class MemberNames {
|
|
|
953
957
|
}
|
|
954
958
|
}
|
|
955
959
|
|
|
960
|
+
/**
|
|
961
|
+
* The properties of the instantiations of one source without base types, as `getNamedMembers` orders them
|
|
962
|
+
* for `container`: the source positions of the named members in that order, and their names
|
|
963
|
+
* (`PropertyMembers`). The other members are skipped, so the named members are all of an instantiation's table.
|
|
964
|
+
*/
|
|
965
|
+
export class NamedMemberOrder {
|
|
966
|
+
readonly container: Symbol | undefined;
|
|
967
|
+
readonly positions: number[];
|
|
968
|
+
readonly names: MemberNames;
|
|
969
|
+
|
|
970
|
+
constructor(container: Symbol | undefined, positions: number[], names: MemberNames) {
|
|
971
|
+
this.container = container;
|
|
972
|
+
this.positions = positions;
|
|
973
|
+
this.names = names;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* What the pending instantiations of a declared members table share whatever their mapper: the members in
|
|
979
|
+
* table order, which of them are named (the others are skipped), and the members whose resolved type keeps
|
|
980
|
+
* them under any instantiation (`keepsSymbolTypeUnderInstantiation`), found so far.
|
|
981
|
+
*/
|
|
982
|
+
export class DeclaredMemberPlan {
|
|
983
|
+
readonly table: SymbolTable;
|
|
984
|
+
/**
|
|
985
|
+
* Whether instantiations build the table eagerly: tsgo's table wouldn't be keyed by symbol names, or an
|
|
986
|
+
* own member could be replaced by an inherited one. The other fields are then incomplete.
|
|
987
|
+
*/
|
|
988
|
+
readonly eager: boolean;
|
|
989
|
+
readonly members: Symbol[];
|
|
990
|
+
/** 1 for a named member, 0 for a skipped one, by position. */
|
|
991
|
+
readonly named: number[];
|
|
992
|
+
/** Bits by position: the member's type keeps it under instantiation. Set when found, never cleared. */
|
|
993
|
+
readonly keptByType: number[];
|
|
994
|
+
readonly hasOwnMembers: boolean;
|
|
995
|
+
readonly hasRequiredOwnMembers: boolean;
|
|
996
|
+
|
|
997
|
+
constructor(
|
|
998
|
+
table: SymbolTable,
|
|
999
|
+
eager: boolean,
|
|
1000
|
+
members: Symbol[],
|
|
1001
|
+
named: number[],
|
|
1002
|
+
hasOwnMembers: boolean,
|
|
1003
|
+
hasRequiredOwnMembers: boolean,
|
|
1004
|
+
) {
|
|
1005
|
+
this.table = table;
|
|
1006
|
+
this.eager = eager;
|
|
1007
|
+
this.members = members;
|
|
1008
|
+
this.named = named;
|
|
1009
|
+
this.keptByType = [];
|
|
1010
|
+
for (let i = 0; i < members.length; i += 32) this.keptByType.push(0);
|
|
1011
|
+
this.hasOwnMembers = hasOwnMembers;
|
|
1012
|
+
this.hasRequiredOwnMembers = hasRequiredOwnMembers;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
956
1016
|
/** A type with members: object types, unions and intersections. */
|
|
957
1017
|
export class StructuredType extends Type {
|
|
958
1018
|
membersValue: SymbolTable | undefined;
|
|
@@ -1060,6 +1120,10 @@ export class InterfaceType extends TypeReference {
|
|
|
1060
1120
|
declaredIndexInfos: IndexInfo[];
|
|
1061
1121
|
/** Positions of the declared members by name, for lazily instantiated members of instantiations. */
|
|
1062
1122
|
declaredMemberPositions: Map<string, number> | undefined;
|
|
1123
|
+
/** The property order of instantiations (`NamedMemberOrder`); null where it can't be cached. */
|
|
1124
|
+
namedMemberOrder: NamedMemberOrder | null | undefined;
|
|
1125
|
+
/** What pending instantiations of the declared members share (`DeclaredMemberPlan`). */
|
|
1126
|
+
declaredMemberPlan: DeclaredMemberPlan | undefined;
|
|
1063
1127
|
/** The member states of the last pending instantiation of the type's members (`sharedStates`). */
|
|
1064
1128
|
lastMemberStates: number[] | undefined;
|
|
1065
1129
|
/** The property names of the last instantiation whose members table is built on demand. */
|
|
@@ -1074,6 +1138,8 @@ export class InterfaceType extends TypeReference {
|
|
|
1074
1138
|
this.references = undefined;
|
|
1075
1139
|
this.checking = undefined;
|
|
1076
1140
|
this.declaredMemberPositions = undefined;
|
|
1141
|
+
this.namedMemberOrder = undefined;
|
|
1142
|
+
this.declaredMemberPlan = undefined;
|
|
1077
1143
|
this.lastMemberStates = undefined;
|
|
1078
1144
|
this.lastMemberNames = undefined;
|
|
1079
1145
|
this.allTypeParameters = emptyTypes;
|
|
@@ -1345,7 +1411,14 @@ export class TypeParameter extends Type {
|
|
|
1345
1411
|
target: Type | undefined;
|
|
1346
1412
|
mapper: TypeMapper | undefined;
|
|
1347
1413
|
isThisType: boolean;
|
|
1414
|
+
/**
|
|
1415
|
+
* A type parameter as referenced inside a distributive conditional type on it, which stands for each
|
|
1416
|
+
* constituent in turn; its constraint is the type parameter it was made from (`getDistributedTypeParameter`).
|
|
1417
|
+
*/
|
|
1418
|
+
isDistributed: boolean;
|
|
1348
1419
|
resolvedDefaultType: Type | undefined;
|
|
1420
|
+
/** The distributed form of this type parameter, made on first use. */
|
|
1421
|
+
distributedType: TypeParameter | undefined;
|
|
1349
1422
|
|
|
1350
1423
|
constructor(id: number, symbol: Symbol | undefined) {
|
|
1351
1424
|
super(TypeFlags.TypeParameter, ObjectFlags.None, id, symbol);
|
|
@@ -1353,10 +1426,29 @@ export class TypeParameter extends Type {
|
|
|
1353
1426
|
this.target = undefined;
|
|
1354
1427
|
this.mapper = undefined;
|
|
1355
1428
|
this.isThisType = false;
|
|
1429
|
+
this.isDistributed = false;
|
|
1356
1430
|
this.resolvedDefaultType = undefined;
|
|
1431
|
+
this.distributedType = undefined;
|
|
1357
1432
|
}
|
|
1358
1433
|
}
|
|
1359
1434
|
|
|
1435
|
+
/** Whether `t` is the distributed form of a type parameter. */
|
|
1436
|
+
export function isDistributedTypeParameter(t: Type): boolean {
|
|
1437
|
+
return (t.flags & TypeFlags.TypeParameter) !== 0 && (t as TypeParameter).isDistributed;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
/** The type parameter a distributed type parameter was made from; other types as they are. */
|
|
1441
|
+
export function getNonDistributedTypeParameter(t: Type): Type {
|
|
1442
|
+
return (t.flags & TypeFlags.TypeParameter) !== 0 && (t as TypeParameter).isDistributed
|
|
1443
|
+
? (t as TypeParameter).constraint!
|
|
1444
|
+
: t;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/** What `mapper` maps `t` to, a distributed type parameter as the type parameter it was made from. */
|
|
1448
|
+
export function getMappedType(t: Type, mapper: TypeMapper): Type {
|
|
1449
|
+
return mapper.map(getNonDistributedTypeParameter(t));
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1360
1452
|
/** `keyof T`. */
|
|
1361
1453
|
export class IndexType extends Type {
|
|
1362
1454
|
readonly target: Type;
|
|
@@ -1759,8 +1851,17 @@ export const enum TypeMapperKind {
|
|
|
1759
1851
|
Merged = 3,
|
|
1760
1852
|
}
|
|
1761
1853
|
|
|
1854
|
+
/** The id of the next mapper this thread creates. */
|
|
1855
|
+
let nextTypeMapperId = 0;
|
|
1856
|
+
|
|
1762
1857
|
/** Maps type parameters to types. Subclasses replace tsgo's function mappers. */
|
|
1763
1858
|
export abstract class TypeMapper {
|
|
1859
|
+
/**
|
|
1860
|
+
* A number for the mapper, unique among the mappers this thread creates (until it wraps at 2^31), so the
|
|
1861
|
+
* stack of active mappers can be searched by id instead of by reference.
|
|
1862
|
+
*/
|
|
1863
|
+
readonly id: number = (nextTypeMapperId = (nextTypeMapperId + 1) | 0);
|
|
1864
|
+
|
|
1764
1865
|
abstract map(type: Type): Type;
|
|
1765
1866
|
|
|
1766
1867
|
kind(): TypeMapperKind {
|
|
@@ -1956,12 +2057,12 @@ export function mergeTypeMappers(m1: TypeMapper | undefined, m2: TypeMapper): Ty
|
|
|
1956
2057
|
}
|
|
1957
2058
|
|
|
1958
2059
|
export function prependTypeMapping(source: Type, target: Type, mapper: TypeMapper | undefined): TypeMapper {
|
|
1959
|
-
const simple = new SimpleTypeMapper(source, target);
|
|
2060
|
+
const simple = new SimpleTypeMapper(getNonDistributedTypeParameter(source), target);
|
|
1960
2061
|
return mapper === undefined ? simple : new MergedTypeMapper(simple, mapper);
|
|
1961
2062
|
}
|
|
1962
2063
|
|
|
1963
2064
|
export function appendTypeMapping(mapper: TypeMapper | undefined, source: Type, target: Type): TypeMapper {
|
|
1964
|
-
const simple = new SimpleTypeMapper(source, target);
|
|
2065
|
+
const simple = new SimpleTypeMapper(getNonDistributedTypeParameter(source), target);
|
|
1965
2066
|
return mapper === undefined ? simple : new MergedTypeMapper(mapper, simple);
|
|
1966
2067
|
}
|
|
1967
2068
|
|
|
@@ -2129,6 +2230,16 @@ export class SymbolLinks implements ProgramLifetime {
|
|
|
2129
2230
|
this.rare().enumChecked = value;
|
|
2130
2231
|
}
|
|
2131
2232
|
|
|
2233
|
+
get mergedExportsChecked(): boolean {
|
|
2234
|
+
const rare = this.rareLinks;
|
|
2235
|
+
return rare === undefined ? false : rare.mergedExportsChecked;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
set mergedExportsChecked(value: boolean) {
|
|
2239
|
+
if (value === false && this.rareLinks === undefined) return;
|
|
2240
|
+
this.rare().mergedExportsChecked = value;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2132
2243
|
get variances(): VarianceFlags[] | undefined {
|
|
2133
2244
|
const rare = this.rareLinks;
|
|
2134
2245
|
return rare === undefined ? undefined : rare.variances;
|
|
@@ -2238,6 +2349,7 @@ export class RareSymbolLinks implements ProgramLifetime {
|
|
|
2238
2349
|
indexSignaturesChecked: boolean;
|
|
2239
2350
|
typeParametersChecked: boolean;
|
|
2240
2351
|
enumChecked: boolean;
|
|
2352
|
+
mergedExportsChecked: boolean;
|
|
2241
2353
|
variances: VarianceFlags[] | undefined;
|
|
2242
2354
|
// Assignment tracking
|
|
2243
2355
|
lastAssignmentPos: number;
|
|
@@ -2265,6 +2377,7 @@ export class RareSymbolLinks implements ProgramLifetime {
|
|
|
2265
2377
|
this.indexSignaturesChecked = false;
|
|
2266
2378
|
this.typeParametersChecked = false;
|
|
2267
2379
|
this.enumChecked = false;
|
|
2380
|
+
this.mergedExportsChecked = false;
|
|
2268
2381
|
this.variances = undefined;
|
|
2269
2382
|
this.lastAssignmentPos = 0;
|
|
2270
2383
|
this.hasDefiniteAssignment = false;
|
|
@@ -2518,3 +2631,33 @@ export class RareNodeLinks implements ProgramLifetime {
|
|
|
2518
2631
|
this.mentionsArguments = 0;
|
|
2519
2632
|
}
|
|
2520
2633
|
}
|
|
2634
|
+
|
|
2635
|
+
/** A conditional type made as a member of a distribution: the instantiation's key, and the constituent it is for. */
|
|
2636
|
+
export class DistributedConditional {
|
|
2637
|
+
readonly typeArguments: Type[];
|
|
2638
|
+
readonly alias: TypeAlias | undefined;
|
|
2639
|
+
readonly tag: number;
|
|
2640
|
+
readonly constituent: Type;
|
|
2641
|
+
|
|
2642
|
+
constructor(typeArguments: Type[], alias: TypeAlias | undefined, tag: number, constituent: Type) {
|
|
2643
|
+
this.typeArguments = typeArguments;
|
|
2644
|
+
this.alias = alias;
|
|
2645
|
+
this.tag = tag;
|
|
2646
|
+
this.constituent = constituent;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
/** The instantiation of a conditional type whose result is a conditional type: its root and key. */
|
|
2651
|
+
export class ConditionalResultKey {
|
|
2652
|
+
readonly root: ConditionalRoot;
|
|
2653
|
+
readonly typeArguments: Type[];
|
|
2654
|
+
readonly alias: TypeAlias | undefined;
|
|
2655
|
+
readonly tag: number;
|
|
2656
|
+
|
|
2657
|
+
constructor(root: ConditionalRoot, typeArguments: Type[], alias: TypeAlias | undefined, tag: number) {
|
|
2658
|
+
this.root = root;
|
|
2659
|
+
this.typeArguments = typeArguments;
|
|
2660
|
+
this.alias = alias;
|
|
2661
|
+
this.tag = tag;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
@@ -53,7 +53,6 @@ import { SyntaxKind } from './syntax-kind.js';
|
|
|
53
53
|
import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
|
|
54
54
|
import { getResolvedSymbol } from './checker-expressions.js';
|
|
55
55
|
import { skipTrivia } from './scanner.js';
|
|
56
|
-
import { getContainingFunctionOrClassStaticBlock } from './checker-grammar.js';
|
|
57
56
|
import { nodeCanBeDecorated } from './checker-decorators.js';
|
|
58
57
|
import { symbolToString } from './type-printer.js';
|
|
59
58
|
import type { Type } from './checker-types.js';
|
|
@@ -248,20 +247,14 @@ class PotentiallyUnusedCollector extends NodeVisitor {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
/**
|
|
251
|
-
* Whether the checker skips the children of `node`: a
|
|
252
|
-
*
|
|
253
|
-
*
|
|
250
|
+
* Whether the checker skips the children of `node`: a decorator of a declaration that can't be decorated
|
|
251
|
+
* is reported as an error and not checked further. (The expression of a `return` outside a function
|
|
252
|
+
* body, or in a class static block, is still checked.)
|
|
254
253
|
*/
|
|
255
254
|
private isUnchecked(node: Node): boolean {
|
|
256
|
-
if (node.kind
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
if (node.kind === SyntaxKind.Decorator) {
|
|
261
|
-
const declaration = node.parent!;
|
|
262
|
-
return !nodeCanBeDecorated(this.legacyDecorators, declaration, declaration.parent, declaration.parent?.parent);
|
|
263
|
-
}
|
|
264
|
-
return false;
|
|
255
|
+
if (node.kind !== SyntaxKind.Decorator) return false;
|
|
256
|
+
const declaration = node.parent!;
|
|
257
|
+
return !nodeCanBeDecorated(this.legacyDecorators, declaration, declaration.parent, declaration.parent?.parent);
|
|
265
258
|
}
|
|
266
259
|
}
|
|
267
260
|
|
|
@@ -273,7 +266,8 @@ function isPotentiallyUnusedContainer(node: Node): boolean {
|
|
|
273
266
|
case SyntaxKind.CaseBlock:
|
|
274
267
|
case SyntaxKind.ForStatement:
|
|
275
268
|
case SyntaxKind.ForInStatement:
|
|
276
|
-
case SyntaxKind.ForOfStatement:
|
|
269
|
+
case SyntaxKind.ForOfStatement:
|
|
270
|
+
case SyntaxKind.ClassStaticBlockDeclaration: {
|
|
277
271
|
const locals = getLocals(node);
|
|
278
272
|
return locals !== undefined && locals.size !== 0;
|
|
279
273
|
}
|
|
@@ -319,6 +313,7 @@ function checkUnusedIdentifiersOfNode(c: Checker, node: Node): void {
|
|
|
319
313
|
case SyntaxKind.ForStatement:
|
|
320
314
|
case SyntaxKind.ForInStatement:
|
|
321
315
|
case SyntaxKind.ForOfStatement:
|
|
316
|
+
case SyntaxKind.ClassStaticBlockDeclaration:
|
|
322
317
|
checkUnusedLocalsAndParameters(c, node);
|
|
323
318
|
return;
|
|
324
319
|
case SyntaxKind.Constructor:
|