tsc-ts 0.0.10 → 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 +1 -1
- 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 +20 -15
- package/dist/api/compiler/ast.js +1023 -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 +173 -123
- 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 +469 -438
- 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 -113
- 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 +210 -74
- 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 +137 -34
- 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 +93 -31
- package/dist/api/compiler/checker.js +143 -35
- 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 +19 -4
- package/dist/api/compiler/compile-program.js +45 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- 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 +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- 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/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 +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -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 +1 -0
- package/dist/api/compiler/printer/printer.js +303 -281
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -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 +2 -0
- package/dist/api/compiler/program.js +69 -57
- 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 +337 -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 +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- 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 +55 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- 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 +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- 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 +197 -55
- 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 +120 -21
- 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 +168 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +51 -25
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- 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 +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +86 -18
- 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 +197 -8
- package/src/compiler/parallel-emit.ts +1 -1
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -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 +35 -14
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -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 +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +19 -2
- 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 +3 -0
- package/src/compiler/tsc-cli.ts +2 -0
- package/src/compiler/tsc-compile.ts +7 -2
- 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
|
@@ -50,6 +50,9 @@ import {
|
|
|
50
50
|
newTypeMapper,
|
|
51
51
|
SimpleTypeMapper,
|
|
52
52
|
type TypeMapper,
|
|
53
|
+
isDistributedTypeParameter,
|
|
54
|
+
type TypeParameter,
|
|
55
|
+
type SymbolLinks,
|
|
53
56
|
} from './checker-types.js';
|
|
54
57
|
import { InferenceFlags, InferencePriority, createInferenceContext, inferTypes } from './checker-inference.js';
|
|
55
58
|
import {
|
|
@@ -94,6 +97,7 @@ import {
|
|
|
94
97
|
createNormalizedTypeReference,
|
|
95
98
|
typeListKey,
|
|
96
99
|
getRegularTypeOfLiteralType,
|
|
100
|
+
compareSymbols,
|
|
97
101
|
} from './checker-type-factory.js';
|
|
98
102
|
import {
|
|
99
103
|
findApplicableIndexInfo,
|
|
@@ -236,9 +240,8 @@ export const enum RelationComparisonResult {
|
|
|
236
240
|
ReportsUnmeasurable = 1 << 3,
|
|
237
241
|
ReportsUnreliable = 1 << 4,
|
|
238
242
|
ComplexityOverflow = 1 << 5,
|
|
239
|
-
StackDepthOverflow = 1 << 6,
|
|
240
243
|
ReportsMask = ReportsUnmeasurable | ReportsUnreliable,
|
|
241
|
-
Overflow = ComplexityOverflow
|
|
244
|
+
Overflow = ComplexityOverflow,
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
/**
|
|
@@ -263,25 +266,46 @@ export class Relation {
|
|
|
263
266
|
}
|
|
264
267
|
}
|
|
265
268
|
|
|
266
|
-
|
|
269
|
+
/** Sets the result of `key`, and returns whether the key is new. */
|
|
270
|
+
set(key: number, result: number): boolean {
|
|
267
271
|
const keys = this.keys;
|
|
268
272
|
const mask = keys.length - 1;
|
|
269
273
|
for (let i = relationSlot(key) & mask; ; i = (i + 1) & mask) {
|
|
270
274
|
const k = keys[i]!;
|
|
271
275
|
if (k === key) {
|
|
272
276
|
this.results[i] = result;
|
|
273
|
-
return;
|
|
277
|
+
return false;
|
|
274
278
|
}
|
|
275
279
|
if (k === 0) {
|
|
276
280
|
keys[i] = key;
|
|
277
281
|
this.results[i] = result;
|
|
278
282
|
this.count++;
|
|
279
283
|
if (this.count * 4 > keys.length * 3) this.grow();
|
|
280
|
-
return;
|
|
284
|
+
return true;
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
287
|
}
|
|
284
288
|
|
|
289
|
+
/** Removes `key`, moving later entries of its probe run back so lookups still find them. */
|
|
290
|
+
delete(key: number): void {
|
|
291
|
+
const keys = this.keys;
|
|
292
|
+
const results = this.results;
|
|
293
|
+
const mask = keys.length - 1;
|
|
294
|
+
let i = relationSlot(key) & mask;
|
|
295
|
+
for (; keys[i] !== key; i = (i + 1) & mask) if (keys[i] === 0) return;
|
|
296
|
+
for (let j = (i + 1) & mask; keys[j] !== 0; j = (j + 1) & mask) {
|
|
297
|
+
// An entry stays where it is when its home slot is cyclically after the freed slot and at or before it.
|
|
298
|
+
const home = relationSlot(keys[j]!) & mask;
|
|
299
|
+
if (i <= j ? i < home && home <= j : i < home || home <= j) continue;
|
|
300
|
+
keys[i] = keys[j]!;
|
|
301
|
+
results[i] = results[j]!;
|
|
302
|
+
i = j;
|
|
303
|
+
}
|
|
304
|
+
keys[i] = 0;
|
|
305
|
+
results[i] = 0;
|
|
306
|
+
this.count--;
|
|
307
|
+
}
|
|
308
|
+
|
|
285
309
|
size(): number {
|
|
286
310
|
return this.count;
|
|
287
311
|
}
|
|
@@ -1010,8 +1034,25 @@ export function checkTypeRelatedTo(
|
|
|
1010
1034
|
// Nested checks (from resolving types during the relation) find no spare and allocate their own.
|
|
1011
1035
|
const r = c.spareRelater ?? new Relater(c, relation, errorNode);
|
|
1012
1036
|
c.spareRelater = undefined;
|
|
1037
|
+
const relationCount = Math.trunc((16000000 - relation.size()) / 8);
|
|
1038
|
+
if (errorNode !== undefined) {
|
|
1039
|
+
// Relate without reporting first: reporting builds a message for every comparison that fails on the way,
|
|
1040
|
+
// even when the relation holds. When the relation fails, the results this pass added are removed, since
|
|
1041
|
+
// the comparisons it assumed related while comparing would change which failure the report elaborates.
|
|
1042
|
+
r.reset(relation, undefined);
|
|
1043
|
+
r.relationCount = relationCount;
|
|
1044
|
+
const addedKeys: number[] = [];
|
|
1045
|
+
r.addedKeys = addedKeys;
|
|
1046
|
+
const quiet = r.isRelatedToEx(source, target, RecursionFlags.Both, false, undefined, IntersectionState.None);
|
|
1047
|
+
r.addedKeys = undefined;
|
|
1048
|
+
if (quiet !== Ternary.False && !r.overflow) {
|
|
1049
|
+
c.spareRelater = r;
|
|
1050
|
+
return true;
|
|
1051
|
+
}
|
|
1052
|
+
for (const key of addedKeys) relation.delete(key);
|
|
1053
|
+
}
|
|
1013
1054
|
r.reset(relation, errorNode);
|
|
1014
|
-
r.relationCount =
|
|
1055
|
+
r.relationCount = relationCount;
|
|
1015
1056
|
const result = r.isRelatedToEx(
|
|
1016
1057
|
source,
|
|
1017
1058
|
target,
|
|
@@ -1023,20 +1064,13 @@ export function checkTypeRelatedTo(
|
|
|
1023
1064
|
if (r.overflow) {
|
|
1024
1065
|
// Remember the overflow so it isn't attempted again.
|
|
1025
1066
|
const key = getRelationKey(c, source, target, IntersectionState.None, relation === c.identityRelation, false).key;
|
|
1026
|
-
relation.set(
|
|
1027
|
-
key,
|
|
1028
|
-
RelationComparisonResult.Failed |
|
|
1029
|
-
(r.relationCount <= 0
|
|
1030
|
-
? RelationComparisonResult.ComplexityOverflow
|
|
1031
|
-
: RelationComparisonResult.StackDepthOverflow),
|
|
1032
|
-
);
|
|
1033
|
-
const message =
|
|
1034
|
-
r.relationCount <= 0
|
|
1035
|
-
? Diagnostics.Excessive_complexity_comparing_types_0_and_1
|
|
1036
|
-
: Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
|
|
1067
|
+
relation.set(key, RelationComparisonResult.Failed | RelationComparisonResult.ComplexityOverflow);
|
|
1037
1068
|
reportDiagnostic(
|
|
1038
1069
|
c,
|
|
1039
|
-
createDiagnosticForNode(errorNode ?? c.currentNode,
|
|
1070
|
+
createDiagnosticForNode(errorNode ?? c.currentNode, Diagnostics.Excessive_complexity_comparing_types_0_and_1, [
|
|
1071
|
+
typeToString(c, source),
|
|
1072
|
+
typeToString(c, target),
|
|
1073
|
+
]),
|
|
1040
1074
|
diagnosticOutput,
|
|
1041
1075
|
);
|
|
1042
1076
|
} else if (r.errorChain !== undefined) {
|
|
@@ -1150,6 +1184,8 @@ export class Relater extends TypeComparer {
|
|
|
1150
1184
|
expandingFlags: ExpandingFlags = ExpandingFlags.None;
|
|
1151
1185
|
overflow = false;
|
|
1152
1186
|
relationCount = 0;
|
|
1187
|
+
/** The keys this check added to the relation, while relating without reporting first. */
|
|
1188
|
+
addedKeys: number[] | undefined = undefined;
|
|
1153
1189
|
/** The intersection state passed to `compare` during signature comparisons. */
|
|
1154
1190
|
signatureIntersectionState: IntersectionState = IntersectionState.None;
|
|
1155
1191
|
// What `relateVariances` changes in its caller's state when it falls back to structure.
|
|
@@ -1681,13 +1717,11 @@ export class Relater extends TypeComparer {
|
|
|
1681
1717
|
} else {
|
|
1682
1718
|
c.reliabilityFlags |=
|
|
1683
1719
|
entry & (RelationComparisonResult.ReportsUnmeasurable | RelationComparisonResult.ReportsUnreliable);
|
|
1684
|
-
if (reportErrors && (entry & RelationComparisonResult.Overflow) !== 0)
|
|
1685
|
-
|
|
1686
|
-
(
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
this.reportError(message, [typeToString(c, source), typeToString(c, target)]);
|
|
1690
|
-
}
|
|
1720
|
+
if (reportErrors && (entry & RelationComparisonResult.Overflow) !== 0)
|
|
1721
|
+
this.reportError(Diagnostics.Excessive_complexity_comparing_types_0_and_1, [
|
|
1722
|
+
typeToString(c, source),
|
|
1723
|
+
typeToString(c, target),
|
|
1724
|
+
]);
|
|
1691
1725
|
return (entry & RelationComparisonResult.Succeeded) !== 0 ? Ternary.True : Ternary.False;
|
|
1692
1726
|
}
|
|
1693
1727
|
}
|
|
@@ -1710,10 +1744,9 @@ export class Relater extends TypeComparer {
|
|
|
1710
1744
|
}
|
|
1711
1745
|
const sourceDepth = this.sourceDepth;
|
|
1712
1746
|
const targetDepth = this.targetDepth;
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
}
|
|
1747
|
+
// A backstop for infinite recursion that isDeeplyNestedType misses, which also stops relating the exceedingly
|
|
1748
|
+
// rare types that are truly more than 100 levels deep.
|
|
1749
|
+
if (sourceDepth === 100 || targetDepth === 100) return Ternary.Maybe;
|
|
1717
1750
|
const maybeStart = this.maybeKeys.length;
|
|
1718
1751
|
this.maybeKeys.push(id);
|
|
1719
1752
|
this.maybeKeysSet.add(id);
|
|
@@ -1754,18 +1787,22 @@ export class Relater extends TypeComparer {
|
|
|
1754
1787
|
}
|
|
1755
1788
|
} else {
|
|
1756
1789
|
// False under assumptions is false without them.
|
|
1757
|
-
this.
|
|
1790
|
+
this.record(id, RelationComparisonResult.Failed | propagatingVarianceFlags);
|
|
1758
1791
|
this.relationCount--;
|
|
1759
1792
|
this.resetMaybeStack(maybeStart, propagatingVarianceFlags, false);
|
|
1760
1793
|
}
|
|
1761
1794
|
return result;
|
|
1762
1795
|
}
|
|
1763
1796
|
|
|
1797
|
+
record(key: number, result: number): void {
|
|
1798
|
+
if (this.relation.set(key, result) && this.addedKeys !== undefined) this.addedKeys.push(key);
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1764
1801
|
resetMaybeStack(maybeStart: number, propagatingVarianceFlags: number, markAllAsSucceeded: boolean): void {
|
|
1765
1802
|
for (let i = maybeStart; i < this.maybeKeys.length; i++) {
|
|
1766
1803
|
this.maybeKeysSet.delete(this.maybeKeys[i]!);
|
|
1767
1804
|
if (markAllAsSucceeded) {
|
|
1768
|
-
this.
|
|
1805
|
+
this.record(this.maybeKeys[i]!, RelationComparisonResult.Succeeded | propagatingVarianceFlags);
|
|
1769
1806
|
this.relationCount--;
|
|
1770
1807
|
}
|
|
1771
1808
|
}
|
|
@@ -2624,7 +2661,7 @@ export class Relater extends TypeComparer {
|
|
|
2624
2661
|
? this.isRelatedTo(s, t, RecursionFlags.Both, false)
|
|
2625
2662
|
: compareTypesIdentical(c, s, t);
|
|
2626
2663
|
else {
|
|
2627
|
-
if (c.
|
|
2664
|
+
if (c.varianceStack.length !== 0 && (varianceFlags & VarianceFlags.Unreliable) !== 0)
|
|
2628
2665
|
instantiateType(c, s, c.reportUnreliableMapper);
|
|
2629
2666
|
if (variance === VarianceFlags.Covariant)
|
|
2630
2667
|
related = this.isRelatedToEx(s, t, RecursionFlags.Both, reportErrors, undefined, intersectionState);
|
|
@@ -2708,7 +2745,8 @@ export class Relater extends TypeComparer {
|
|
|
2708
2745
|
const sourceArity = getTypeReferenceArity(source);
|
|
2709
2746
|
const targetArity = getTypeReferenceArity(target);
|
|
2710
2747
|
const sourceRest = isTupleType(source) ? (tupleTargetOf(source).combinedFlags & ElementFlags.Rest) !== 0 : true;
|
|
2711
|
-
const targetHasRestElement = (targetTuple.combinedFlags & ElementFlags.
|
|
2748
|
+
const targetHasRestElement = (targetTuple.combinedFlags & ElementFlags.Rest) !== 0;
|
|
2749
|
+
const targetHasVariableElement = (targetTuple.combinedFlags & ElementFlags.Variable) !== 0;
|
|
2712
2750
|
const sourceMinLength = isTupleType(source) ? tupleTargetOf(source).minLength : 0;
|
|
2713
2751
|
const targetMinLength = targetTuple.minLength;
|
|
2714
2752
|
if (!sourceRest && sourceArity < targetMinLength) {
|
|
@@ -2719,7 +2757,7 @@ export class Relater extends TypeComparer {
|
|
|
2719
2757
|
]);
|
|
2720
2758
|
return Ternary.False;
|
|
2721
2759
|
}
|
|
2722
|
-
if (!
|
|
2760
|
+
if (!targetHasVariableElement && targetArity < sourceMinLength) {
|
|
2723
2761
|
if (reportErrors)
|
|
2724
2762
|
this.reportError(Diagnostics.Source_has_0_element_s_but_target_allows_only_1, [
|
|
2725
2763
|
String(sourceMinLength),
|
|
@@ -2727,7 +2765,7 @@ export class Relater extends TypeComparer {
|
|
|
2727
2765
|
]);
|
|
2728
2766
|
return Ternary.False;
|
|
2729
2767
|
}
|
|
2730
|
-
if (!
|
|
2768
|
+
if (!targetHasVariableElement && (sourceRest || targetArity < sourceArity)) {
|
|
2731
2769
|
if (reportErrors) {
|
|
2732
2770
|
if (sourceMinLength < targetMinLength)
|
|
2733
2771
|
this.reportError(Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, [
|
|
@@ -2750,10 +2788,18 @@ export class Relater extends TypeComparer {
|
|
|
2750
2788
|
? tupleTargetOf(source).elementInfos[sourcePosition]!.flags
|
|
2751
2789
|
: ElementFlags.Rest;
|
|
2752
2790
|
const sourcePositionFromEnd = sourceArity - 1 - sourcePosition;
|
|
2753
|
-
const
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2791
|
+
const restMapped = targetHasRestElement && sourcePosition >= targetStartCount;
|
|
2792
|
+
// A source element past the target's last element (a target with variadic but no rest elements).
|
|
2793
|
+
if (!restMapped && sourcePosition >= targetArity) {
|
|
2794
|
+
if (reportErrors)
|
|
2795
|
+
this.reportError(Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, [
|
|
2796
|
+
String(targetArity),
|
|
2797
|
+
]);
|
|
2798
|
+
return Ternary.False;
|
|
2799
|
+
}
|
|
2800
|
+
const targetPosition = restMapped
|
|
2801
|
+
? targetArity - 1 - Math.min(sourcePositionFromEnd, targetEndCount)
|
|
2802
|
+
: sourcePosition;
|
|
2757
2803
|
const targetFlags = targetPosition >= 0 ? targetTuple.elementInfos[targetPosition]!.flags : ElementFlags.None;
|
|
2758
2804
|
if ((targetFlags & ElementFlags.Variadic) !== 0 && (sourceFlags & ElementFlags.Variadic) === 0) {
|
|
2759
2805
|
if (reportErrors)
|
|
@@ -3557,7 +3603,15 @@ export class Relater extends TypeComparer {
|
|
|
3557
3603
|
target !== c.markerSubTypeForCheck
|
|
3558
3604
|
) {
|
|
3559
3605
|
const constraint = getBaseConstraintOfType(c, target);
|
|
3560
|
-
if (
|
|
3606
|
+
if (
|
|
3607
|
+
isDistributedTypeParameter(target) &&
|
|
3608
|
+
isTypeAssignableTo(c, generalizedSource, (target as TypeParameter).constraint!)
|
|
3609
|
+
)
|
|
3610
|
+
this.reportError(Diagnostics.X_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here, [
|
|
3611
|
+
generalizedSourceType,
|
|
3612
|
+
targetType,
|
|
3613
|
+
]);
|
|
3614
|
+
else if (constraint !== undefined && isTypeAssignableTo(c, generalizedSource, constraint))
|
|
3561
3615
|
this.reportError(
|
|
3562
3616
|
Diagnostics.X_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2,
|
|
3563
3617
|
[generalizedSourceType, targetType, typeToString(c, constraint)],
|
|
@@ -3611,7 +3665,6 @@ export class Relater extends TypeComparer {
|
|
|
3611
3665
|
case Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2:
|
|
3612
3666
|
return;
|
|
3613
3667
|
case Diagnostics.Excessive_complexity_comparing_types_0_and_1:
|
|
3614
|
-
case Diagnostics.Excessive_stack_depth_comparing_types_0_and_1:
|
|
3615
3668
|
case Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1:
|
|
3616
3669
|
if (this.chainArgsMatch(generalizedSourceType, targetType, undefined)) return;
|
|
3617
3670
|
break;
|
|
@@ -4335,14 +4388,12 @@ export function isDeeplyNestedType(
|
|
|
4335
4388
|
maxDepth: number,
|
|
4336
4389
|
): boolean {
|
|
4337
4390
|
if (depth < maxDepth) return false;
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
(
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
for (const u of typesOf(t)) if (isDeeplyNestedType(c, u, stack, depth, maxDepth)) return true;
|
|
4345
|
-
const identity = getRecursionIdentity(t);
|
|
4391
|
+
const target = getRecursionIdentityTarget(c, t);
|
|
4392
|
+
if ((target.flags & TypeFlags.Intersection) !== 0) {
|
|
4393
|
+
for (const u of typesOf(target)) if (isDeeplyNestedType(c, u, stack, depth, maxDepth)) return true;
|
|
4394
|
+
return false;
|
|
4395
|
+
}
|
|
4396
|
+
const identity = getRecursionIdentityFromTarget(target);
|
|
4346
4397
|
let count = 0;
|
|
4347
4398
|
let lastTypeId = 0;
|
|
4348
4399
|
for (let i = 0; i < depth; i++) {
|
|
@@ -4358,8 +4409,77 @@ export function isDeeplyNestedType(
|
|
|
4358
4409
|
return false;
|
|
4359
4410
|
}
|
|
4360
4411
|
|
|
4361
|
-
|
|
4412
|
+
/**
|
|
4413
|
+
* isDeeplyNestedType for the newest entry of `stack[start..end)`, counting only the entries in that range.
|
|
4414
|
+
* `identities` holds the recursion identity of each entry of the range once a check has computed it: 0 before
|
|
4415
|
+
* that, and -1 for an entry whose recursion identity target is an intersection, which is matched by its
|
|
4416
|
+
* constituents each time. Later checks compare the kept identities. The identities are computed when and in the
|
|
4417
|
+
* order isDeeplyNestedType computes them, so the types and symbol ids they create come in the same order.
|
|
4418
|
+
*/
|
|
4419
|
+
export function isDeeplyNestedStackEntry(
|
|
4420
|
+
c: Checker,
|
|
4421
|
+
stack: readonly Type[],
|
|
4422
|
+
identities: RecursionId[],
|
|
4423
|
+
start: number,
|
|
4424
|
+
end: number,
|
|
4425
|
+
maxDepth: number,
|
|
4426
|
+
): boolean {
|
|
4427
|
+
if (end - start < maxDepth) return false;
|
|
4428
|
+
return isDeeplyNestedInRange(c, stack[end - 1]!, true, stack, identities, start, end, maxDepth);
|
|
4429
|
+
}
|
|
4430
|
+
|
|
4431
|
+
function isDeeplyNestedInRange(
|
|
4432
|
+
c: Checker,
|
|
4433
|
+
t: Type,
|
|
4434
|
+
isEntry: boolean,
|
|
4435
|
+
stack: readonly Type[],
|
|
4436
|
+
identities: RecursionId[],
|
|
4437
|
+
start: number,
|
|
4438
|
+
end: number,
|
|
4439
|
+
maxDepth: number,
|
|
4440
|
+
): boolean {
|
|
4441
|
+
const target = getRecursionIdentityTarget(c, t);
|
|
4442
|
+
if ((target.flags & TypeFlags.Intersection) !== 0) {
|
|
4443
|
+
if (isEntry) identities[end - 1] = -1;
|
|
4444
|
+
for (const u of typesOf(target))
|
|
4445
|
+
if (isDeeplyNestedInRange(c, u, false, stack, identities, start, end, maxDepth)) return true;
|
|
4446
|
+
return false;
|
|
4447
|
+
}
|
|
4448
|
+
const identity = getRecursionIdentityFromTarget(target);
|
|
4449
|
+
if (isEntry) identities[end - 1] = identity;
|
|
4450
|
+
let count = 0;
|
|
4451
|
+
let lastTypeId = 0;
|
|
4452
|
+
for (let i = start; i < end; i++) {
|
|
4453
|
+
const s = stack[i]!;
|
|
4454
|
+
let known = identities[i]!;
|
|
4455
|
+
if (known === 0) {
|
|
4456
|
+
const sourceTarget = getRecursionIdentityTarget(c, s);
|
|
4457
|
+
known = (sourceTarget.flags & TypeFlags.Intersection) !== 0 ? -1 : getRecursionIdentityFromTarget(sourceTarget);
|
|
4458
|
+
identities[i] = known;
|
|
4459
|
+
}
|
|
4460
|
+
if (known >= 0 ? known === identity : hasMatchingRecursionIdentity(c, s, identity)) {
|
|
4461
|
+
if (s.id >= lastTypeId) {
|
|
4462
|
+
count++;
|
|
4463
|
+
if (count >= maxDepth) return true;
|
|
4464
|
+
}
|
|
4465
|
+
lastTypeId = s.id;
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
return false;
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
/**
|
|
4472
|
+
* The type whose recursion identity `t` has: the object type of an indexed access (T in T[K]), and for a
|
|
4473
|
+
* homomorphic mapped type the deepest target type that has a symbol. Unwrapping mapped types keeps the identities of
|
|
4474
|
+
* mapped types applied to written object literals unique: in `Mapped<{ x: Mapped<{ x: Mapped<{ x: string }>}>}>`,
|
|
4475
|
+
* each application has the identity of its object literal and does not appear deeply nested.
|
|
4476
|
+
*/
|
|
4477
|
+
function getRecursionIdentityTarget(c: Checker, t: Type): Type {
|
|
4362
4478
|
for (;;) {
|
|
4479
|
+
if ((t.flags & TypeFlags.IndexedAccess) !== 0) {
|
|
4480
|
+
t = (t as IndexedAccessType).objectType;
|
|
4481
|
+
continue;
|
|
4482
|
+
}
|
|
4363
4483
|
if (
|
|
4364
4484
|
(t.objectFlags & ObjectFlags.InstantiatedMapped) === ObjectFlags.InstantiatedMapped &&
|
|
4365
4485
|
(t.flags & TypeFlags.Object) !== 0
|
|
@@ -4378,20 +4498,20 @@ function getMappedTargetWithSymbol(c: Checker, t: Type): Type {
|
|
|
4378
4498
|
}
|
|
4379
4499
|
|
|
4380
4500
|
function hasMatchingRecursionIdentity(c: Checker, t: Type, identity: RecursionId): boolean {
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
(
|
|
4384
|
-
)
|
|
4385
|
-
t = getMappedTargetWithSymbol(c, t);
|
|
4386
|
-
if ((t.flags & TypeFlags.Intersection) !== 0) {
|
|
4387
|
-
for (const u of typesOf(t)) if (hasMatchingRecursionIdentity(c, u, identity)) return true;
|
|
4501
|
+
const target = getRecursionIdentityTarget(c, t);
|
|
4502
|
+
if ((target.flags & TypeFlags.Intersection) !== 0) {
|
|
4503
|
+
for (const u of typesOf(target)) if (hasMatchingRecursionIdentity(c, u, identity)) return true;
|
|
4388
4504
|
return false;
|
|
4389
4505
|
}
|
|
4390
|
-
return
|
|
4506
|
+
return getRecursionIdentityFromTarget(target) === identity;
|
|
4391
4507
|
}
|
|
4392
4508
|
|
|
4393
4509
|
/** An identity shared by instantiations of a type, so infinitely expanding instantiations can be detected. */
|
|
4394
|
-
export function getRecursionIdentity(t: Type): RecursionId {
|
|
4510
|
+
export function getRecursionIdentity(c: Checker, t: Type): RecursionId {
|
|
4511
|
+
return getRecursionIdentityFromTarget(getRecursionIdentityTarget(c, t));
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
function getRecursionIdentityFromTarget(t: Type): RecursionId {
|
|
4395
4515
|
if (
|
|
4396
4516
|
(t.flags & TypeFlags.Object) !== 0 &&
|
|
4397
4517
|
(t.objectFlags & (ObjectFlags.ObjectLiteral | ObjectFlags.ArrayLiteral)) === 0
|
|
@@ -4408,12 +4528,6 @@ export function getRecursionIdentity(t: Type): RecursionId {
|
|
|
4408
4528
|
return typeRecursionId((t as TypeReference).target!);
|
|
4409
4529
|
}
|
|
4410
4530
|
if ((t.flags & TypeFlags.TypeParameter) !== 0 && t.symbol !== undefined) return symbolRecursionId(t.symbol);
|
|
4411
|
-
if ((t.flags & TypeFlags.IndexedAccess) !== 0) {
|
|
4412
|
-
let objectType = (t as IndexedAccessType).objectType;
|
|
4413
|
-
while ((objectType.flags & TypeFlags.IndexedAccess) !== 0)
|
|
4414
|
-
objectType = (objectType as IndexedAccessType).objectType;
|
|
4415
|
-
return typeRecursionId(objectType);
|
|
4416
|
-
}
|
|
4417
4531
|
if ((t.flags & TypeFlags.Conditional) !== 0) return nodeRecursionId((t as ConditionalType).root.node);
|
|
4418
4532
|
return typeRecursionId(t);
|
|
4419
4533
|
}
|
|
@@ -4451,16 +4565,45 @@ export function getAliasVariances(c: Checker, symbol: Symbol): VarianceFlags[] {
|
|
|
4451
4565
|
* The measured variance of each type parameter, from relating marker instantiations; empty when
|
|
4452
4566
|
* requested recursively.
|
|
4453
4567
|
*/
|
|
4568
|
+
/** A generic type whose variances are being computed. */
|
|
4569
|
+
export class VarianceStackEntry {
|
|
4570
|
+
constructor(
|
|
4571
|
+
readonly symbol: Symbol,
|
|
4572
|
+
readonly typeParameters: readonly Type[],
|
|
4573
|
+
) {}
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4454
4576
|
function getVariancesWorker(c: Checker, symbol: Symbol, typeParameters: readonly Type[]): VarianceFlags[] {
|
|
4455
4577
|
const links = c.symbolLinks(symbol);
|
|
4456
4578
|
if (links.variances !== undefined) return links.variances;
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4579
|
+
let stackIndex = -1;
|
|
4580
|
+
for (let i = 0; i < c.varianceStack.length; i++)
|
|
4581
|
+
if (c.varianceStack[i]!.symbol === symbol) {
|
|
4582
|
+
stackIndex = i;
|
|
4583
|
+
break;
|
|
4584
|
+
}
|
|
4585
|
+
if (stackIndex >= 0) {
|
|
4586
|
+
// A circularity. The variances computed can depend on where the circular region is entered, so the
|
|
4587
|
+
// computation restarts from the generic type with the smallest symbol in the region if that is not this one,
|
|
4588
|
+
// which keeps the results of circular generic types stable.
|
|
4589
|
+
let minIndex = stackIndex;
|
|
4590
|
+
for (let i = stackIndex + 1; i < c.varianceStack.length; i++)
|
|
4591
|
+
if (compareSymbols(c, c.varianceStack[i]!.symbol, c.varianceStack[minIndex]!.symbol) < 0) minIndex = i;
|
|
4592
|
+
if (minIndex > stackIndex) {
|
|
4593
|
+
const saveVarianceStack = c.varianceStack;
|
|
4594
|
+
c.varianceStack = [];
|
|
4595
|
+
getVariancesWorker(c, saveVarianceStack[minIndex]!.symbol, saveVarianceStack[minIndex]!.typeParameters);
|
|
4596
|
+
c.varianceStack = saveVarianceStack;
|
|
4597
|
+
}
|
|
4598
|
+
// Variances that cannot be computed: the type parameters are treated as covariant. The computation in
|
|
4599
|
+
// progress stores its results over this.
|
|
4600
|
+
const stored = storedVariances(links);
|
|
4601
|
+
if (stored === undefined || stored.length === 0) links.variances = [];
|
|
4602
|
+
return links.variances!;
|
|
4462
4603
|
}
|
|
4463
|
-
|
|
4604
|
+
const saveResolutionStart = c.resolutionStart;
|
|
4605
|
+
if (c.varianceStack.length === 0) c.resolutionStart = c.resolutionDepth;
|
|
4606
|
+
c.varianceStack.push(new VarianceStackEntry(symbol, typeParameters));
|
|
4464
4607
|
const variances: VarianceFlags[] = [];
|
|
4465
4608
|
for (const tp of typeParameters) {
|
|
4466
4609
|
const modifiers = getTypeParameterModifiers(tp);
|
|
@@ -4487,14 +4630,22 @@ function getVariancesWorker(c: Checker, symbol: Symbol, typeParameters: readonly
|
|
|
4487
4630
|
if ((c.reliabilityFlags & RelationComparisonResult.ReportsUnreliable) !== 0) variance |= VarianceFlags.Unreliable;
|
|
4488
4631
|
c.reliabilityFlags = saveReliabilityFlags;
|
|
4489
4632
|
}
|
|
4633
|
+
// A computation restarted because of a circularity may have stored the variances already.
|
|
4634
|
+
const restarted = storedVariances(links);
|
|
4635
|
+
if (restarted !== undefined && restarted.length !== 0) break;
|
|
4490
4636
|
variances.push(variance);
|
|
4491
4637
|
}
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
return variances
|
|
4638
|
+
// Unless a restarted computation stored them.
|
|
4639
|
+
const stored = storedVariances(links);
|
|
4640
|
+
if (stored === undefined || stored.length === 0) links.variances = variances;
|
|
4641
|
+
c.varianceStack.pop();
|
|
4642
|
+
if (c.varianceStack.length === 0) c.resolutionStart = saveResolutionStart;
|
|
4643
|
+
return links.variances!;
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
/** The variances stored in `links`, read again after computations that may have stored them. */
|
|
4647
|
+
function storedVariances(links: SymbolLinks): VarianceFlags[] | undefined {
|
|
4648
|
+
return links.variances;
|
|
4498
4649
|
}
|
|
4499
4650
|
|
|
4500
4651
|
export function createMarkerType(c: Checker, symbol: Symbol, source: Type, target: Type): Type {
|
|
@@ -5138,6 +5289,8 @@ export function isExactOptionalPropertyMismatch(
|
|
|
5138
5289
|
}
|
|
5139
5290
|
|
|
5140
5291
|
/** The string literal member of `target` closest to the string literal `source`. */
|
|
5292
|
+
const maxStringLiteralSuggestionCandidates = 1000;
|
|
5293
|
+
|
|
5141
5294
|
function getSuggestedTypeForNonexistentStringLiteralType(c: Checker, source: Type, target: Type): Type | undefined {
|
|
5142
5295
|
const value = (source as LiteralType).stringValue;
|
|
5143
5296
|
const valueCodePoints = new CodePoints();
|
|
@@ -5146,8 +5299,11 @@ function getSuggestedTypeForNonexistentStringLiteralType(c: Checker, source: Typ
|
|
|
5146
5299
|
let bestDistance = Math.floor(valueCodePoints.length * 0.4) + 0.9;
|
|
5147
5300
|
let best: Type | undefined = undefined;
|
|
5148
5301
|
const lowerValue = value.toLowerCase();
|
|
5302
|
+
// A target with more string literal candidates than this gets no suggestion.
|
|
5303
|
+
let candidates = 0;
|
|
5149
5304
|
for (const t of typesOf(target)) {
|
|
5150
5305
|
if ((t.flags & TypeFlags.StringLiteral) === 0) continue;
|
|
5306
|
+
if (++candidates > maxStringLiteralSuggestionCandidates) return undefined;
|
|
5151
5307
|
const name = (t as LiteralType).stringValue;
|
|
5152
5308
|
const nameLength = utf8Length(name);
|
|
5153
5309
|
if (name === '' || Math.abs(nameLength - valueCodePoints.length) > maximumLengthDifference || name === value)
|
package/src/compiler/reparser.ts
CHANGED
|
@@ -891,11 +891,15 @@ export class Reparser {
|
|
|
891
891
|
if ((clause as HeritageClause).types.nodes.length !== 1) return false;
|
|
892
892
|
const target = (clause as HeritageClause).types.nodes[0]!;
|
|
893
893
|
const source = tag.className;
|
|
894
|
+
// The tag's type arguments apply to an `extends` clause without any: one naming the same
|
|
895
|
+
// entity, or another expression such as a call (`extends mixin(Base)`), but not `null`.
|
|
894
896
|
if (
|
|
895
897
|
target instanceof ExpressionWithTypeArguments &&
|
|
896
|
-
hasSamePropertyAccessName((target as ExpressionWithTypeArguments).expression, source.expression) &&
|
|
897
898
|
(target as ExpressionWithTypeArguments).typeArguments === undefined &&
|
|
898
|
-
source.typeArguments !== undefined
|
|
899
|
+
source.typeArguments !== undefined &&
|
|
900
|
+
(target as ExpressionWithTypeArguments).expression.kind !== SyntaxKind.NullKeyword &&
|
|
901
|
+
(!isEntityNameExpression((target as ExpressionWithTypeArguments).expression, false) ||
|
|
902
|
+
hasSamePropertyAccessName((target as ExpressionWithTypeArguments).expression, source.expression))
|
|
899
903
|
) {
|
|
900
904
|
const newArguments: Node[] = [];
|
|
901
905
|
for (const arg of source.typeArguments.nodes) newArguments.push(this.addDeepCloneReparse(arg));
|
|
@@ -966,6 +970,7 @@ export class Reparser {
|
|
|
966
970
|
modifiers,
|
|
967
971
|
SyntaxKind.NamespaceKeyword,
|
|
968
972
|
this.addDeepCloneReparse((fullName as ModuleDeclaration).name),
|
|
973
|
+
undefined,
|
|
969
974
|
block,
|
|
970
975
|
);
|
|
971
976
|
this.finishReparsedNode(result, fullName);
|