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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Instantiation: mappers that need the checker, and `instantiateType` for every kind of type.
|
|
2
2
|
import { lazyObjectFlags, sideOf, sideOfIfAny } from './side-state.js';
|
|
3
3
|
import { NodeVisitor, getBody, getInitializer, getParameters, getType, getTypeArguments as getTypeArgumentNodes, getTypeParameters as getTypeParameterNodes, } from './ast.js';
|
|
4
|
-
import { cachedTypeKey, IndexInfo, Signature, TypeAlias, TypeMapper, emptyTypes, newTypeMapper, SimpleTypeMapper, TypeListCache, } from './checker-types.js';
|
|
4
|
+
import { cachedTypeKey, IndexInfo, Signature, TypeAlias, TypeMapper, emptyTypes, newTypeMapper, SimpleTypeMapper, TypeListCache, getMappedType, } from './checker-types.js';
|
|
5
5
|
import { createDeferredTypeReference, createNormalizedTypeReference, getIntersectionType, getIntersectionTypeEx, getPropagatingFlagsOfTypes, getTemplateLiteralType, getTypeArguments, getUnionTypeEx, newObjectType, aliasKey, typesOf, typeListHash, } from './checker-type-factory.js';
|
|
6
6
|
import { getOuterTypeParameters } from './checker-declared-types.js';
|
|
7
7
|
import { getSymbolFromTypeReference, getResolvedSymbolOfIdentifier } from './checker-type-nodes.js';
|
|
@@ -10,6 +10,7 @@ import { getConstraintDeclaration } from './checker-declared-types.js';
|
|
|
10
10
|
import { isTypeAssignableTo } from './relations.js';
|
|
11
11
|
import { getFirstIdentifier } from './checker-symbols.js';
|
|
12
12
|
import { copyDeclarations, declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
|
|
13
|
+
import { symbolToString } from './type-printer.js';
|
|
13
14
|
// ---- Mappers that need the checker
|
|
14
15
|
/** Applies `m1`, then instantiates its result with `m2`, or applies `m2` when `m1` doesn't map. */
|
|
15
16
|
export class CompositeTypeMapper extends TypeMapper {
|
|
@@ -23,8 +24,8 @@ export class CompositeTypeMapper extends TypeMapper {
|
|
|
23
24
|
this.m2 = m2;
|
|
24
25
|
}
|
|
25
26
|
map(type) {
|
|
26
|
-
const t1 = this.m1
|
|
27
|
-
return t1 !== type ? instantiateType(this.c, t1, this.m2) : this.m2
|
|
27
|
+
const t1 = getMappedType(type, this.m1);
|
|
28
|
+
return t1 !== type ? instantiateType(this.c, t1, this.m2) : getMappedType(type, this.m2);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
/** Records unreliable or unmeasurable variance when it sees a marker type. */
|
|
@@ -103,25 +104,36 @@ export function instantiateTypeWithAlias(c, type, mapper, alias) {
|
|
|
103
104
|
if (!could && (type.alias === undefined || !aliasCouldContainTypeVariables(c, type)))
|
|
104
105
|
return type;
|
|
105
106
|
if (c.instantiationDepth === 100 || c.instantiationCount >= 5000000) {
|
|
106
|
-
// Probably infinitely expanding generic types; stop with the error type
|
|
107
|
-
|
|
107
|
+
// Probably infinitely expanding generic types; stop with the error type, naming the types whose
|
|
108
|
+
// instantiations nest three or more times.
|
|
109
|
+
const circularTypeNames = getCircularTypeNames(c);
|
|
110
|
+
if (circularTypeNames.length === 1)
|
|
111
|
+
c.error(c.currentNode, 1193 /* Diagnostics.Instantiations_of_type_0_appear_infinitely_circular */, circularTypeNames[0]);
|
|
112
|
+
else if (circularTypeNames.length > 1)
|
|
113
|
+
c.error(c.currentNode, 1194 /* Diagnostics.Instantiations_of_the_following_types_appear_infinitely_circular_Colon_0 */, quotedAndCommaSeparated(circularTypeNames));
|
|
114
|
+
else
|
|
115
|
+
c.error(c.currentNode, 744 /* Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite */);
|
|
108
116
|
return c.errorType;
|
|
109
117
|
}
|
|
110
|
-
const depth = c.activeMapperDepth;
|
|
111
|
-
const
|
|
112
|
-
let index = depth - 1;
|
|
113
|
-
while (index >= 0 &&
|
|
114
|
-
index
|
|
118
|
+
const depth = c.activeMapperDepth | 0;
|
|
119
|
+
const mapperId = mapper.id | 0;
|
|
120
|
+
let index = (depth - 1) | 0;
|
|
121
|
+
while (index >= 0 && c.activeMapperIds[index] !== mapperId)
|
|
122
|
+
index = (index - 1) | 0;
|
|
115
123
|
if (index === -1) {
|
|
116
124
|
// A newly active mapper has no cached instantiations; its cache is created when a nested
|
|
117
125
|
// instantiation with the same mapper stores one.
|
|
118
|
-
if (depth
|
|
119
|
-
|
|
126
|
+
if (depth === c.activeMapperIds.length) {
|
|
127
|
+
const grown = new Int32Array(depth * 2);
|
|
128
|
+
grown.set(c.activeMapperIds);
|
|
129
|
+
c.activeMapperIds = grown;
|
|
130
|
+
}
|
|
131
|
+
c.activeMapperIds[depth] = mapperId;
|
|
132
|
+
if (depth < c.activeMapperCaches.length) {
|
|
120
133
|
c.activeMapperCaches[depth] = undefined;
|
|
121
134
|
c.activeMapperAliasCaches[depth] = undefined;
|
|
122
135
|
}
|
|
123
136
|
else {
|
|
124
|
-
activeMappers.push(mapper);
|
|
125
137
|
c.activeMapperCaches.push(undefined);
|
|
126
138
|
c.activeMapperAliasCaches.push(undefined);
|
|
127
139
|
}
|
|
@@ -144,7 +156,13 @@ export function instantiateTypeWithAlias(c, type, mapper, alias) {
|
|
|
144
156
|
}
|
|
145
157
|
c.instantiationCount++;
|
|
146
158
|
c.totalInstantiations++;
|
|
147
|
-
c.instantiationDepth
|
|
159
|
+
const instantiationDepth = c.instantiationDepth;
|
|
160
|
+
const instantiationStack = c.instantiationStack;
|
|
161
|
+
if (instantiationDepth < instantiationStack.length)
|
|
162
|
+
instantiationStack[instantiationDepth] = type;
|
|
163
|
+
else
|
|
164
|
+
instantiationStack.push(type);
|
|
165
|
+
c.instantiationDepth = instantiationDepth + 1;
|
|
148
166
|
const result = instantiateTypeWorker(c, type, mapper, alias);
|
|
149
167
|
if (index === -1) {
|
|
150
168
|
// The mapper's slot stays until it is reused; its caches are released now.
|
|
@@ -187,6 +205,33 @@ export function instantiateTypeWithAlias(c, type, mapper, alias) {
|
|
|
187
205
|
c.instantiationDepth--;
|
|
188
206
|
return result;
|
|
189
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* The names of the types that are instantiated three or more times on the current instantiation stack, by
|
|
210
|
+
* their alias where they have one, in the order they reach the third, each once.
|
|
211
|
+
*/
|
|
212
|
+
function getCircularTypeNames(c) {
|
|
213
|
+
const counts = new Map();
|
|
214
|
+
const names = [];
|
|
215
|
+
const stack = c.instantiationStack;
|
|
216
|
+
for (let i = 0; i < c.instantiationDepth; i++) {
|
|
217
|
+
const t = stack[i];
|
|
218
|
+
const count = (counts.get(t) ?? 0) + 1;
|
|
219
|
+
counts.set(t, count);
|
|
220
|
+
if (count !== 3)
|
|
221
|
+
continue;
|
|
222
|
+
const symbol = t.alias !== undefined ? t.alias.symbol : t.symbol;
|
|
223
|
+
if (symbol === undefined || symbol.name.length === 0 || symbol.name.charCodeAt(0) === 0xfffe)
|
|
224
|
+
continue;
|
|
225
|
+
const name = symbolToString(c, symbol);
|
|
226
|
+
if (!names.includes(name))
|
|
227
|
+
names.push(name);
|
|
228
|
+
}
|
|
229
|
+
return names;
|
|
230
|
+
}
|
|
231
|
+
/** `'a', 'b', 'c'`. */
|
|
232
|
+
export function quotedAndCommaSeparated(items) {
|
|
233
|
+
return items.map((item) => "'" + item + "'").join(', ');
|
|
234
|
+
}
|
|
190
235
|
function aliasCouldContainTypeVariables(c, type) {
|
|
191
236
|
const alias = type.alias;
|
|
192
237
|
if (alias === undefined || alias.typeArguments.length === 0)
|
|
@@ -261,18 +306,18 @@ function isNonGenericTopLevelType(type) {
|
|
|
261
306
|
return false;
|
|
262
307
|
let declaration;
|
|
263
308
|
for (const d of getDeclarations(alias.symbol))
|
|
264
|
-
if (d.kind ===
|
|
309
|
+
if (d.kind === 267 /* SyntaxKind.TypeAliasDeclaration */ || d.kind === 346 /* SyntaxKind.JSTypeAliasDeclaration */) {
|
|
265
310
|
declaration = d;
|
|
266
311
|
break;
|
|
267
312
|
}
|
|
268
313
|
if (declaration === undefined)
|
|
269
314
|
return false;
|
|
270
315
|
for (let n = declaration.parent; n !== undefined; n = n.parent) {
|
|
271
|
-
if (n.kind ===
|
|
316
|
+
if (n.kind === 308 /* SyntaxKind.SourceFile */)
|
|
272
317
|
return true;
|
|
273
|
-
if (n.kind ===
|
|
318
|
+
if (n.kind === 269 /* SyntaxKind.ModuleDeclaration */)
|
|
274
319
|
return false;
|
|
275
|
-
if (n.kind !==
|
|
320
|
+
if (n.kind !== 270 /* SyntaxKind.ModuleBlock */)
|
|
276
321
|
return false;
|
|
277
322
|
}
|
|
278
323
|
return false;
|
|
@@ -280,7 +325,7 @@ function isNonGenericTopLevelType(type) {
|
|
|
280
325
|
function instantiateTypeWorker(c, type, mapper, alias) {
|
|
281
326
|
const flags = type.flags;
|
|
282
327
|
if ((flags & 524288 /* TypeFlags.TypeParameter */) !== 0)
|
|
283
|
-
return
|
|
328
|
+
return getMappedType(type, mapper);
|
|
284
329
|
if ((flags & 1048576 /* TypeFlags.Object */) !== 0) {
|
|
285
330
|
const objectFlags = type.objectFlags;
|
|
286
331
|
if ((objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) === 0)
|
|
@@ -357,7 +402,7 @@ function instantiateTypeWorker(c, type, mapper, alias) {
|
|
|
357
402
|
}
|
|
358
403
|
/** Instantiates anonymous types, deferred references, instantiation expressions and mapped types. */
|
|
359
404
|
function getObjectTypeInstantiation(c, type, mapper, alias) {
|
|
360
|
-
if ((type.objectFlags & 4 /* ObjectFlags.Reference */) === 0 && c.withoutOuterTypeParameters.
|
|
405
|
+
if ((type.objectFlags & 4 /* ObjectFlags.Reference */) === 0 && c.withoutOuterTypeParameters.has(type.id))
|
|
361
406
|
return type;
|
|
362
407
|
let declaration;
|
|
363
408
|
if ((type.objectFlags & 4 /* ObjectFlags.Reference */) !== 0)
|
|
@@ -403,7 +448,7 @@ function getObjectTypeInstantiation(c, type, mapper, alias) {
|
|
|
403
448
|
}
|
|
404
449
|
if (typeParameters.length === 0) {
|
|
405
450
|
if ((type.objectFlags & 4 /* ObjectFlags.Reference */) === 0)
|
|
406
|
-
c.withoutOuterTypeParameters.
|
|
451
|
+
c.withoutOuterTypeParameters.add(type.id);
|
|
407
452
|
return type;
|
|
408
453
|
}
|
|
409
454
|
// The type arguments, mapped as `combineTypeMappers(c, type.mapper, mapper)` maps them, into a
|
|
@@ -412,10 +457,10 @@ function getObjectTypeInstantiation(c, type, mapper, alias) {
|
|
|
412
457
|
const mapped = c.freeTypeLists.pop() ?? [];
|
|
413
458
|
for (const tp of typeParameters) {
|
|
414
459
|
if (typeMapper === undefined)
|
|
415
|
-
mapped.push(
|
|
460
|
+
mapped.push(getMappedType(tp, mapper));
|
|
416
461
|
else {
|
|
417
|
-
const t1 =
|
|
418
|
-
mapped.push(t1 !== tp ? instantiateType(c, t1, mapper) :
|
|
462
|
+
const t1 = getMappedType(tp, typeMapper);
|
|
463
|
+
mapped.push(t1 !== tp ? instantiateType(c, t1, mapper) : getMappedType(tp, mapper));
|
|
419
464
|
}
|
|
420
465
|
}
|
|
421
466
|
const newAlias = alias ?? instantiateTypeAlias(c, type.alias, mapper);
|
|
@@ -481,9 +526,9 @@ class ReferenceFinder extends NodeVisitor {
|
|
|
481
526
|
containsReference(node) {
|
|
482
527
|
const tp = this.tp;
|
|
483
528
|
switch (node.kind) {
|
|
484
|
-
case
|
|
529
|
+
case 199 /* SyntaxKind.ThisType */:
|
|
485
530
|
return tp.isThisType;
|
|
486
|
-
case
|
|
531
|
+
case 185 /* SyntaxKind.TypeReference */: {
|
|
487
532
|
const args = getTypeArgumentNodes(node);
|
|
488
533
|
if (!tp.isThisType &&
|
|
489
534
|
(args === undefined || args.nodes.length === 0) &&
|
|
@@ -491,14 +536,14 @@ class ReferenceFinder extends NodeVisitor {
|
|
|
491
536
|
return true;
|
|
492
537
|
break;
|
|
493
538
|
}
|
|
494
|
-
case
|
|
539
|
+
case 188 /* SyntaxKind.TypeQuery */: {
|
|
495
540
|
const firstIdentifier = getFirstIdentifier(node.exprName);
|
|
496
541
|
if (firstIdentifier.kind !== 109 /* SyntaxKind.ThisKeyword */ &&
|
|
497
542
|
!(firstIdentifier.kind === 79 /* SyntaxKind.Identifier */ && firstIdentifier.text === 'this')) {
|
|
498
543
|
const symbol = getResolvedSymbolOfIdentifier(this.c, firstIdentifier);
|
|
499
544
|
const tpDeclaration = tp.symbol.declaration;
|
|
500
545
|
let scope;
|
|
501
|
-
if (tpDeclaration.kind ===
|
|
546
|
+
if (tpDeclaration.kind === 170 /* SyntaxKind.TypeParameter */)
|
|
502
547
|
scope = tpDeclaration.parent;
|
|
503
548
|
else if (tp.isThisType)
|
|
504
549
|
scope = tpDeclaration;
|
|
@@ -516,8 +561,8 @@ class ReferenceFinder extends NodeVisitor {
|
|
|
516
561
|
}
|
|
517
562
|
return true;
|
|
518
563
|
}
|
|
519
|
-
case
|
|
520
|
-
case
|
|
564
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
565
|
+
case 175 /* SyntaxKind.MethodSignature */: {
|
|
521
566
|
const returnType = getType(node);
|
|
522
567
|
if (returnType === undefined && getBody(node) !== undefined)
|
|
523
568
|
return true;
|
|
@@ -558,9 +603,9 @@ export function isTypeParameterPossiblyReferenced(c, tp, node) {
|
|
|
558
603
|
const finder = new ReferenceFinder(c, typeParameter);
|
|
559
604
|
const container = tp.symbol.declaration.parent;
|
|
560
605
|
for (let n = node; n !== container; n = n.parent) {
|
|
561
|
-
if (n === undefined || n.kind ===
|
|
606
|
+
if (n === undefined || n.kind === 243 /* SyntaxKind.Block */)
|
|
562
607
|
return true;
|
|
563
|
-
if (n.kind ===
|
|
608
|
+
if (n.kind === 196 /* SyntaxKind.ConditionalType */ && finder.containsReference(n.extendsType))
|
|
564
609
|
return true;
|
|
565
610
|
}
|
|
566
611
|
return finder.containsReference(node);
|
|
@@ -697,11 +742,18 @@ export function instantiateSymbol(c, symbol, mapper) {
|
|
|
697
742
|
* is resolved yet, so lazily instantiated members record it when tsgo would instantiate them.
|
|
698
743
|
*/
|
|
699
744
|
export function keepsSymbolUnderInstantiation(c, symbol, mapper) {
|
|
700
|
-
|
|
701
|
-
|
|
745
|
+
if (mapper.mapsThisOnly() && isThisless(symbol)) {
|
|
746
|
+
getSymbolId(symbol);
|
|
702
747
|
return true;
|
|
703
|
-
|
|
704
|
-
|
|
748
|
+
}
|
|
749
|
+
return keepsSymbolTypeUnderInstantiation(c, symbol);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Whether the resolved type of `symbol` (and its write type) can't change under instantiation, so that
|
|
753
|
+
* `instantiateSymbol` keeps it whatever the mapper. Once true, it stays true: types are resolved once.
|
|
754
|
+
*/
|
|
755
|
+
export function keepsSymbolTypeUnderInstantiation(c, symbol) {
|
|
756
|
+
const type = c.symbolTypes.get(getSymbolId(symbol));
|
|
705
757
|
if (type !== undefined && !couldContainTypeVariables(c, type)) {
|
|
706
758
|
if ((symbol.flags & 65536 /* SymbolFlags.SetAccessor */) === 0)
|
|
707
759
|
return true;
|
|
@@ -723,7 +775,7 @@ export function newInstantiatedSymbol(c, symbol, mapper) {
|
|
|
723
775
|
result.checkFlags =
|
|
724
776
|
1 /* CheckFlags.Instantiated */ |
|
|
725
777
|
(symbol.checkFlags &
|
|
726
|
-
(8 /* CheckFlags.Readonly */ |
|
|
778
|
+
(8 /* CheckFlags.Readonly */ | 32768 /* CheckFlags.Late */ | 131072 /* CheckFlags.OptionalParameter */ | 262144 /* CheckFlags.RestParameter */));
|
|
727
779
|
copyDeclarations(result, symbol);
|
|
728
780
|
result.parent = symbol.parent;
|
|
729
781
|
result.valueDeclaration = symbol.valueDeclaration;
|
|
@@ -739,15 +791,15 @@ export function isThisless(symbol) {
|
|
|
739
791
|
return false;
|
|
740
792
|
const declaration = symbol.declaration;
|
|
741
793
|
switch (declaration.kind) {
|
|
742
|
-
case
|
|
743
|
-
case
|
|
744
|
-
case
|
|
794
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
795
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
796
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
745
797
|
return isThislessVariableLikeDeclaration(declaration);
|
|
746
|
-
case
|
|
747
|
-
case
|
|
748
|
-
case
|
|
749
|
-
case
|
|
750
|
-
case
|
|
798
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
799
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
800
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
801
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
802
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
751
803
|
return isThislessFunctionLikeDeclaration(declaration);
|
|
752
804
|
}
|
|
753
805
|
return false;
|
|
@@ -769,11 +821,11 @@ function isThislessType(node) {
|
|
|
769
821
|
case 115 /* SyntaxKind.VoidKeyword */:
|
|
770
822
|
case 157 /* SyntaxKind.UndefinedKeyword */:
|
|
771
823
|
case 146 /* SyntaxKind.NeverKeyword */:
|
|
772
|
-
case
|
|
824
|
+
case 203 /* SyntaxKind.LiteralType */:
|
|
773
825
|
return true;
|
|
774
|
-
case
|
|
826
|
+
case 190 /* SyntaxKind.ArrayType */:
|
|
775
827
|
return isThislessType(node.elementType);
|
|
776
|
-
case
|
|
828
|
+
case 185 /* SyntaxKind.TypeReference */: {
|
|
777
829
|
const args = getTypeArgumentNodes(node);
|
|
778
830
|
if (args !== undefined)
|
|
779
831
|
for (const a of args.nodes)
|
|
@@ -786,7 +838,7 @@ function isThislessType(node) {
|
|
|
786
838
|
}
|
|
787
839
|
function isThislessFunctionLikeDeclaration(node) {
|
|
788
840
|
const returnType = getType(node);
|
|
789
|
-
if (node.kind !==
|
|
841
|
+
if (node.kind !== 178 /* SyntaxKind.Constructor */ && (returnType === undefined || !isThislessType(returnType)))
|
|
790
842
|
return false;
|
|
791
843
|
const parameters = getParameters(node);
|
|
792
844
|
if (parameters !== undefined)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// JSDoc comment parsing, a port of tsgo's parser/jsdoc.go.
|
|
2
2
|
//
|
|
3
3
|
// Comment indentation is measured in UTF-8 bytes, as in tsgo, so comment text matches it exactly.
|
|
4
|
-
import { ArrayTypeNode, ExpressionWithTypeArguments, Identifier, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, ModuleDeclaration, NodeList, PropertyAccessExpression, QualifiedName, TypeParameterDeclaration, TypeReferenceNode, getTagName, getType, } from './ast.js';
|
|
4
|
+
import { ArrayTypeNode, ExpressionWithTypeArguments, Identifier, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, ModuleDeclaration, NodeList, PropertyAccessExpression, QualifiedName, TypeParameterDeclaration, TypeReferenceNode, getTagName, getType, getText, } from './ast.js';
|
|
5
5
|
import { isReservedWord, tokenIsIdentifierOrKeyword } from './ast-utilities.js';
|
|
6
6
|
import { isWhiteSpaceLike } from './character-codes.js';
|
|
7
7
|
import { Diagnostic } from './diagnostics.js';
|
|
@@ -27,13 +27,13 @@ class CommentText {
|
|
|
27
27
|
export function getJSDocCommentRanges(node, text) {
|
|
28
28
|
const ranges = [];
|
|
29
29
|
switch (node.kind) {
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
36
|
-
case
|
|
30
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
31
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
32
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
33
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
34
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
35
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
36
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
37
37
|
addRanges(ranges, getTrailingCommentRanges(text, node.pos));
|
|
38
38
|
addRanges(ranges, getLeadingCommentRanges(text, node.pos));
|
|
39
39
|
break;
|
|
@@ -656,7 +656,7 @@ export class JSDocParser {
|
|
|
656
656
|
typeExpression = nestedTypeLiteral;
|
|
657
657
|
isNameFirst = true;
|
|
658
658
|
}
|
|
659
|
-
const kind = target === 1 /* PropertyLikeParse.Property */ ?
|
|
659
|
+
const kind = target === 1 /* PropertyLikeParse.Property */ ? 341 /* SyntaxKind.JSDocPropertyTag */ : 334 /* SyntaxKind.JSDocParameterTag */;
|
|
660
660
|
return p.finishNode(new JSDocParameterOrPropertyTag(kind, tagName, name, isBracketed, typeExpression, isNameFirst, comment), start);
|
|
661
661
|
}
|
|
662
662
|
parseNestedTypeLiteral(typeExpression, name, target, indent) {
|
|
@@ -675,24 +675,24 @@ export class JSDocParser {
|
|
|
675
675
|
p.rewind(state);
|
|
676
676
|
break;
|
|
677
677
|
}
|
|
678
|
-
if (child.kind ===
|
|
678
|
+
if (child.kind === 334 /* SyntaxKind.JSDocParameterTag */ || child.kind === 341 /* SyntaxKind.JSDocPropertyTag */)
|
|
679
679
|
children.push(child);
|
|
680
|
-
else if (child.kind ===
|
|
680
|
+
else if (child.kind === 338 /* SyntaxKind.JSDocTemplateTag */)
|
|
681
681
|
this.reportTemplateAfterTypedef(child);
|
|
682
682
|
}
|
|
683
683
|
if (children.length === 0)
|
|
684
684
|
return undefined;
|
|
685
|
-
const literal = p.finishNode(new JSDocTypeLiteral(children, type.kind ===
|
|
685
|
+
const literal = p.finishNode(new JSDocTypeLiteral(children, type.kind === 190 /* SyntaxKind.ArrayType */), pos);
|
|
686
686
|
return p.finishNode(new JSDocTypeExpression(literal), pos);
|
|
687
687
|
}
|
|
688
688
|
reportTemplateAfterTypedef(tag) {
|
|
689
689
|
const tagName = getTagName(tag);
|
|
690
|
-
this.p.parseErrorAt(tagName.pos, tagName.end,
|
|
690
|
+
this.p.parseErrorAt(tagName.pos, tagName.end, 1788 /* Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag */);
|
|
691
691
|
return true;
|
|
692
692
|
}
|
|
693
693
|
parseReturnTag(previousTags, start, tagName, indent, indentText) {
|
|
694
694
|
const p = this.p;
|
|
695
|
-
if (hasTagOfKind(previousTags,
|
|
695
|
+
if (hasTagOfKind(previousTags, 335 /* SyntaxKind.JSDocReturnTag */))
|
|
696
696
|
p.parseErrorAt(tagName.pos, p.scanner.getTokenStart(), 173 /* Diagnostics.X_0_tag_already_specified */, [tagName.text]);
|
|
697
697
|
const typeExpression = this.tryParseTypeExpression();
|
|
698
698
|
return p.finishNode(new JSDocReturnTag(tagName, typeExpression, this.parseTrailingTagComments(start, p.nodePos(), indent, indentText)), start);
|
|
@@ -700,7 +700,7 @@ export class JSDocParser {
|
|
|
700
700
|
/** `indent` -1 skips trailing comments, as for a type tag nested in a typedef. */
|
|
701
701
|
parseTypeTag(previousTags, start, tagName, indent, indentText) {
|
|
702
702
|
const p = this.p;
|
|
703
|
-
if (hasTagOfKind(previousTags,
|
|
703
|
+
if (hasTagOfKind(previousTags, 337 /* SyntaxKind.JSDocTypeTag */))
|
|
704
704
|
p.parseErrorAt(tagName.pos, p.scanner.getTokenStart(), 173 /* Diagnostics.X_0_tag_already_specified */, [tagName.text]);
|
|
705
705
|
const typeExpression = this.parseJSDocTypeExpression(true);
|
|
706
706
|
const comments = indent !== -1 ? this.parseTrailingTagComments(start, p.nodePos(), indent, indentText) : undefined;
|
|
@@ -790,7 +790,7 @@ export class JSDocParser {
|
|
|
790
790
|
const typeNameOrNamespaceName = this.parseJSDocIdentifierName(undefined);
|
|
791
791
|
if (this.parseOptionalJsdoc(24 /* SyntaxKind.DotToken */)) {
|
|
792
792
|
const body = this.parseJSDocTypeNameWithNamespace(true);
|
|
793
|
-
const jsDocNamespaceNode = new ModuleDeclaration(undefined, 145 /* SyntaxKind.NamespaceKeyword */, typeNameOrNamespaceName, body);
|
|
793
|
+
const jsDocNamespaceNode = new ModuleDeclaration(undefined, 145 /* SyntaxKind.NamespaceKeyword */, typeNameOrNamespaceName, undefined, body);
|
|
794
794
|
if (nested)
|
|
795
795
|
jsDocNamespaceNode.flags |= 32 /* NodeFlags.NestedNamespace */;
|
|
796
796
|
return p.finishNode(jsDocNamespaceNode, start);
|
|
@@ -823,7 +823,7 @@ export class JSDocParser {
|
|
|
823
823
|
break;
|
|
824
824
|
}
|
|
825
825
|
hasChildren = true;
|
|
826
|
-
if (child.kind ===
|
|
826
|
+
if (child.kind === 338 /* SyntaxKind.JSDocTemplateTag */) {
|
|
827
827
|
this.reportTemplateAfterTypedef(child);
|
|
828
828
|
}
|
|
829
829
|
else if (child instanceof JSDocTypeTag) {
|
|
@@ -831,9 +831,9 @@ export class JSDocParser {
|
|
|
831
831
|
childTypeTag = child;
|
|
832
832
|
}
|
|
833
833
|
else {
|
|
834
|
-
const lastError = p.parseErrorAtCurrentToken(
|
|
834
|
+
const lastError = p.parseErrorAtCurrentToken(1782 /* Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags */);
|
|
835
835
|
if (lastError !== undefined)
|
|
836
|
-
lastError.addRelatedInfo(newDiagnosticAtStart(
|
|
836
|
+
lastError.addRelatedInfo(newDiagnosticAtStart(1783 /* Diagnostics.The_tag_was_first_specified_here */));
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
else {
|
|
@@ -841,7 +841,7 @@ export class JSDocParser {
|
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
843
|
if (hasChildren) {
|
|
844
|
-
const isArrayType = typeExpressionType !== undefined && typeExpressionType.kind ===
|
|
844
|
+
const isArrayType = typeExpressionType !== undefined && typeExpressionType.kind === 190 /* SyntaxKind.ArrayType */;
|
|
845
845
|
const jsdocTypeLiteral = new JSDocTypeLiteral(jsdocPropertyTags, isArrayType);
|
|
846
846
|
const childType = childTypeTag !== undefined && childTypeTag.typeExpression !== undefined
|
|
847
847
|
? getType(childTypeTag.typeExpression)
|
|
@@ -889,7 +889,7 @@ export class JSDocParser {
|
|
|
889
889
|
p.rewind(state);
|
|
890
890
|
break;
|
|
891
891
|
}
|
|
892
|
-
if (child.kind ===
|
|
892
|
+
if (child.kind === 338 /* SyntaxKind.JSDocTemplateTag */)
|
|
893
893
|
this.reportTemplateAfterTypedef(child);
|
|
894
894
|
else
|
|
895
895
|
parameters.push(child);
|
|
@@ -903,7 +903,7 @@ export class JSDocParser {
|
|
|
903
903
|
const state = p.mark();
|
|
904
904
|
if (this.parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) {
|
|
905
905
|
const tag = this.parseTag([], indent);
|
|
906
|
-
if (tag.kind ===
|
|
906
|
+
if (tag.kind === 335 /* SyntaxKind.JSDocReturnTag */)
|
|
907
907
|
returnTag = tag;
|
|
908
908
|
}
|
|
909
909
|
if (returnTag === undefined)
|
|
@@ -1116,7 +1116,7 @@ function textsEqual(a, b) {
|
|
|
1116
1116
|
while (!(a instanceof Identifier) || !(b instanceof Identifier)) {
|
|
1117
1117
|
if (a instanceof QualifiedName &&
|
|
1118
1118
|
b instanceof QualifiedName &&
|
|
1119
|
-
a.right
|
|
1119
|
+
getText(a.right) === getText(b.right)) {
|
|
1120
1120
|
a = a.left;
|
|
1121
1121
|
b = b.left;
|
|
1122
1122
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Symbol } from './symbol.js';
|
|
2
1
|
/** Links are stored in pages of 256 ids. */
|
|
3
2
|
export declare const enum LinkPaging {
|
|
4
3
|
Bits = 8,
|
|
@@ -66,13 +65,16 @@ export declare class PagedIdSet {
|
|
|
66
65
|
clear(): void;
|
|
67
66
|
}
|
|
68
67
|
/**
|
|
69
|
-
* A page of a `
|
|
70
|
-
* of
|
|
71
|
-
* lookup reads one object before the
|
|
72
|
-
* 32-bit fields
|
|
68
|
+
* A page of a `CompactLinkTable`'s presence bits: one bit per id of the page in eight 32-id words, the
|
|
69
|
+
* number of values stored before each word, and the position of the page's values in the table's
|
|
70
|
+
* `values`. The words are fields, so a lookup reads one object before the values. Natively the words
|
|
71
|
+
* are 32-bit fields, since every write stores an int32. A class that is generic or has a generic
|
|
72
|
+
* subclass keeps its number fields as doubles, so the values the bits index are in the table's
|
|
73
|
+
* `values`, not in this class or a subclass.
|
|
73
74
|
*/
|
|
74
75
|
declare class CompactLinkPage {
|
|
75
|
-
|
|
76
|
+
/** The position of the page's values in the table's `values`. */
|
|
77
|
+
readonly position: number;
|
|
76
78
|
private w0;
|
|
77
79
|
private w1;
|
|
78
80
|
private w2;
|
|
@@ -84,29 +86,57 @@ declare class CompactLinkPage {
|
|
|
84
86
|
/** Byte `w & 3` of `before0` (words 1 to 3) or of `before1` (words 4 to 7): the values before word `w`. */
|
|
85
87
|
private before0;
|
|
86
88
|
private before1;
|
|
87
|
-
constructor();
|
|
89
|
+
constructor(position: number);
|
|
88
90
|
/** The presence bits of ids `32 * word` to `32 * word + 31`. */
|
|
89
91
|
word(word: number): number;
|
|
90
92
|
setWord(word: number, bits: number): void;
|
|
91
93
|
/** The index in `values` of the value of `slot` (an id's low bits), or of where it goes. */
|
|
92
94
|
rank(slot: number, bits: number): number;
|
|
93
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Adds 1 (`delta` 1) or subtracts 1 (`delta` -1) from the counts of the words after `word`, a byte
|
|
97
|
+
* of `before0` or `before1` each. No byte carries or borrows: a count is at most 224, and a count
|
|
98
|
+
* that goes down includes the value removed.
|
|
99
|
+
*/
|
|
94
100
|
shiftCounts(word: number, delta: number): void;
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
98
|
-
* pages it touches
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
+
* Values by node or symbol id, for ids a checker stores a value for in more than about one in
|
|
104
|
+
* sixteen of the ids of the pages it touches: the symbols it resolves for the identifiers and names
|
|
105
|
+
* of the files it checks (one in four to one in eight), the types and signatures it resolves for
|
|
106
|
+
* their type nodes and calls (one in twelve to one in seventeen), and the symbol columns most
|
|
107
|
+
* symbols leave empty, such as the name type of a property (one in ten to one in three with
|
|
108
|
+
* `--checkers 16`, where every checker touches symbols across the whole program). Pages of
|
|
109
|
+
* `LinkPaging.Size` ids keep a presence bit per id and only the values stored, so a value costs
|
|
110
|
+
* about one array slot. A `LinkTable` page costs a slot for every id, and a `Map` entry also stores
|
|
111
|
+
* its key and a share of the hash buckets. At fewer values per page than that, the page's own
|
|
112
|
+
* allocations outweigh what it saves, and a `SparseLinkTable` costs less.
|
|
103
113
|
*/
|
|
104
|
-
export declare class
|
|
114
|
+
export declare class CompactLinkTable<T> {
|
|
115
|
+
/**
|
|
116
|
+
* The pages by `id >> LinkPaging.Bits`, up to the highest page stored; undefined where a page stores
|
|
117
|
+
* nothing. A checker stores values in a few percent of the pages of a large program, so the values
|
|
118
|
+
* are kept apart, one list for each page stored, rather than in a second slot per page.
|
|
119
|
+
*/
|
|
105
120
|
readonly pages: (CompactLinkPage | undefined)[];
|
|
106
|
-
/** The
|
|
121
|
+
/** The values of each page stored, in id order, at the page's `position`. */
|
|
122
|
+
readonly values: T[][];
|
|
123
|
+
/** The number of values stored. */
|
|
107
124
|
size: number;
|
|
108
|
-
get(id: number):
|
|
109
|
-
set(id: number, value:
|
|
125
|
+
get(id: number): T | undefined;
|
|
126
|
+
set(id: number, value: T | undefined): void;
|
|
127
|
+
clear(): void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Int32 values by id, zero where none is stored, in a `CompactLinkTable`: pages of
|
|
131
|
+
* `LinkPaging.Size` ids keep a presence bit per id and only the nonzero values. For columns where a
|
|
132
|
+
* checker stores a value for fewer than about one in three of the ids of the pages it touches, such
|
|
133
|
+
* as the reference kinds of the symbols its files reference: an `IntLinkTable` page costs four bytes
|
|
134
|
+
* for every id.
|
|
135
|
+
*/
|
|
136
|
+
export declare class CompactIntLinkTable {
|
|
137
|
+
private readonly table;
|
|
138
|
+
get(id: number): number;
|
|
139
|
+
set(id: number, value: number): void;
|
|
110
140
|
clear(): void;
|
|
111
141
|
}
|
|
112
142
|
export {};
|