tsc-ts 0.0.3 → 0.0.5
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 +46 -0
- package/dist/api/compiler/ast-utilities.d.ts +82 -0
- package/dist/api/compiler/ast-utilities.js +462 -0
- package/dist/api/compiler/ast.d.ts +2350 -0
- package/dist/api/compiler/ast.js +11206 -0
- package/dist/api/compiler/astnav.d.ts +37 -0
- package/dist/api/compiler/astnav.js +767 -0
- package/dist/api/compiler/binder-utilities.d.ts +182 -0
- package/dist/api/compiler/binder-utilities.js +1240 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2358 -0
- package/dist/api/compiler/character-codes.d.ts +161 -0
- package/dist/api/compiler/character-codes.js +160 -0
- package/dist/api/compiler/checker-calls.d.ts +46 -0
- package/dist/api/compiler/checker-calls.js +1640 -0
- package/dist/api/compiler/checker-classes.d.ts +30 -0
- package/dist/api/compiler/checker-classes.js +582 -0
- package/dist/api/compiler/checker-contextual.d.ts +77 -0
- package/dist/api/compiler/checker-contextual.js +1136 -0
- package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
- package/dist/api/compiler/checker-declaration-order.js +356 -0
- package/dist/api/compiler/checker-declarations.d.ts +33 -0
- package/dist/api/compiler/checker-declarations.js +888 -0
- package/dist/api/compiler/checker-declared-types.d.ts +48 -0
- package/dist/api/compiler/checker-declared-types.js +787 -0
- package/dist/api/compiler/checker-decorators.d.ts +26 -0
- package/dist/api/compiler/checker-decorators.js +562 -0
- package/dist/api/compiler/checker-deprecation.d.ts +33 -0
- package/dist/api/compiler/checker-deprecation.js +315 -0
- package/dist/api/compiler/checker-destructuring.d.ts +34 -0
- package/dist/api/compiler/checker-destructuring.js +584 -0
- package/dist/api/compiler/checker-elaboration.d.ts +15 -0
- package/dist/api/compiler/checker-elaboration.js +290 -0
- package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
- package/dist/api/compiler/checker-emit-helpers.js +154 -0
- package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
- package/dist/api/compiler/checker-emit-resolver.js +579 -0
- package/dist/api/compiler/checker-evaluator.d.ts +27 -0
- package/dist/api/compiler/checker-evaluator.js +188 -0
- package/dist/api/compiler/checker-expressions.d.ts +67 -0
- package/dist/api/compiler/checker-expressions.js +1351 -0
- package/dist/api/compiler/checker-features.d.ts +6 -0
- package/dist/api/compiler/checker-features.js +354 -0
- package/dist/api/compiler/checker-flow.d.ts +86 -0
- package/dist/api/compiler/checker-flow.js +169 -0
- package/dist/api/compiler/checker-functions.d.ts +43 -0
- package/dist/api/compiler/checker-functions.js +1002 -0
- package/dist/api/compiler/checker-generated-code.d.ts +25 -0
- package/dist/api/compiler/checker-generated-code.js +168 -0
- package/dist/api/compiler/checker-globals.d.ts +14 -0
- package/dist/api/compiler/checker-globals.js +37 -0
- package/dist/api/compiler/checker-grammar.d.ts +35 -0
- package/dist/api/compiler/checker-grammar.js +2573 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +900 -0
- package/dist/api/compiler/checker-inference.d.ts +179 -0
- package/dist/api/compiler/checker-inference.js +2105 -0
- package/dist/api/compiler/checker-iteration.d.ts +115 -0
- package/dist/api/compiler/checker-iteration.js +857 -0
- package/dist/api/compiler/checker-javascript.d.ts +42 -0
- package/dist/api/compiler/checker-javascript.js +441 -0
- package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
- package/dist/api/compiler/checker-jsdoc.js +320 -0
- package/dist/api/compiler/checker-jsx.d.ts +94 -0
- package/dist/api/compiler/checker-jsx.js +1433 -0
- package/dist/api/compiler/checker-literals.d.ts +6 -0
- package/dist/api/compiler/checker-literals.js +43 -0
- package/dist/api/compiler/checker-members.d.ts +198 -0
- package/dist/api/compiler/checker-members.js +2126 -0
- package/dist/api/compiler/checker-modules.d.ts +85 -0
- package/dist/api/compiler/checker-modules.js +2141 -0
- package/dist/api/compiler/checker-narrowing.d.ts +120 -0
- package/dist/api/compiler/checker-narrowing.js +2797 -0
- package/dist/api/compiler/checker-object-literals.d.ts +14 -0
- package/dist/api/compiler/checker-object-literals.js +479 -0
- package/dist/api/compiler/checker-operators.d.ts +33 -0
- package/dist/api/compiler/checker-operators.js +1040 -0
- package/dist/api/compiler/checker-overloads.d.ts +7 -0
- package/dist/api/compiler/checker-overloads.js +270 -0
- package/dist/api/compiler/checker-property-access.d.ts +34 -0
- package/dist/api/compiler/checker-property-access.js +672 -0
- package/dist/api/compiler/checker-services.d.ts +49 -0
- package/dist/api/compiler/checker-services.js +995 -0
- package/dist/api/compiler/checker-signatures.d.ts +55 -0
- package/dist/api/compiler/checker-signatures.js +788 -0
- package/dist/api/compiler/checker-source-file.d.ts +27 -0
- package/dist/api/compiler/checker-source-file.js +619 -0
- package/dist/api/compiler/checker-statements.d.ts +18 -0
- package/dist/api/compiler/checker-statements.js +226 -0
- package/dist/api/compiler/checker-super.d.ts +13 -0
- package/dist/api/compiler/checker-super.js +241 -0
- package/dist/api/compiler/checker-symbol-types.d.ts +67 -0
- package/dist/api/compiler/checker-symbol-types.js +1885 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1782 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2501 -0
- package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
- package/dist/api/compiler/checker-type-nodes.js +828 -0
- package/dist/api/compiler/checker-type-operators.d.ts +109 -0
- package/dist/api/compiler/checker-type-operators.js +1842 -0
- package/dist/api/compiler/checker-types.d.ts +1027 -0
- package/dist/api/compiler/checker-types.js +1697 -0
- package/dist/api/compiler/checker-unused.d.ts +19 -0
- package/dist/api/compiler/checker-unused.js +524 -0
- package/dist/api/compiler/checker-utilities.d.ts +33 -0
- package/dist/api/compiler/checker-utilities.js +141 -0
- package/dist/api/compiler/checker.d.ts +491 -0
- package/dist/api/compiler/checker.js +912 -0
- package/dist/api/compiler/command-line.d.ts +32 -0
- package/dist/api/compiler/command-line.js +383 -0
- package/dist/api/compiler/compile-program.d.ts +118 -0
- package/dist/api/compiler/compile-program.js +384 -0
- package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
- package/dist/api/compiler/diagnostic-locales.js +64 -0
- package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
- package/dist/api/compiler/diagnostic-messages.js +184 -0
- package/dist/api/compiler/diagnostics.d.ts +167 -0
- package/dist/api/compiler/diagnostics.js +820 -0
- package/dist/api/compiler/emitter.d.ts +71 -0
- package/dist/api/compiler/emitter.js +327 -0
- package/dist/api/compiler/file-include.d.ts +117 -0
- package/dist/api/compiler/file-include.js +536 -0
- package/dist/api/compiler/file-loader.d.ts +261 -0
- package/dist/api/compiler/file-loader.js +1257 -0
- package/dist/api/compiler/file-system.d.ts +51 -0
- package/dist/api/compiler/file-system.js +132 -0
- package/dist/api/compiler/flow.d.ts +60 -0
- package/dist/api/compiler/flow.js +45 -0
- package/dist/api/compiler/instantiation.d.ts +74 -0
- package/dist/api/compiler/instantiation.js +799 -0
- package/dist/api/compiler/jsdoc.d.ts +75 -0
- package/dist/api/compiler/jsdoc.js +1229 -0
- package/dist/api/compiler/link-tables.d.ts +36 -0
- package/dist/api/compiler/link-tables.js +83 -0
- package/dist/api/compiler/locale-data.d.ts +24 -0
- package/dist/api/compiler/locale-data.js +183 -0
- package/dist/api/compiler/locale.d.ts +4 -0
- package/dist/api/compiler/locale.js +317 -0
- package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
- package/dist/api/compiler/locales/cs-CZ.js +3 -0
- package/dist/api/compiler/locales/de-DE.d.ts +2 -0
- package/dist/api/compiler/locales/de-DE.js +3 -0
- package/dist/api/compiler/locales/es-ES.d.ts +2 -0
- package/dist/api/compiler/locales/es-ES.js +3 -0
- package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
- package/dist/api/compiler/locales/fr-FR.js +3 -0
- package/dist/api/compiler/locales/it-IT.d.ts +2 -0
- package/dist/api/compiler/locales/it-IT.js +3 -0
- package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
- package/dist/api/compiler/locales/ja-JP.js +3 -0
- package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
- package/dist/api/compiler/locales/ko-KR.js +3 -0
- package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
- package/dist/api/compiler/locales/pl-PL.js +3 -0
- package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
- package/dist/api/compiler/locales/pt-BR.js +3 -0
- package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
- package/dist/api/compiler/locales/ru-RU.js +3 -0
- package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
- package/dist/api/compiler/locales/tr-TR.js +3 -0
- package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
- package/dist/api/compiler/locales/zh-CN.js +3 -0
- package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
- package/dist/api/compiler/locales/zh-TW.js +3 -0
- package/dist/api/compiler/module-resolution-types.d.ts +83 -0
- package/dist/api/compiler/module-resolution-types.js +176 -0
- package/dist/api/compiler/module-resolution.d.ts +71 -0
- package/dist/api/compiler/module-resolution.js +1598 -0
- package/dist/api/compiler/module-specifiers.d.ts +64 -0
- package/dist/api/compiler/module-specifiers.js +1101 -0
- package/dist/api/compiler/name-resolver.d.ts +43 -0
- package/dist/api/compiler/name-resolver.js +509 -0
- package/dist/api/compiler/node-builder-names.d.ts +32 -0
- package/dist/api/compiler/node-builder-names.js +854 -0
- package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
- package/dist/api/compiler/node-builder-pseudo.js +744 -0
- package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
- package/dist/api/compiler/node-builder-reuse.js +647 -0
- package/dist/api/compiler/node-builder.d.ts +270 -0
- package/dist/api/compiler/node-builder.js +2645 -0
- package/dist/api/compiler/option-declarations.d.ts +90 -0
- package/dist/api/compiler/option-declarations.js +1460 -0
- package/dist/api/compiler/options.d.ts +289 -0
- package/dist/api/compiler/options.js +1197 -0
- package/dist/api/compiler/output-paths.d.ts +42 -0
- package/dist/api/compiler/output-paths.js +195 -0
- package/dist/api/compiler/package-json.d.ts +175 -0
- package/dist/api/compiler/package-json.js +1015 -0
- package/dist/api/compiler/parallel-parse.d.ts +219 -0
- package/dist/api/compiler/parallel-parse.js +537 -0
- package/dist/api/compiler/parser.d.ts +587 -0
- package/dist/api/compiler/parser.js +6407 -0
- package/dist/api/compiler/path.d.ts +91 -0
- package/dist/api/compiler/path.js +705 -0
- package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
- package/dist/api/compiler/printer/async-helpers.js +91 -0
- package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
- package/dist/api/compiler/printer/auto-generate.js +20 -0
- package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
- package/dist/api/compiler/printer/decorator-helpers.js +118 -0
- package/dist/api/compiler/printer/emit-context.d.ts +154 -0
- package/dist/api/compiler/printer/emit-context.js +576 -0
- package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
- package/dist/api/compiler/printer/emit-flags.js +2 -0
- package/dist/api/compiler/printer/factory-base.d.ts +171 -0
- package/dist/api/compiler/printer/factory-base.js +1505 -0
- package/dist/api/compiler/printer/factory.d.ts +147 -0
- package/dist/api/compiler/printer/factory.js +542 -0
- package/dist/api/compiler/printer/helpers.d.ts +27 -0
- package/dist/api/compiler/printer/helpers.js +164 -0
- package/dist/api/compiler/printer/name-generator.d.ts +41 -0
- package/dist/api/compiler/printer/name-generator.js +283 -0
- package/dist/api/compiler/printer/printer.d.ts +411 -0
- package/dist/api/compiler/printer/printer.js +4517 -0
- package/dist/api/compiler/printer/text-writer.d.ts +46 -0
- package/dist/api/compiler/printer/text-writer.js +172 -0
- package/dist/api/compiler/printer/utilities.d.ts +82 -0
- package/dist/api/compiler/printer/utilities.js +817 -0
- package/dist/api/compiler/program-checker.d.ts +156 -0
- package/dist/api/compiler/program-checker.js +526 -0
- package/dist/api/compiler/program-utilities.d.ts +52 -0
- package/dist/api/compiler/program-utilities.js +365 -0
- package/dist/api/compiler/program.d.ts +180 -0
- package/dist/api/compiler/program.js +1011 -0
- package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
- package/dist/api/compiler/pseudo-bigint.js +61 -0
- package/dist/api/compiler/regexp-checker.d.ts +38 -0
- package/dist/api/compiler/regexp-checker.js +942 -0
- package/dist/api/compiler/relations.d.ts +263 -0
- package/dist/api/compiler/relations.js +4002 -0
- package/dist/api/compiler/reparser.d.ts +48 -0
- package/dist/api/compiler/reparser.js +1323 -0
- package/dist/api/compiler/scanner.d.ts +256 -0
- package/dist/api/compiler/scanner.js +2853 -0
- package/dist/api/compiler/side-state.d.ts +16 -0
- package/dist/api/compiler/side-state.js +89 -0
- package/dist/api/compiler/sourcemap.d.ts +55 -0
- package/dist/api/compiler/sourcemap.js +340 -0
- package/dist/api/compiler/spelling.d.ts +14 -0
- package/dist/api/compiler/spelling.js +128 -0
- package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
- package/dist/api/compiler/symbol-accessibility.js +894 -0
- package/dist/api/compiler/symbol.d.ts +240 -0
- package/dist/api/compiler/symbol.js +228 -0
- package/dist/api/compiler/symlinks.d.ts +32 -0
- package/dist/api/compiler/symlinks.js +114 -0
- package/dist/api/compiler/syntax-kind.d.ts +389 -0
- package/dist/api/compiler/syntax-kind.js +2 -0
- package/dist/api/compiler/timeline.d.ts +9 -0
- package/dist/api/compiler/timeline.js +54 -0
- package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
- package/dist/api/compiler/transformers/alias-references.js +676 -0
- package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
- package/dist/api/compiler/transformers/async-utilities.js +260 -0
- package/dist/api/compiler/transformers/async.d.ts +53 -0
- package/dist/api/compiler/transformers/async.js +645 -0
- package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
- package/dist/api/compiler/transformers/class-fields.js +2418 -0
- package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
- package/dist/api/compiler/transformers/class-utilities.js +261 -0
- package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
- package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
- package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
- package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.js +538 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +797 -0
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
- package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
- package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
- package/dist/api/compiler/transformers/declarations-tracker.js +197 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2380 -0
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
- package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
- package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
- package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
- package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
- package/dist/api/compiler/transformers/destructuring.js +626 -0
- package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
- package/dist/api/compiler/transformers/downlevel.js +45 -0
- package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
- package/dist/api/compiler/transformers/emit-resolver.js +197 -0
- package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
- package/dist/api/compiler/transformers/es-decorators.js +1901 -0
- package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
- package/dist/api/compiler/transformers/exponentiation.js +76 -0
- package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
- package/dist/api/compiler/transformers/external-module-info.js +351 -0
- package/dist/api/compiler/transformers/for-await.d.ts +43 -0
- package/dist/api/compiler/transformers/for-await.js +469 -0
- package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
- package/dist/api/compiler/transformers/import-elision.js +124 -0
- package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
- package/dist/api/compiler/transformers/jsx-entities.js +256 -0
- package/dist/api/compiler/transformers/jsx.d.ts +71 -0
- package/dist/api/compiler/transformers/jsx.js +700 -0
- package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
- package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
- package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
- package/dist/api/compiler/transformers/logical-assignment.js +62 -0
- package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
- package/dist/api/compiler/transformers/module-utilities.js +36 -0
- package/dist/api/compiler/transformers/module.d.ts +49 -0
- package/dist/api/compiler/transformers/module.js +296 -0
- package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
- package/dist/api/compiler/transformers/named-evaluation.js +266 -0
- package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
- package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
- package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
- package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
- package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
- package/dist/api/compiler/transformers/optional-catch.js +20 -0
- package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
- package/dist/api/compiler/transformers/optional-chain.js +188 -0
- package/dist/api/compiler/transformers/reference-resolver.d.ts +128 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1155 -0
- package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
- package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
- package/dist/api/compiler/transformers/subtree-facts.d.ts +9 -0
- package/dist/api/compiler/transformers/subtree-facts.js +203 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +51 -0
- package/dist/api/compiler/transformers/syntax-facts.js +254 -0
- package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
- package/dist/api/compiler/transformers/tagged-template.js +148 -0
- package/dist/api/compiler/transformers/transformer.d.ts +17 -0
- package/dist/api/compiler/transformers/transformer.js +54 -0
- package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
- package/dist/api/compiler/transformers/type-eraser.js +346 -0
- package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
- package/dist/api/compiler/transformers/type-serialization.js +347 -0
- package/dist/api/compiler/transformers/using.d.ts +56 -0
- package/dist/api/compiler/transformers/using.js +453 -0
- package/dist/api/compiler/transformers/utilities.d.ts +50 -0
- package/dist/api/compiler/transformers/utilities.js +347 -0
- package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
- package/dist/api/compiler/transformers/visitor-base.js +817 -0
- package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
- package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
- package/dist/api/compiler/tsconfig.d.ts +177 -0
- package/dist/api/compiler/tsconfig.js +1311 -0
- package/dist/api/compiler/type-printer.d.ts +15 -0
- package/dist/api/compiler/type-printer.js +74 -0
- package/dist/api/compiler/types.d.ts +87 -0
- package/dist/api/compiler/types.js +23 -0
- package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
- package/dist/api/compiler/unicode-identifiers.js +209 -0
- package/dist/api/compiler/unicode-properties.d.ts +8 -0
- package/dist/api/compiler/unicode-properties.js +531 -0
- package/dist/api/compiler/vfs-match.d.ts +24 -0
- package/dist/api/compiler/vfs-match.js +587 -0
- package/dist/api/library/ast.d.ts +74 -0
- package/dist/api/library/ast.generated.d.ts +1145 -0
- package/dist/api/library/ast.generated.js +3 -0
- package/dist/api/library/ast.js +5 -0
- package/dist/api/library/checker.d.ts +51 -0
- package/dist/api/library/checker.js +318 -0
- package/dist/api/library/compiler-options.generated.d.ts +108 -0
- package/dist/api/library/compiler-options.generated.js +3 -0
- package/dist/api/library/diagnostics.d.ts +13 -0
- package/dist/api/library/diagnostics.js +50 -0
- package/dist/api/library/disk.d.ts +13 -0
- package/dist/api/library/disk.js +66 -0
- package/dist/api/library/enums.generated.d.ts +891 -0
- package/dist/api/library/enums.generated.js +916 -0
- package/dist/api/library/errors.d.ts +13 -0
- package/dist/api/library/errors.js +24 -0
- package/dist/api/library/host.d.ts +24 -0
- package/dist/api/library/host.js +52 -0
- package/dist/api/library/index.d.ts +14 -0
- package/dist/api/library/index.js +15 -0
- package/dist/api/library/nodes.d.ts +51 -0
- package/dist/api/library/nodes.js +196 -0
- package/dist/api/library/options.d.ts +144 -0
- package/dist/api/library/options.js +308 -0
- package/dist/api/library/parse.d.ts +19 -0
- package/dist/api/library/parse.js +41 -0
- package/dist/api/library/program.d.ts +21 -0
- package/dist/api/library/program.js +234 -0
- package/dist/api/library/symbols.d.ts +8 -0
- package/dist/api/library/symbols.js +11 -0
- package/dist/api/library/types.d.ts +313 -0
- package/dist/api/library/types.js +6 -0
- package/package.json +22 -8
- package/src/compiler/ast-utilities.ts +548 -0
- package/src/compiler/ast.ts +12862 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2703 -0
- package/src/compiler/build-info.ts +1197 -0
- package/src/compiler/character-codes.ts +323 -0
- package/src/compiler/checker-calls.ts +2155 -0
- package/src/compiler/checker-classes.ts +706 -0
- package/src/compiler/checker-contextual.ts +1457 -0
- package/src/compiler/checker-declaration-order.ts +438 -0
- package/src/compiler/checker-declarations.ts +1194 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +359 -0
- package/src/compiler/checker-destructuring.ts +805 -0
- package/src/compiler/checker-elaboration.ts +477 -0
- package/src/compiler/checker-emit-helpers.ts +224 -0
- package/src/compiler/checker-emit-resolver.ts +769 -0
- package/src/compiler/checker-evaluator.ts +243 -0
- package/src/compiler/checker-expressions.ts +1831 -0
- package/src/compiler/checker-features.ts +361 -0
- package/src/compiler/checker-flow.ts +394 -0
- package/src/compiler/checker-functions.ts +1296 -0
- package/src/compiler/checker-generated-code.ts +227 -0
- package/src/compiler/checker-globals.ts +52 -0
- package/src/compiler/checker-grammar.ts +3584 -0
- package/src/compiler/checker-heritage.ts +1233 -0
- package/src/compiler/checker-inference.ts +2576 -0
- package/src/compiler/checker-iteration.ts +1206 -0
- package/src/compiler/checker-javascript.ts +502 -0
- package/src/compiler/checker-jsdoc.ts +360 -0
- package/src/compiler/checker-jsx.ts +1924 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2436 -0
- package/src/compiler/checker-modules.ts +2886 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +575 -0
- package/src/compiler/checker-operators.ts +1422 -0
- package/src/compiler/checker-overloads.ts +328 -0
- package/src/compiler/checker-property-access.ts +906 -0
- package/src/compiler/checker-services.ts +1149 -0
- package/src/compiler/checker-signatures.ts +1032 -0
- package/src/compiler/checker-source-file.ts +732 -0
- package/src/compiler/checker-statements.ts +292 -0
- package/src/compiler/checker-super.ts +261 -0
- package/src/compiler/checker-symbol-types.ts +2107 -0
- package/src/compiler/checker-symbols.ts +2150 -0
- package/src/compiler/checker-type-factory.ts +2579 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2502 -0
- package/src/compiler/checker-types.ts +2340 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1116 -0
- package/src/compiler/command-line.ts +436 -0
- package/src/compiler/compile-program.ts +439 -0
- package/src/compiler/decoder.ts +1209 -0
- package/src/compiler/diagnostic-locales.ts +86 -0
- package/src/compiler/diagnostic-messages.ts +2349 -0
- package/src/compiler/diagnostics.ts +897 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +673 -0
- package/src/compiler/file-loader.ts +1528 -0
- package/src/compiler/file-system.ts +143 -0
- package/src/compiler/flow.ts +89 -0
- package/src/compiler/help.ts +473 -0
- package/src/compiler/incremental.ts +2784 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +894 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +98 -0
- package/src/compiler/locale-data.ts +203 -0
- package/src/compiler/locale.ts +307 -0
- package/src/compiler/locales/cs-CZ.ts +5 -0
- package/src/compiler/locales/de-DE.ts +5 -0
- package/src/compiler/locales/es-ES.ts +5 -0
- package/src/compiler/locales/fr-FR.ts +5 -0
- package/src/compiler/locales/it-IT.ts +5 -0
- package/src/compiler/locales/ja-JP.ts +5 -0
- package/src/compiler/locales/ko-KR.ts +5 -0
- package/src/compiler/locales/pl-PL.ts +5 -0
- package/src/compiler/locales/pt-BR.ts +5 -0
- package/src/compiler/locales/ru-RU.ts +5 -0
- package/src/compiler/locales/tr-TR.ts +5 -0
- package/src/compiler/locales/zh-CN.ts +5 -0
- package/src/compiler/locales/zh-TW.ts +5 -0
- package/src/compiler/module-resolution-types.ts +243 -0
- package/src/compiler/module-resolution.ts +2072 -0
- package/src/compiler/module-specifiers.ts +1491 -0
- package/src/compiler/name-resolver.ts +646 -0
- package/src/compiler/node-builder-names.ts +1069 -0
- package/src/compiler/node-builder-pseudo.ts +892 -0
- package/src/compiler/node-builder-reuse.ts +764 -0
- package/src/compiler/node-builder.ts +3425 -0
- package/src/compiler/option-declarations.ts +1560 -0
- package/src/compiler/options.ts +1576 -0
- package/src/compiler/output-paths.ts +334 -0
- package/src/compiler/package-json.ts +1083 -0
- package/src/compiler/parallel-check.ts +1951 -0
- package/src/compiler/parallel-parse.ts +590 -0
- package/src/compiler/parse-thread.ts +140 -0
- package/src/compiler/parser.ts +7716 -0
- package/src/compiler/path.ts +717 -0
- package/src/compiler/printer/async-helpers.ts +183 -0
- package/src/compiler/printer/auto-generate.ts +27 -0
- package/src/compiler/printer/decorator-helpers.ts +218 -0
- package/src/compiler/printer/emit-context.ts +679 -0
- package/src/compiler/printer/emit-flags.ts +64 -0
- package/src/compiler/printer/factory-base.ts +2577 -0
- package/src/compiler/printer/factory.ts +764 -0
- package/src/compiler/printer/helpers.ts +291 -0
- package/src/compiler/printer/name-generator.ts +372 -0
- package/src/compiler/printer/printer.ts +5072 -0
- package/src/compiler/printer/text-writer.ts +183 -0
- package/src/compiler/printer/utilities.ts +884 -0
- package/src/compiler/program-checker.ts +592 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1419 -0
- package/src/compiler/pseudo-bigint.ts +62 -0
- package/src/compiler/regexp-checker.ts +1142 -0
- package/src/compiler/relations.ts +5149 -0
- package/src/compiler/reparser.ts +1566 -0
- package/src/compiler/scanner.ts +2951 -0
- package/src/compiler/show-config.ts +239 -0
- package/src/compiler/side-state.ts +125 -0
- package/src/compiler/sourcemap.ts +366 -0
- package/src/compiler/spelling.ts +122 -0
- package/src/compiler/symbol-accessibility.ts +1071 -0
- package/src/compiler/symbol.ts +439 -0
- package/src/compiler/symlinks.ts +137 -0
- package/src/compiler/syntax-kind.ts +391 -0
- package/src/compiler/thread-entry.ts +191 -0
- package/src/compiler/timeline.ts +53 -0
- package/src/compiler/transformers/alias-references.ts +757 -0
- package/src/compiler/transformers/async-utilities.ts +335 -0
- package/src/compiler/transformers/async.ts +838 -0
- package/src/compiler/transformers/class-fields.ts +2967 -0
- package/src/compiler/transformers/class-utilities.ts +324 -0
- package/src/compiler/transformers/commonjs-module.ts +1621 -0
- package/src/compiler/transformers/const-enum-inliner.ts +50 -0
- package/src/compiler/transformers/declarations-diagnostics.ts +832 -0
- package/src/compiler/transformers/declarations-pseudo.ts +966 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1859 -0
- package/src/compiler/transformers/declarations-tracker.ts +269 -0
- package/src/compiler/transformers/declarations.ts +3120 -0
- package/src/compiler/transformers/decorator-metadata.ts +697 -0
- package/src/compiler/transformers/decorator-utilities.ts +283 -0
- package/src/compiler/transformers/destructuring.ts +708 -0
- package/src/compiler/transformers/downlevel.ts +50 -0
- package/src/compiler/transformers/emit-resolver.ts +258 -0
- package/src/compiler/transformers/es-decorators.ts +2682 -0
- package/src/compiler/transformers/exponentiation.ts +80 -0
- package/src/compiler/transformers/external-module-info.ts +412 -0
- package/src/compiler/transformers/for-await.ts +687 -0
- package/src/compiler/transformers/import-elision.ts +152 -0
- package/src/compiler/transformers/jsx-entities.ts +256 -0
- package/src/compiler/transformers/jsx.ts +824 -0
- package/src/compiler/transformers/legacy-decorators.ts +726 -0
- package/src/compiler/transformers/logical-assignment.ts +75 -0
- package/src/compiler/transformers/module-utilities.ts +42 -0
- package/src/compiler/transformers/module.ts +474 -0
- package/src/compiler/transformers/named-evaluation.ts +389 -0
- package/src/compiler/transformers/nullish-coalescing.ts +35 -0
- package/src/compiler/transformers/object-rest-spread.ts +577 -0
- package/src/compiler/transformers/optional-catch.ts +29 -0
- package/src/compiler/transformers/optional-chain.ts +246 -0
- package/src/compiler/transformers/reference-resolver.ts +1201 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +245 -0
- package/src/compiler/transformers/syntax-facts.ts +353 -0
- package/src/compiler/transformers/tagged-template.ts +167 -0
- package/src/compiler/transformers/transformer.ts +56 -0
- package/src/compiler/transformers/type-eraser.ts +520 -0
- package/src/compiler/transformers/type-serialization.ts +374 -0
- package/src/compiler/transformers/using.ts +613 -0
- package/src/compiler/transformers/utilities.ts +419 -0
- package/src/compiler/transformers/visitor-base.ts +1601 -0
- package/src/compiler/transformers/visitor-hooks.ts +252 -0
- package/src/compiler/tsc-build.ts +1418 -0
- package/src/compiler/tsc-cli.ts +666 -0
- package/src/compiler/tsc-compile.ts +437 -0
- package/src/compiler/tsc-watch.ts +854 -0
- package/src/compiler/tsconfig.ts +1574 -0
- package/src/compiler/type-printer.ts +110 -0
- package/src/compiler/types.ts +115 -0
- package/src/compiler/unicode-identifiers.ts +212 -0
- package/src/compiler/unicode-properties.ts +537 -0
- package/src/compiler/vfs-match.ts +597 -0
- package/src/compiler/xxh3.ts +650 -0
- package/src/library/ast.generated.ts +1685 -0
- package/src/library/ast.ts +104 -0
- package/src/library/checker.ts +384 -0
- package/src/library/compiler-options.generated.ts +114 -0
- package/src/library/diagnostics.ts +72 -0
- package/src/library/disk.ts +73 -0
- package/src/library/enums.generated.ts +1024 -0
- package/src/library/errors.ts +26 -0
- package/src/library/host.ts +63 -0
- package/src/library/index.ts +71 -0
- package/src/library/nodes.ts +232 -0
- package/src/library/options.ts +449 -0
- package/src/library/parse.ts +63 -0
- package/src/library/program.ts +293 -0
- package/src/library/symbols.ts +15 -0
- package/src/library/types.ts +359 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
// Types from type nodes: `getTypeFromTypeNode` and the resolution of type references.
|
|
2
|
+
import { getExpression, getName, getText, getType, getSymbol, getBody, getTypeArguments, } from './ast.js';
|
|
3
|
+
import { declarationNameToString, getSourceFileOfNode, getThisContainer, isClassLike, isStatic, isDeclarationStatementKind, } from './binder-utilities.js';
|
|
4
|
+
import { getSymbolId } from './symbol.js';
|
|
5
|
+
import { TupleElementInfo, TypeAlias, UniqueESSymbolType, emptyTypes, newTypeMapper, } from './checker-types.js';
|
|
6
|
+
import { createArrayType, aliasKey, createDeferredTypeReference, createNormalizedTupleType, createTypeReferenceEx, getIntersectionTypeEx, getRegularTypeOfLiteralType, getTemplateLiteralType, getTupleTargetType, getUnionTypeEx, getIntersectionType, everyType, isArrayOrTupleType, isPatternLiteralType, newObjectType, typeListKey, } from './checker-type-factory.js';
|
|
7
|
+
import { getMembersOfSymbol, getMergedSymbol, getSymbolOfDeclaration, resolveAlias, resolveEntityName, } from './checker-symbols.js';
|
|
8
|
+
import { getTypeFromImportTypeNode } from './checker-modules.js';
|
|
9
|
+
import { fillMissingTypeArguments, getDeclaredTypeOfClassOrInterface, getDeclaredTypeOfSymbol, getDeclaredTypeOfTypeParameter, getConstraintOfTypeParameter, getLocalTypeParametersOfClassOrInterfaceOrTypeAlias, getMinTypeArgumentCount, tryGetDeclaredTypeOfSymbol, } from './checker-declared-types.js';
|
|
10
|
+
import { addOptionality, getNullableType, getWidenedType } from './checker-symbol-types.js';
|
|
11
|
+
import { instantiateTypeWithAlias } from './instantiation.js';
|
|
12
|
+
import { symbolToString, typeToString } from './type-printer.js';
|
|
13
|
+
import { getIndexType, getIndexedAccessTypeEx, getNoInferType, getStringMappingType, getTypeFromConditionalTypeNode, getTypeFromMappedTypeNode, intrinsicTypeKind, getSubstitutionType, getActualTypeVariable, getHomomorphicTypeVariable, getTypeParameterFromMappedType, } from './checker-type-operators.js';
|
|
14
|
+
import { checkExpression, checkExpressionCached, getResolvedSymbol } from './checker-expressions.js';
|
|
15
|
+
import { checkExpressionWithTypeArguments } from './checker-calls.js';
|
|
16
|
+
import { getIntendedTypeFromJSDocTypeReference } from './checker-jsdoc.js';
|
|
17
|
+
import { getCombinedNodeFlags, hasSyntacticModifier } from './binder-utilities.js';
|
|
18
|
+
export function getTypeFromTypeNode(c, node) {
|
|
19
|
+
return getConditionalFlowTypeOfType(c, getTypeFromTypeNodeWorker(c, node), node);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `t` with the constraints implied by enclosing conditional types, as a substitution type: in
|
|
23
|
+
* `T extends string ? X : Y`, references to T in X are known to be strings.
|
|
24
|
+
*/
|
|
25
|
+
function getConditionalFlowTypeOfType(c, t, start) {
|
|
26
|
+
let constraints;
|
|
27
|
+
let covariant = true;
|
|
28
|
+
for (let node = start; node !== undefined && !isStatementLike(node); node = node.parent) {
|
|
29
|
+
const parent = node.parent;
|
|
30
|
+
if (parent === undefined)
|
|
31
|
+
break;
|
|
32
|
+
// Only parameter positions flip variance; `keyof` is mostly used invariantly in indexed accesses.
|
|
33
|
+
if (parent.kind === 170 /* SyntaxKind.Parameter */)
|
|
34
|
+
covariant = !covariant;
|
|
35
|
+
// Type variables always substitute, as even contravariant positions may rely on their constraints.
|
|
36
|
+
if ((covariant || (t.flags & 34078720 /* TypeFlags.TypeVariable */) !== 0) &&
|
|
37
|
+
parent.kind === 195 /* SyntaxKind.ConditionalType */ &&
|
|
38
|
+
node === parent.trueType) {
|
|
39
|
+
const conditional = parent;
|
|
40
|
+
const constraint = getImpliedConstraint(c, t, conditional.checkType, conditional.extendsType);
|
|
41
|
+
if (constraint !== undefined)
|
|
42
|
+
(constraints ??= []).push(constraint);
|
|
43
|
+
}
|
|
44
|
+
else if ((t.flags & 524288 /* TypeFlags.TypeParameter */) !== 0 &&
|
|
45
|
+
parent.kind === 201 /* SyntaxKind.MappedType */ &&
|
|
46
|
+
parent.nameType === undefined &&
|
|
47
|
+
node === parent.type) {
|
|
48
|
+
// Homomorphic mapped types over arrays and tuples map numeric keys only.
|
|
49
|
+
const mappedType = getTypeFromTypeNode(c, parent);
|
|
50
|
+
if (getTypeParameterFromMappedType(c, mappedType) === getActualTypeVariable(c, t)) {
|
|
51
|
+
const typeParameter = getHomomorphicTypeVariable(c, mappedType);
|
|
52
|
+
if (typeParameter !== undefined) {
|
|
53
|
+
const constraint = getConstraintOfTypeParameter(c, typeParameter);
|
|
54
|
+
if (constraint !== undefined && everyType(constraint, (u) => isArrayOrTupleType(c, u)))
|
|
55
|
+
(constraints ??= []).push(getUnionTypeEx(c, [c.numberType, c.numericStringType], 1 /* UnionReduction.Literal */, undefined, undefined));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return constraints !== undefined ? getSubstitutionType(c, t, getIntersectionType(c, constraints)) : t;
|
|
61
|
+
}
|
|
62
|
+
function getImpliedConstraint(c, t, checkNode, extendsNode) {
|
|
63
|
+
if (isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode))
|
|
64
|
+
return getImpliedConstraint(c, t, checkNode.elements.nodes[0], extendsNode.elements.nodes[0]);
|
|
65
|
+
if (getActualTypeVariable(c, getTypeFromTypeNode(c, checkNode)) === getActualTypeVariable(c, t))
|
|
66
|
+
return getTypeFromTypeNode(c, extendsNode);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
function isUnaryTupleTypeNode(node) {
|
|
70
|
+
return node.kind === 190 /* SyntaxKind.TupleType */ && node.elements.nodes.length === 1;
|
|
71
|
+
}
|
|
72
|
+
/** A statement, declaration statement or block, which ends the search for enclosing conditional types. */
|
|
73
|
+
function isStatementLike(node) {
|
|
74
|
+
switch (node.kind) {
|
|
75
|
+
case 242 /* SyntaxKind.Block */:
|
|
76
|
+
case 253 /* SyntaxKind.BreakStatement */:
|
|
77
|
+
case 252 /* SyntaxKind.ContinueStatement */:
|
|
78
|
+
case 260 /* SyntaxKind.DebuggerStatement */:
|
|
79
|
+
case 247 /* SyntaxKind.DoStatement */:
|
|
80
|
+
case 245 /* SyntaxKind.ExpressionStatement */:
|
|
81
|
+
case 243 /* SyntaxKind.EmptyStatement */:
|
|
82
|
+
case 250 /* SyntaxKind.ForInStatement */:
|
|
83
|
+
case 251 /* SyntaxKind.ForOfStatement */:
|
|
84
|
+
case 249 /* SyntaxKind.ForStatement */:
|
|
85
|
+
case 246 /* SyntaxKind.IfStatement */:
|
|
86
|
+
case 257 /* SyntaxKind.LabeledStatement */:
|
|
87
|
+
case 254 /* SyntaxKind.ReturnStatement */:
|
|
88
|
+
case 256 /* SyntaxKind.SwitchStatement */:
|
|
89
|
+
case 258 /* SyntaxKind.ThrowStatement */:
|
|
90
|
+
case 259 /* SyntaxKind.TryStatement */:
|
|
91
|
+
case 244 /* SyntaxKind.VariableStatement */:
|
|
92
|
+
case 248 /* SyntaxKind.WhileStatement */:
|
|
93
|
+
case 255 /* SyntaxKind.WithStatement */:
|
|
94
|
+
case 347 /* SyntaxKind.NotEmittedStatement */:
|
|
95
|
+
case 315 /* SyntaxKind.JSDoc */:
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return isDeclarationStatementKind(node.kind);
|
|
99
|
+
}
|
|
100
|
+
function getTypeFromTypeNodeWorker(c, node) {
|
|
101
|
+
switch (node.kind) {
|
|
102
|
+
case 132 /* SyntaxKind.AnyKeyword */:
|
|
103
|
+
case 310 /* SyntaxKind.JSDocAllType */:
|
|
104
|
+
return c.anyType;
|
|
105
|
+
case 312 /* SyntaxKind.JSDocNonNullableType */:
|
|
106
|
+
return getTypeFromTypeNode(c, getType(node));
|
|
107
|
+
case 311 /* SyntaxKind.JSDocNullableType */: {
|
|
108
|
+
const t = getTypeFromTypeNode(c, getType(node));
|
|
109
|
+
return c.strictNullChecks ? getNullableType(c, t, 8 /* TypeFlags.Null */) : t;
|
|
110
|
+
}
|
|
111
|
+
case 314 /* SyntaxKind.JSDocVariadicType */:
|
|
112
|
+
return createArrayType(c, getTypeFromTypeNode(c, getType(node)));
|
|
113
|
+
case 313 /* SyntaxKind.JSDocOptionalType */:
|
|
114
|
+
return addOptionality(c, getTypeFromTypeNode(c, getType(node)), false, true);
|
|
115
|
+
case 159 /* SyntaxKind.UnknownKeyword */:
|
|
116
|
+
return c.unknownType;
|
|
117
|
+
case 154 /* SyntaxKind.StringKeyword */:
|
|
118
|
+
return c.stringType;
|
|
119
|
+
case 150 /* SyntaxKind.NumberKeyword */:
|
|
120
|
+
return c.numberType;
|
|
121
|
+
case 163 /* SyntaxKind.BigIntKeyword */:
|
|
122
|
+
return c.bigintType;
|
|
123
|
+
case 135 /* SyntaxKind.BooleanKeyword */:
|
|
124
|
+
return c.booleanType;
|
|
125
|
+
case 155 /* SyntaxKind.SymbolKeyword */:
|
|
126
|
+
return c.esSymbolType;
|
|
127
|
+
case 115 /* SyntaxKind.VoidKeyword */:
|
|
128
|
+
return c.voidType;
|
|
129
|
+
case 157 /* SyntaxKind.UndefinedKeyword */:
|
|
130
|
+
return c.undefinedType;
|
|
131
|
+
case 105 /* SyntaxKind.NullKeyword */:
|
|
132
|
+
return c.nullType;
|
|
133
|
+
case 146 /* SyntaxKind.NeverKeyword */:
|
|
134
|
+
return c.neverType;
|
|
135
|
+
case 151 /* SyntaxKind.ObjectKeyword */:
|
|
136
|
+
return c.nonPrimitiveType;
|
|
137
|
+
case 141 /* SyntaxKind.IntrinsicKeyword */:
|
|
138
|
+
return c.intrinsicMarkerType;
|
|
139
|
+
case 198 /* SyntaxKind.ThisType */:
|
|
140
|
+
case 109 /* SyntaxKind.ThisKeyword */:
|
|
141
|
+
return getTypeFromThisTypeNode(c, node);
|
|
142
|
+
case 202 /* SyntaxKind.LiteralType */:
|
|
143
|
+
return getTypeFromLiteralTypeNode(c, node);
|
|
144
|
+
case 184 /* SyntaxKind.TypeReference */:
|
|
145
|
+
case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
146
|
+
return getTypeFromTypeReference(c, node);
|
|
147
|
+
case 183 /* SyntaxKind.TypePredicate */:
|
|
148
|
+
return node.assertsModifier !== undefined ? c.voidType : c.booleanType;
|
|
149
|
+
case 187 /* SyntaxKind.TypeQuery */:
|
|
150
|
+
return getTypeFromTypeQueryNode(c, node);
|
|
151
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
152
|
+
case 190 /* SyntaxKind.TupleType */:
|
|
153
|
+
return getTypeFromArrayOrTupleTypeNode(c, node);
|
|
154
|
+
case 191 /* SyntaxKind.OptionalType */:
|
|
155
|
+
return addOptionality(c, getTypeFromTypeNode(c, node.type), true, true);
|
|
156
|
+
case 193 /* SyntaxKind.UnionType */:
|
|
157
|
+
return getTypeFromUnionTypeNode(c, node);
|
|
158
|
+
case 194 /* SyntaxKind.IntersectionType */:
|
|
159
|
+
return getTypeFromIntersectionTypeNode(c, node);
|
|
160
|
+
case 203 /* SyntaxKind.NamedTupleMember */:
|
|
161
|
+
return getTypeFromNamedTupleTypeNode(c, node);
|
|
162
|
+
case 197 /* SyntaxKind.ParenthesizedType */:
|
|
163
|
+
return getTypeFromTypeNode(c, getType(node));
|
|
164
|
+
case 192 /* SyntaxKind.RestType */:
|
|
165
|
+
return getTypeFromRestTypeNode(c, node);
|
|
166
|
+
case 185 /* SyntaxKind.FunctionType */:
|
|
167
|
+
case 186 /* SyntaxKind.ConstructorType */:
|
|
168
|
+
case 188 /* SyntaxKind.TypeLiteral */:
|
|
169
|
+
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(c, node);
|
|
170
|
+
case 199 /* SyntaxKind.TypeOperator */:
|
|
171
|
+
return getTypeFromTypeOperatorNode(c, node);
|
|
172
|
+
case 200 /* SyntaxKind.IndexedAccessType */:
|
|
173
|
+
return getTypeFromIndexedAccessTypeNode(c, node);
|
|
174
|
+
case 204 /* SyntaxKind.TemplateLiteralType */:
|
|
175
|
+
return getTypeFromTemplateTypeNode(c, node);
|
|
176
|
+
case 201 /* SyntaxKind.MappedType */:
|
|
177
|
+
return getTypeFromMappedTypeNode(c, node);
|
|
178
|
+
case 195 /* SyntaxKind.ConditionalType */:
|
|
179
|
+
return getTypeFromConditionalTypeNode(c, node);
|
|
180
|
+
case 196 /* SyntaxKind.InferType */: {
|
|
181
|
+
let type = c.resolvedTypes.get(node.id);
|
|
182
|
+
if (type === undefined) {
|
|
183
|
+
type = getDeclaredTypeOfTypeParameter(c, getSymbolOfDeclaration(c, node.typeParameter));
|
|
184
|
+
c.resolvedTypes.set(node.id, type);
|
|
185
|
+
}
|
|
186
|
+
return type;
|
|
187
|
+
}
|
|
188
|
+
case 206 /* SyntaxKind.ImportType */:
|
|
189
|
+
return getTypeFromImportTypeNode(c, node);
|
|
190
|
+
}
|
|
191
|
+
return c.errorType;
|
|
192
|
+
}
|
|
193
|
+
export function getTypeFromThisTypeNode(c, node) {
|
|
194
|
+
let type = c.resolvedTypes.get(node.id);
|
|
195
|
+
if (type === undefined) {
|
|
196
|
+
type = getThisType(c, node);
|
|
197
|
+
c.resolvedTypes.set(node.id, type);
|
|
198
|
+
}
|
|
199
|
+
return type;
|
|
200
|
+
}
|
|
201
|
+
function getThisType(c, node) {
|
|
202
|
+
const container = getThisContainer(node, false, false);
|
|
203
|
+
const parent = container.parent;
|
|
204
|
+
if (parent !== undefined && (isClassLike(parent) || parent.kind === 265 /* SyntaxKind.InterfaceDeclaration */)) {
|
|
205
|
+
if (!isStatic(container) && (container.kind !== 177 /* SyntaxKind.Constructor */ || isDescendant(node, getBody(container))))
|
|
206
|
+
return getDeclaredTypeOfClassOrInterface(c, getSymbolOfDeclaration(c, parent)).thisType ?? c.errorType;
|
|
207
|
+
}
|
|
208
|
+
c.error(node, 684 /* Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface */);
|
|
209
|
+
return c.errorType;
|
|
210
|
+
}
|
|
211
|
+
function isDescendant(node, ancestor) {
|
|
212
|
+
if (ancestor === undefined)
|
|
213
|
+
return false;
|
|
214
|
+
for (let n = node; n !== undefined; n = n.parent)
|
|
215
|
+
if (n === ancestor)
|
|
216
|
+
return true;
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
function getTypeFromLiteralTypeNode(c, node) {
|
|
220
|
+
if (node.literal.kind === 105 /* SyntaxKind.NullKeyword */)
|
|
221
|
+
return c.nullType;
|
|
222
|
+
let type = c.resolvedTypes.get(node.id);
|
|
223
|
+
if (type === undefined) {
|
|
224
|
+
type = getRegularTypeOfLiteralType(c, checkExpression(c, node.literal));
|
|
225
|
+
c.resolvedTypes.set(node.id, type);
|
|
226
|
+
}
|
|
227
|
+
return type;
|
|
228
|
+
}
|
|
229
|
+
function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(c, node) {
|
|
230
|
+
let type = c.resolvedTypes.get(node.id);
|
|
231
|
+
if (type === undefined) {
|
|
232
|
+
// Members resolve lazily.
|
|
233
|
+
const alias = getAliasForTypeNode(c, node);
|
|
234
|
+
const symbol = getSymbol(node);
|
|
235
|
+
if (symbol === undefined || (getMembersOfSymbol(c, symbol).size === 0 && alias === undefined))
|
|
236
|
+
type = c.emptyTypeLiteralType;
|
|
237
|
+
else {
|
|
238
|
+
const t = newObjectType(c, 16 /* ObjectFlags.Anonymous */, symbol);
|
|
239
|
+
t.alias = alias;
|
|
240
|
+
type = t;
|
|
241
|
+
}
|
|
242
|
+
c.resolvedTypes.set(node.id, type);
|
|
243
|
+
}
|
|
244
|
+
return type;
|
|
245
|
+
}
|
|
246
|
+
export function getTypeFromIndexedAccessTypeNode(c, node) {
|
|
247
|
+
let type = c.resolvedTypes.get(node.id);
|
|
248
|
+
if (type === undefined) {
|
|
249
|
+
const objectType = getTypeFromTypeNode(c, node.objectType);
|
|
250
|
+
const indexType = getTypeFromTypeNode(c, node.indexType);
|
|
251
|
+
type = getIndexedAccessTypeEx(c, objectType, indexType, 0, node, getAliasForTypeNode(c, node));
|
|
252
|
+
c.resolvedTypes.set(node.id, type);
|
|
253
|
+
}
|
|
254
|
+
return type;
|
|
255
|
+
}
|
|
256
|
+
function getTypeFromTypeOperatorNode(c, node) {
|
|
257
|
+
let type = c.resolvedTypes.get(node.id);
|
|
258
|
+
if (type === undefined) {
|
|
259
|
+
const argType = node.type;
|
|
260
|
+
switch (node.operator) {
|
|
261
|
+
case 143 /* SyntaxKind.KeyOfKeyword */:
|
|
262
|
+
type = getIndexType(c, getTypeFromTypeNode(c, argType));
|
|
263
|
+
break;
|
|
264
|
+
case 158 /* SyntaxKind.UniqueKeyword */:
|
|
265
|
+
type =
|
|
266
|
+
argType.kind === 155 /* SyntaxKind.SymbolKeyword */
|
|
267
|
+
? getESSymbolLikeTypeForNode(c, walkUpParenthesizedTypes(node.parent))
|
|
268
|
+
: c.errorType;
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
type = getTypeFromTypeNode(c, argType);
|
|
272
|
+
}
|
|
273
|
+
c.resolvedTypes.set(node.id, type);
|
|
274
|
+
}
|
|
275
|
+
return type;
|
|
276
|
+
}
|
|
277
|
+
function walkUpParenthesizedTypes(node) {
|
|
278
|
+
let n = node;
|
|
279
|
+
while (n.kind === 197 /* SyntaxKind.ParenthesizedType */ && n.parent !== undefined)
|
|
280
|
+
n = n.parent;
|
|
281
|
+
return n;
|
|
282
|
+
}
|
|
283
|
+
/** A const variable of a variable statement, a static readonly property, or a readonly property signature. */
|
|
284
|
+
function isValidESSymbolDeclaration(node) {
|
|
285
|
+
switch (node.kind) {
|
|
286
|
+
case 261 /* SyntaxKind.VariableDeclaration */: {
|
|
287
|
+
const list = node.parent;
|
|
288
|
+
return ((getCombinedNodeFlags(node) & 6 /* NodeFlags.Constant */) === 2 /* NodeFlags.Const */ &&
|
|
289
|
+
getName(node).kind === 79 /* SyntaxKind.Identifier */ &&
|
|
290
|
+
list.kind === 262 /* SyntaxKind.VariableDeclarationList */ &&
|
|
291
|
+
list.parent.kind === 244 /* SyntaxKind.VariableStatement */);
|
|
292
|
+
}
|
|
293
|
+
case 173 /* SyntaxKind.PropertyDeclaration */:
|
|
294
|
+
return hasSyntacticModifier(node, 8 /* ModifierFlags.Readonly */) && isStatic(node);
|
|
295
|
+
case 172 /* SyntaxKind.PropertySignature */:
|
|
296
|
+
return hasSyntacticModifier(node, 8 /* ModifierFlags.Readonly */);
|
|
297
|
+
}
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
export function getESSymbolLikeTypeForNode(c, node) {
|
|
301
|
+
if (isValidESSymbolDeclaration(node)) {
|
|
302
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
303
|
+
if (symbol !== undefined) {
|
|
304
|
+
let uniqueType = c.uniqueESSymbolTypes.get(symbol);
|
|
305
|
+
if (uniqueType === undefined) {
|
|
306
|
+
uniqueType = new UniqueESSymbolType(c.nextTypeId(), symbol, '@' + symbol.name + '@' + getSymbolId(symbol));
|
|
307
|
+
c.uniqueESSymbolTypes.set(symbol, uniqueType);
|
|
308
|
+
}
|
|
309
|
+
return uniqueType;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return c.esSymbolType;
|
|
313
|
+
}
|
|
314
|
+
// ---- Type references
|
|
315
|
+
function isConstTypeReference(node) {
|
|
316
|
+
if (node.kind !== 184 /* SyntaxKind.TypeReference */)
|
|
317
|
+
return false;
|
|
318
|
+
const ref = node;
|
|
319
|
+
return (ref.typeName.kind === 79 /* SyntaxKind.Identifier */ && getText(ref.typeName) === 'const' && ref.typeArguments === undefined);
|
|
320
|
+
}
|
|
321
|
+
function isAssertionExpression(node) {
|
|
322
|
+
return (node !== undefined && (node.kind === 235 /* SyntaxKind.AsExpression */ || node.kind === 217 /* SyntaxKind.TypeAssertionExpression */));
|
|
323
|
+
}
|
|
324
|
+
export function getTypeFromTypeReference(c, node) {
|
|
325
|
+
let type = c.resolvedTypes.get(node.id);
|
|
326
|
+
if (type === undefined) {
|
|
327
|
+
if (isConstTypeReference(node) && isAssertionExpression(node.parent))
|
|
328
|
+
type = checkExpressionCached(c, getExpression(node.parent));
|
|
329
|
+
else
|
|
330
|
+
type =
|
|
331
|
+
getIntendedTypeFromJSDocTypeReference(c, node) ??
|
|
332
|
+
getTypeReferenceType(c, node, getSymbolFromTypeReference(c, node));
|
|
333
|
+
c.resolvedTypes.set(node.id, type);
|
|
334
|
+
}
|
|
335
|
+
return type;
|
|
336
|
+
}
|
|
337
|
+
export function getSymbolFromTypeReference(c, node) {
|
|
338
|
+
let symbol = c.resolvedSymbols.get(node.id);
|
|
339
|
+
if (symbol === undefined) {
|
|
340
|
+
if (isConstTypeReference(node) && isAssertionExpression(node.parent))
|
|
341
|
+
symbol = c.unknownSymbol;
|
|
342
|
+
else
|
|
343
|
+
symbol = resolveTypeReferenceName(c, node, 788968 /* SymbolFlags.Type */, false);
|
|
344
|
+
c.resolvedSymbols.set(node.id, symbol);
|
|
345
|
+
}
|
|
346
|
+
return symbol;
|
|
347
|
+
}
|
|
348
|
+
function getTypeReferenceName(node) {
|
|
349
|
+
if (node.kind === 184 /* SyntaxKind.TypeReference */)
|
|
350
|
+
return node.typeName;
|
|
351
|
+
if (node.kind === 234 /* SyntaxKind.ExpressionWithTypeArguments */) {
|
|
352
|
+
const e = node.expression;
|
|
353
|
+
if (isEntityNameExpression(e))
|
|
354
|
+
return e;
|
|
355
|
+
}
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
function isEntityNameExpression(node) {
|
|
359
|
+
if (node.kind === 79 /* SyntaxKind.Identifier */)
|
|
360
|
+
return true;
|
|
361
|
+
if (node.kind === 212 /* SyntaxKind.PropertyAccessExpression */) {
|
|
362
|
+
const name = getName(node);
|
|
363
|
+
return name !== undefined && name.kind === 79 /* SyntaxKind.Identifier */ && isEntityNameExpression(getExpression(node));
|
|
364
|
+
}
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
export function resolveTypeReferenceName(c, typeReference, meaning, ignoreErrors) {
|
|
368
|
+
const name = getTypeReferenceName(typeReference);
|
|
369
|
+
if (name === undefined)
|
|
370
|
+
return c.unknownSymbol;
|
|
371
|
+
const symbol = resolveEntityName(c, name, meaning, ignoreErrors, false, undefined);
|
|
372
|
+
if (symbol !== undefined && symbol !== c.unknownSymbol)
|
|
373
|
+
return symbol;
|
|
374
|
+
if (ignoreErrors)
|
|
375
|
+
return c.unknownSymbol;
|
|
376
|
+
return getUnresolvedSymbolForEntityName(c, name);
|
|
377
|
+
}
|
|
378
|
+
export function getUnresolvedSymbolForEntityName(c, name) {
|
|
379
|
+
let identifier;
|
|
380
|
+
if (name.kind === 167 /* SyntaxKind.QualifiedName */)
|
|
381
|
+
identifier = name.right;
|
|
382
|
+
else if (name.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
|
|
383
|
+
identifier = getName(name);
|
|
384
|
+
else
|
|
385
|
+
identifier = name;
|
|
386
|
+
const text = getText(identifier);
|
|
387
|
+
if (text === '')
|
|
388
|
+
return c.unknownSymbol;
|
|
389
|
+
let parentSymbol;
|
|
390
|
+
if (name.kind === 167 /* SyntaxKind.QualifiedName */)
|
|
391
|
+
parentSymbol = getUnresolvedSymbolForEntityName(c, name.left);
|
|
392
|
+
else if (name.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
|
|
393
|
+
parentSymbol = getUnresolvedSymbolForEntityName(c, getExpression(name));
|
|
394
|
+
const path = parentSymbol !== undefined ? getSymbolPath(parentSymbol) + '.' + text : text;
|
|
395
|
+
let result = c.unresolvedSymbols.get(path);
|
|
396
|
+
if (result === undefined) {
|
|
397
|
+
result = c.newSymbolWithCheckFlags(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */);
|
|
398
|
+
c.unresolvedSymbols.set(path, result);
|
|
399
|
+
result.parent = parentSymbol;
|
|
400
|
+
c.symbolLinks(result).declaredType = c.unresolvedType;
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
function getSymbolPath(symbol) {
|
|
405
|
+
return symbol.parent !== undefined ? getSymbolPath(symbol.parent) + '.' + symbol.name : symbol.name;
|
|
406
|
+
}
|
|
407
|
+
export function getTypeReferenceType(c, node, symbol) {
|
|
408
|
+
if (symbol === c.unknownSymbol)
|
|
409
|
+
return c.errorType;
|
|
410
|
+
if ((symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) !== 0)
|
|
411
|
+
return getTypeFromClassOrInterfaceReference(c, node, symbol);
|
|
412
|
+
if ((symbol.flags & 524288 /* SymbolFlags.TypeAlias */) !== 0)
|
|
413
|
+
return getTypeFromTypeAliasReference(c, node, symbol);
|
|
414
|
+
// Enums and type parameters can't be generic.
|
|
415
|
+
const res = tryGetDeclaredTypeOfSymbol(c, symbol);
|
|
416
|
+
if (res !== undefined && checkNoTypeArguments(c, node, symbol))
|
|
417
|
+
return getRegularTypeOfLiteralType(c, res);
|
|
418
|
+
return c.errorType;
|
|
419
|
+
}
|
|
420
|
+
function typeArgumentNodesOf(node) {
|
|
421
|
+
const list = getTypeArguments(node);
|
|
422
|
+
return list !== undefined ? list.nodes : emptyNodes;
|
|
423
|
+
}
|
|
424
|
+
const emptyNodes = [];
|
|
425
|
+
export function getTypeArgumentsFromNode(c, node) {
|
|
426
|
+
return getTypesFromTypeNodes(c, typeArgumentNodesOf(node));
|
|
427
|
+
}
|
|
428
|
+
export function getTypesFromTypeNodes(c, nodes) {
|
|
429
|
+
const result = [];
|
|
430
|
+
for (const n of nodes)
|
|
431
|
+
result.push(getTypeFromTypeNode(c, n));
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
export function getTypeFromClassOrInterfaceReference(c, node, symbol) {
|
|
435
|
+
const t = getDeclaredTypeOfClassOrInterface(c, getMergedSymbol(c, symbol));
|
|
436
|
+
const typeParameters = t.localTypeParameters();
|
|
437
|
+
if (typeParameters.length === 0)
|
|
438
|
+
return checkNoTypeArguments(c, node, symbol) ? t : c.errorType;
|
|
439
|
+
const numTypeArguments = typeArgumentNodesOf(node).length;
|
|
440
|
+
const minTypeArgumentCount = getMinTypeArgumentCount(c, typeParameters);
|
|
441
|
+
const isJs = (node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0;
|
|
442
|
+
const isJsImplicitAny = !c.noImplicitAny && isJs;
|
|
443
|
+
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
|
|
444
|
+
const message = minTypeArgumentCount < typeParameters.length
|
|
445
|
+
? 839 /* Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments */
|
|
446
|
+
: 492 /* Diagnostics.Generic_type_0_requires_1_type_argument_s */;
|
|
447
|
+
c.error(node, message, typeToString(c, t, undefined, 1 << 1), String(minTypeArgumentCount), String(typeParameters.length));
|
|
448
|
+
if (!isJs)
|
|
449
|
+
return c.errorType;
|
|
450
|
+
}
|
|
451
|
+
if (node.kind === 184 /* SyntaxKind.TypeReference */ &&
|
|
452
|
+
isDeferredTypeReferenceNode(c, node, numTypeArguments !== typeParameters.length))
|
|
453
|
+
return createDeferredTypeReference(c, t, node, undefined, getAliasForTypeNode(c, node));
|
|
454
|
+
// Outer type parameters are supplied automatically; the reference gives the local ones.
|
|
455
|
+
const localTypeArguments = fillMissingTypeArguments(c, getTypeArgumentsFromNode(c, node), typeParameters, minTypeArgumentCount, isJs);
|
|
456
|
+
// localTypeArguments is a new list, so without outer type parameters it is the reference's own.
|
|
457
|
+
const outerCount = t.outerTypeParameterCount;
|
|
458
|
+
if (outerCount === 0)
|
|
459
|
+
return createTypeReferenceEx(c, t, localTypeArguments, 1073741824 /* ObjectFlags.FromTypeNode */);
|
|
460
|
+
const typeArguments = [];
|
|
461
|
+
for (let i = 0; i < outerCount; i++)
|
|
462
|
+
typeArguments.push(t.allTypeParameters[i]);
|
|
463
|
+
for (const typeArgument of localTypeArguments)
|
|
464
|
+
typeArguments.push(typeArgument);
|
|
465
|
+
return createTypeReferenceEx(c, t, typeArguments, 1073741824 /* ObjectFlags.FromTypeNode */);
|
|
466
|
+
}
|
|
467
|
+
export function checkNoTypeArguments(c, node, symbol) {
|
|
468
|
+
if (typeArgumentNodesOf(node).length === 0)
|
|
469
|
+
return true;
|
|
470
|
+
const typeName = symbol !== undefined
|
|
471
|
+
? symbolToString(c, symbol)
|
|
472
|
+
: declarationNameToString(getSourceFileOfNode(node), node.typeName);
|
|
473
|
+
c.error(node, 493 /* Diagnostics.Type_0_is_not_generic */, typeName);
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
/** Directly aliased references, and those possibly in circular chains of eagerly resolved types, are deferred. */
|
|
477
|
+
function isDeferredTypeReferenceNode(c, node, hasDefaultTypeArguments) {
|
|
478
|
+
if (getAliasSymbolForTypeNode(c, node) !== undefined)
|
|
479
|
+
return true;
|
|
480
|
+
if (!isResolvedByTypeAlias(node))
|
|
481
|
+
return false;
|
|
482
|
+
switch (node.kind) {
|
|
483
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
484
|
+
return mayResolveTypeAlias(c, node.elementType);
|
|
485
|
+
case 190 /* SyntaxKind.TupleType */:
|
|
486
|
+
return someMayResolveTypeAlias(c, node.elements.nodes);
|
|
487
|
+
case 184 /* SyntaxKind.TypeReference */:
|
|
488
|
+
return hasDefaultTypeArguments || someMayResolveTypeAlias(c, typeArgumentNodesOf(node));
|
|
489
|
+
}
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
function isResolvedByTypeAlias(node) {
|
|
493
|
+
const parent = node.parent;
|
|
494
|
+
switch (parent.kind) {
|
|
495
|
+
case 197 /* SyntaxKind.ParenthesizedType */:
|
|
496
|
+
case 203 /* SyntaxKind.NamedTupleMember */:
|
|
497
|
+
case 184 /* SyntaxKind.TypeReference */:
|
|
498
|
+
case 193 /* SyntaxKind.UnionType */:
|
|
499
|
+
case 194 /* SyntaxKind.IntersectionType */:
|
|
500
|
+
case 200 /* SyntaxKind.IndexedAccessType */:
|
|
501
|
+
case 195 /* SyntaxKind.ConditionalType */:
|
|
502
|
+
case 199 /* SyntaxKind.TypeOperator */:
|
|
503
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
504
|
+
case 190 /* SyntaxKind.TupleType */:
|
|
505
|
+
return isResolvedByTypeAlias(parent);
|
|
506
|
+
case 266 /* SyntaxKind.TypeAliasDeclaration */:
|
|
507
|
+
case 345 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
function mayResolveTypeAlias(c, node) {
|
|
513
|
+
switch (node.kind) {
|
|
514
|
+
case 184 /* SyntaxKind.TypeReference */:
|
|
515
|
+
return (resolveTypeReferenceName(c, node, 788968 /* SymbolFlags.Type */, false).flags & 524288 /* SymbolFlags.TypeAlias */) !== 0;
|
|
516
|
+
case 187 /* SyntaxKind.TypeQuery */:
|
|
517
|
+
return true;
|
|
518
|
+
case 199 /* SyntaxKind.TypeOperator */:
|
|
519
|
+
return (node.operator !== 158 /* SyntaxKind.UniqueKeyword */ &&
|
|
520
|
+
mayResolveTypeAlias(c, node.type));
|
|
521
|
+
case 197 /* SyntaxKind.ParenthesizedType */:
|
|
522
|
+
case 191 /* SyntaxKind.OptionalType */:
|
|
523
|
+
case 203 /* SyntaxKind.NamedTupleMember */:
|
|
524
|
+
return mayResolveTypeAlias(c, getType(node));
|
|
525
|
+
case 192 /* SyntaxKind.RestType */: {
|
|
526
|
+
const t = node.type;
|
|
527
|
+
return t.kind !== 189 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(c, t.elementType);
|
|
528
|
+
}
|
|
529
|
+
case 193 /* SyntaxKind.UnionType */:
|
|
530
|
+
return someMayResolveTypeAlias(c, node.types.nodes);
|
|
531
|
+
case 194 /* SyntaxKind.IntersectionType */:
|
|
532
|
+
return someMayResolveTypeAlias(c, node.types.nodes);
|
|
533
|
+
case 200 /* SyntaxKind.IndexedAccessType */:
|
|
534
|
+
return (mayResolveTypeAlias(c, node.objectType) ||
|
|
535
|
+
mayResolveTypeAlias(c, node.indexType));
|
|
536
|
+
case 195 /* SyntaxKind.ConditionalType */: {
|
|
537
|
+
const n = node;
|
|
538
|
+
return (mayResolveTypeAlias(c, n.checkType) ||
|
|
539
|
+
mayResolveTypeAlias(c, n.extendsType) ||
|
|
540
|
+
mayResolveTypeAlias(c, n.trueType) ||
|
|
541
|
+
mayResolveTypeAlias(c, n.falseType));
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
function someMayResolveTypeAlias(c, nodes) {
|
|
547
|
+
for (const n of nodes)
|
|
548
|
+
if (mayResolveTypeAlias(c, n))
|
|
549
|
+
return true;
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
// ---- Type aliases
|
|
553
|
+
export function isTypeAlias(node) {
|
|
554
|
+
return node.kind === 266 /* SyntaxKind.TypeAliasDeclaration */ || node.kind === 345 /* SyntaxKind.JSTypeAliasDeclaration */;
|
|
555
|
+
}
|
|
556
|
+
export function getAliasForTypeNode(c, node) {
|
|
557
|
+
const symbol = getAliasSymbolForTypeNode(c, node);
|
|
558
|
+
return symbol !== undefined
|
|
559
|
+
? new TypeAlias(symbol, getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(c, symbol))
|
|
560
|
+
: undefined;
|
|
561
|
+
}
|
|
562
|
+
export function getAliasSymbolForTypeNode(c, node) {
|
|
563
|
+
let host = node.parent;
|
|
564
|
+
while (host.kind === 197 /* SyntaxKind.ParenthesizedType */ ||
|
|
565
|
+
(host.kind === 199 /* SyntaxKind.TypeOperator */ && host.operator === 148 /* SyntaxKind.ReadonlyKeyword */))
|
|
566
|
+
host = host.parent;
|
|
567
|
+
return isTypeAlias(host) ? getSymbolOfDeclaration(c, host) : undefined;
|
|
568
|
+
}
|
|
569
|
+
function isLocalTypeAlias(symbol) {
|
|
570
|
+
let declaration;
|
|
571
|
+
for (const d of symbol.declarations) {
|
|
572
|
+
if (isTypeAlias(d)) {
|
|
573
|
+
declaration = d;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (declaration === undefined)
|
|
578
|
+
return false;
|
|
579
|
+
for (let n = declaration.parent; n !== undefined; n = n.parent) {
|
|
580
|
+
switch (n.kind) {
|
|
581
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
582
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
583
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
584
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
585
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
586
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
587
|
+
case 179 /* SyntaxKind.SetAccessor */:
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
function getTypeFromTypeAliasReference(c, node, symbol) {
|
|
594
|
+
const typeArgumentNodes = typeArgumentNodesOf(node);
|
|
595
|
+
if ((symbol.checkFlags & 1048576 /* CheckFlags.Unresolved */) !== 0) {
|
|
596
|
+
const alias = new TypeAlias(symbol, getTypesFromTypeNodes(c, typeArgumentNodes));
|
|
597
|
+
const key = aliasKey(alias);
|
|
598
|
+
let errorType = c.errorTypes.get(key);
|
|
599
|
+
if (errorType === undefined) {
|
|
600
|
+
errorType = c.newIntrinsicType(1 /* TypeFlags.Any */, 'error', 0 /* ObjectFlags.None */);
|
|
601
|
+
errorType.alias = alias;
|
|
602
|
+
c.errorTypes.set(key, errorType);
|
|
603
|
+
}
|
|
604
|
+
return errorType;
|
|
605
|
+
}
|
|
606
|
+
const t = getDeclaredTypeOfSymbol(c, symbol);
|
|
607
|
+
const typeParameters = c.symbolLinks(symbol).typeParameters;
|
|
608
|
+
if (typeParameters !== undefined && typeParameters.length !== 0) {
|
|
609
|
+
const numTypeArguments = typeArgumentNodes.length;
|
|
610
|
+
const minTypeArgumentCount = getMinTypeArgumentCount(c, typeParameters);
|
|
611
|
+
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
|
|
612
|
+
const message = minTypeArgumentCount === typeParameters.length
|
|
613
|
+
? 492 /* Diagnostics.Generic_type_0_requires_1_type_argument_s */
|
|
614
|
+
: 839 /* Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments */;
|
|
615
|
+
c.error(node, message, symbolToString(c, symbol), String(minTypeArgumentCount), String(typeParameters.length));
|
|
616
|
+
return c.errorType;
|
|
617
|
+
}
|
|
618
|
+
// A local alias doesn't name an instantiation of a top-level one.
|
|
619
|
+
const aliasSymbol = getAliasSymbolForTypeNode(c, node);
|
|
620
|
+
let newAliasSymbol = aliasSymbol !== undefined && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol))
|
|
621
|
+
? aliasSymbol
|
|
622
|
+
: undefined;
|
|
623
|
+
let aliasTypeArguments;
|
|
624
|
+
if (newAliasSymbol !== undefined)
|
|
625
|
+
aliasTypeArguments = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(c, newAliasSymbol);
|
|
626
|
+
else if (node.kind === 184 /* SyntaxKind.TypeReference */) {
|
|
627
|
+
const aliased = resolveTypeReferenceName(c, node, 2097152 /* SymbolFlags.Alias */, true);
|
|
628
|
+
if (aliased !== c.unknownSymbol) {
|
|
629
|
+
const resolved = resolveAlias(c, aliased);
|
|
630
|
+
if ((resolved.flags & 524288 /* SymbolFlags.TypeAlias */) !== 0) {
|
|
631
|
+
newAliasSymbol = resolved;
|
|
632
|
+
aliasTypeArguments = getTypeArgumentsFromNode(c, node);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
const newAlias = newAliasSymbol !== undefined ? new TypeAlias(newAliasSymbol, aliasTypeArguments ?? emptyTypes) : undefined;
|
|
637
|
+
return getTypeAliasInstantiation(c, symbol, getTypeArgumentsFromNode(c, node), newAlias);
|
|
638
|
+
}
|
|
639
|
+
return checkNoTypeArguments(c, node, symbol) ? t : c.errorType;
|
|
640
|
+
}
|
|
641
|
+
export function getTypeAliasInstantiation(c, symbol, typeArguments, alias) {
|
|
642
|
+
const t = getDeclaredTypeOfSymbol(c, symbol);
|
|
643
|
+
if (t === c.intrinsicMarkerType && typeArguments.length === 1) {
|
|
644
|
+
const kind = intrinsicTypeKind(symbol.name);
|
|
645
|
+
if (kind === 5 /* IntrinsicTypeKind.NoInfer */)
|
|
646
|
+
return getNoInferType(c, typeArguments[0]);
|
|
647
|
+
if (kind !== 0 /* IntrinsicTypeKind.Unknown */)
|
|
648
|
+
return getStringMappingType(c, symbol, typeArguments[0]);
|
|
649
|
+
}
|
|
650
|
+
const links = c.symbolLinks(symbol);
|
|
651
|
+
const typeParameters = links.typeParameters ?? emptyTypes;
|
|
652
|
+
let instantiations = links.instantiations;
|
|
653
|
+
if (instantiations === undefined) {
|
|
654
|
+
instantiations = new Map();
|
|
655
|
+
links.instantiations = instantiations;
|
|
656
|
+
}
|
|
657
|
+
const key = typeListKey(typeArguments) + aliasKey(alias);
|
|
658
|
+
let instantiation = instantiations.get(key);
|
|
659
|
+
if (instantiation === undefined) {
|
|
660
|
+
const inJs = symbol.valueDeclaration !== undefined && (symbol.valueDeclaration.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0;
|
|
661
|
+
const mapper = newTypeMapper(typeParameters, fillMissingTypeArguments(c, typeArguments, typeParameters, getMinTypeArgumentCount(c, typeParameters), inJs));
|
|
662
|
+
instantiation = instantiateTypeWithAlias(c, t, mapper, alias);
|
|
663
|
+
instantiations.set(key, instantiation);
|
|
664
|
+
}
|
|
665
|
+
return instantiation;
|
|
666
|
+
}
|
|
667
|
+
// ---- Other type nodes
|
|
668
|
+
function getTypeFromTypeQueryNode(c, node) {
|
|
669
|
+
let type = c.resolvedTypes.get(node.id);
|
|
670
|
+
if (type === undefined) {
|
|
671
|
+
type = getRegularTypeOfLiteralType(c, getWidenedType(c, checkExpressionWithTypeArguments(c, node)));
|
|
672
|
+
c.resolvedTypes.set(node.id, type);
|
|
673
|
+
}
|
|
674
|
+
return type;
|
|
675
|
+
}
|
|
676
|
+
export function getTupleElementFlags(c, node) {
|
|
677
|
+
switch (node.kind) {
|
|
678
|
+
case 191 /* SyntaxKind.OptionalType */:
|
|
679
|
+
return 2 /* ElementFlags.Optional */;
|
|
680
|
+
case 192 /* SyntaxKind.RestType */:
|
|
681
|
+
return getArrayElementTypeNode(node.type) !== undefined
|
|
682
|
+
? 4 /* ElementFlags.Rest */
|
|
683
|
+
: 8 /* ElementFlags.Variadic */;
|
|
684
|
+
case 203 /* SyntaxKind.NamedTupleMember */: {
|
|
685
|
+
const named = node;
|
|
686
|
+
if (named.questionToken !== undefined)
|
|
687
|
+
return 2 /* ElementFlags.Optional */;
|
|
688
|
+
if (named.dotDotDotToken !== undefined)
|
|
689
|
+
return getArrayElementTypeNode(named.type) !== undefined ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */;
|
|
690
|
+
return 1 /* ElementFlags.Required */;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return 1 /* ElementFlags.Required */;
|
|
694
|
+
}
|
|
695
|
+
function getTupleElementInfo(c, node) {
|
|
696
|
+
return new TupleElementInfo(getTupleElementFlags(c, node), node.kind === 203 /* SyntaxKind.NamedTupleMember */ || node.kind === 170 /* SyntaxKind.Parameter */ ? node : undefined);
|
|
697
|
+
}
|
|
698
|
+
function getArrayElementTypeNode(node) {
|
|
699
|
+
switch (node.kind) {
|
|
700
|
+
case 197 /* SyntaxKind.ParenthesizedType */:
|
|
701
|
+
return getArrayElementTypeNode(getType(node));
|
|
702
|
+
case 190 /* SyntaxKind.TupleType */: {
|
|
703
|
+
const elements = node.elements.nodes;
|
|
704
|
+
if (elements.length === 1) {
|
|
705
|
+
const e = elements[0];
|
|
706
|
+
if (e.kind === 192 /* SyntaxKind.RestType */)
|
|
707
|
+
return getArrayElementTypeNode(e.type);
|
|
708
|
+
if (e.kind === 203 /* SyntaxKind.NamedTupleMember */ && e.dotDotDotToken !== undefined)
|
|
709
|
+
return getArrayElementTypeNode(e.type);
|
|
710
|
+
}
|
|
711
|
+
return undefined;
|
|
712
|
+
}
|
|
713
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
714
|
+
return node.elementType;
|
|
715
|
+
}
|
|
716
|
+
return undefined;
|
|
717
|
+
}
|
|
718
|
+
function getArrayOrTupleTargetType(c, node) {
|
|
719
|
+
const parent = node.parent;
|
|
720
|
+
const readonly = parent.kind === 199 /* SyntaxKind.TypeOperator */ && parent.operator === 148 /* SyntaxKind.ReadonlyKeyword */;
|
|
721
|
+
if (getArrayElementTypeNode(node) !== undefined)
|
|
722
|
+
return readonly ? c.globalReadonlyArrayType : c.globalArrayType;
|
|
723
|
+
const elementInfos = [];
|
|
724
|
+
for (const e of node.elements.nodes)
|
|
725
|
+
elementInfos.push(getTupleElementInfo(c, e));
|
|
726
|
+
return getTupleTargetType(c, elementInfos, readonly);
|
|
727
|
+
}
|
|
728
|
+
function getTypeFromArrayOrTupleTypeNode(c, node) {
|
|
729
|
+
const type = c.resolvedTypes.get(node.id);
|
|
730
|
+
if (type !== undefined)
|
|
731
|
+
return type;
|
|
732
|
+
const target = getArrayOrTupleTargetType(c, node);
|
|
733
|
+
if (target === c.emptyGenericType)
|
|
734
|
+
c.resolvedTypes.set(node.id, c.emptyObjectType);
|
|
735
|
+
else if (!(node.kind === 190 /* SyntaxKind.TupleType */ && hasVariadicTupleElement(c, node)) &&
|
|
736
|
+
isDeferredTypeReferenceNode(c, node, false))
|
|
737
|
+
c.resolvedTypes.set(node.id, node.kind === 190 /* SyntaxKind.TupleType */ && node.elements.nodes.length === 0
|
|
738
|
+
? target
|
|
739
|
+
: createDeferredTypeReference(c, target, node, undefined, getAliasForTypeNode(c, node)));
|
|
740
|
+
else {
|
|
741
|
+
const elementTypes = node.kind === 189 /* SyntaxKind.ArrayType */
|
|
742
|
+
? [getTypeFromTypeNode(c, node.elementType)]
|
|
743
|
+
: getTypesFromTypeNodes(c, node.elements.nodes);
|
|
744
|
+
c.resolvedTypes.set(node.id, (target.objectFlags & 8 /* ObjectFlags.Tuple */) !== 0
|
|
745
|
+
? createNormalizedTupleType(c, target, elementTypes, 1073741824 /* ObjectFlags.FromTypeNode */)
|
|
746
|
+
: createTypeReferenceEx(c, target, elementTypes, 1073741824 /* ObjectFlags.FromTypeNode */));
|
|
747
|
+
}
|
|
748
|
+
return c.resolvedTypes.get(node.id);
|
|
749
|
+
}
|
|
750
|
+
function hasVariadicTupleElement(c, node) {
|
|
751
|
+
for (const e of node.elements.nodes)
|
|
752
|
+
if ((getTupleElementFlags(c, e) & 8 /* ElementFlags.Variadic */) !== 0)
|
|
753
|
+
return true;
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
/** Type arguments of a deferred reference from its node. */
|
|
757
|
+
export function getTypeArgumentsOfDeferredReference(c, node, target) {
|
|
758
|
+
switch (node.kind) {
|
|
759
|
+
case 184 /* SyntaxKind.TypeReference */:
|
|
760
|
+
return target
|
|
761
|
+
.outerTypeParameters()
|
|
762
|
+
.concat(fillMissingTypeArguments(c, getTypeArgumentsFromNode(c, node), target.localTypeParameters(), getMinTypeArgumentCount(c, target.localTypeParameters()), (node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0));
|
|
763
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
764
|
+
return [getTypeFromTypeNode(c, node.elementType)];
|
|
765
|
+
case 190 /* SyntaxKind.TupleType */:
|
|
766
|
+
return getTypesFromTypeNodes(c, node.elements.nodes);
|
|
767
|
+
}
|
|
768
|
+
return [];
|
|
769
|
+
}
|
|
770
|
+
function getTypeFromNamedTupleTypeNode(c, node) {
|
|
771
|
+
let type = c.resolvedTypes.get(node.id);
|
|
772
|
+
if (type === undefined) {
|
|
773
|
+
type =
|
|
774
|
+
node.dotDotDotToken !== undefined
|
|
775
|
+
? getTypeFromRestTypeNode(c, node)
|
|
776
|
+
: addOptionality(c, getTypeFromTypeNode(c, node.type), true, node.questionToken !== undefined);
|
|
777
|
+
c.resolvedTypes.set(node.id, type);
|
|
778
|
+
}
|
|
779
|
+
return type;
|
|
780
|
+
}
|
|
781
|
+
function getTypeFromRestTypeNode(c, node) {
|
|
782
|
+
const typeNode = getType(node);
|
|
783
|
+
return getTypeFromTypeNode(c, getArrayElementTypeNode(typeNode) ?? typeNode);
|
|
784
|
+
}
|
|
785
|
+
function getTypeFromUnionTypeNode(c, node) {
|
|
786
|
+
let type = c.resolvedTypes.get(node.id);
|
|
787
|
+
if (type === undefined) {
|
|
788
|
+
type = getUnionTypeEx(c, getTypesFromTypeNodes(c, node.types.nodes), 1 /* UnionReduction.Literal */, getAliasForTypeNode(c, node), undefined);
|
|
789
|
+
c.resolvedTypes.set(node.id, type);
|
|
790
|
+
}
|
|
791
|
+
return type;
|
|
792
|
+
}
|
|
793
|
+
function getTypeFromIntersectionTypeNode(c, node) {
|
|
794
|
+
if (c.resolvedTypes.get(node.id) === undefined) {
|
|
795
|
+
const alias = getAliasForTypeNode(c, node);
|
|
796
|
+
const types = getTypesFromTypeNodes(c, node.types.nodes);
|
|
797
|
+
// `string & {}` and friends keep literal completions in unions.
|
|
798
|
+
let noSupertypeReduction = false;
|
|
799
|
+
if (types.length === 2) {
|
|
800
|
+
const emptyIndex = types.indexOf(c.emptyTypeLiteralType);
|
|
801
|
+
if (emptyIndex >= 0) {
|
|
802
|
+
const t = types[1 - emptyIndex];
|
|
803
|
+
noSupertypeReduction =
|
|
804
|
+
(t.flags & (32 /* TypeFlags.String */ | 64 /* TypeFlags.Number */ | 128 /* TypeFlags.BigInt */)) !== 0 ||
|
|
805
|
+
((t.flags & 4194304 /* TypeFlags.TemplateLiteral */) !== 0 && isPatternLiteralType(c, t));
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
c.resolvedTypes.set(node.id, getIntersectionTypeEx(c, types, noSupertypeReduction ? 1 /* IntersectionFlags.NoSupertypeReduction */ : 0 /* IntersectionFlags.None */, alias));
|
|
809
|
+
}
|
|
810
|
+
return c.resolvedTypes.get(node.id);
|
|
811
|
+
}
|
|
812
|
+
function getTypeFromTemplateTypeNode(c, node) {
|
|
813
|
+
if (c.resolvedTypes.get(node.id) === undefined) {
|
|
814
|
+
const spans = node.templateSpans.nodes;
|
|
815
|
+
const texts = [getText(node.head)];
|
|
816
|
+
const types = [];
|
|
817
|
+
for (const span of spans) {
|
|
818
|
+
texts.push(getText(span.literal));
|
|
819
|
+
types.push(getTypeFromTypeNode(c, span.type));
|
|
820
|
+
}
|
|
821
|
+
c.resolvedTypes.set(node.id, getTemplateLiteralType(c, texts, types));
|
|
822
|
+
}
|
|
823
|
+
return c.resolvedTypes.get(node.id);
|
|
824
|
+
}
|
|
825
|
+
/** The symbol an identifier resolves to, cached on the identifier. */
|
|
826
|
+
export function getResolvedSymbolOfIdentifier(c, node) {
|
|
827
|
+
return getResolvedSymbol(c, node);
|
|
828
|
+
}
|