tsc-ts 0.0.4 → 0.0.6
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 +34 -2
- 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 +2351 -0
- package/dist/api/compiler/ast.js +11212 -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 +1241 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2359 -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 +1641 -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 +357 -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 +788 -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 +314 -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 +291 -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 +580 -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 +2587 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +901 -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 +442 -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 +200 -0
- package/dist/api/compiler/checker-members.js +2148 -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 +483 -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 +271 -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 +789 -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 +51 -0
- package/dist/api/compiler/checker-symbol-types.js +955 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1784 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2542 -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 +1093 -0
- package/dist/api/compiler/checker-types.js +1874 -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 +512 -0
- package/dist/api/compiler/checker.js +932 -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 +161 -0
- package/dist/api/compiler/diagnostics.js +784 -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 +144 -0
- package/dist/api/compiler/file-include.js +599 -0
- package/dist/api/compiler/file-loader.d.ts +290 -0
- package/dist/api/compiler/file-loader.js +1323 -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 +835 -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 +105 -0
- package/dist/api/compiler/link-tables.js +319 -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 +745 -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 +221 -0
- package/dist/api/compiler/parallel-parse.js +541 -0
- package/dist/api/compiler/parser.d.ts +604 -0
- package/dist/api/compiler/parser.js +6426 -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 +157 -0
- package/dist/api/compiler/printer/emit-context.js +582 -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 +529 -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 +1019 -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 +991 -0
- package/dist/api/compiler/symbol.d.ts +282 -0
- package/dist/api/compiler/symbol.js +339 -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 +677 -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 +539 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +799 -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 +198 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2381 -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 +129 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1157 -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 +10 -0
- package/dist/api/compiler/transformers/subtree-facts.js +205 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +52 -0
- package/dist/api/compiler/transformers/syntax-facts.js +258 -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 +3 -2
- package/dist/api/library/ast.generated.d.ts +127 -139
- package/dist/api/library/checker.d.ts +51 -0
- package/dist/api/library/checker.js +318 -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/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 +5 -1
- package/dist/api/library/index.js +4 -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/types.d.ts +14 -1
- package/package.json +12 -8
- package/src/compiler/ast-utilities.ts +548 -0
- package/src/compiler/ast.ts +12870 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2707 -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 +1201 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +355 -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 +3596 -0
- package/src/compiler/checker-heritage.ts +1240 -0
- package/src/compiler/checker-inference.ts +2584 -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 +1928 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2480 -0
- package/src/compiler/checker-modules.ts +2896 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +591 -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 +1187 -0
- package/src/compiler/checker-symbols.ts +2157 -0
- package/src/compiler/checker-type-factory.ts +2616 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2510 -0
- package/src/compiler/checker-types.ts +2520 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1138 -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 +858 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +741 -0
- package/src/compiler/file-loader.ts +1597 -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 +2818 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +938 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +343 -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 +1071 -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 +3433 -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 +1954 -0
- package/src/compiler/parallel-parse.ts +595 -0
- package/src/compiler/parse-thread.ts +136 -0
- package/src/compiler/parser.ts +7766 -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 +684 -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 +594 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1426 -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 +1166 -0
- package/src/compiler/symbol.ts +557 -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 +833 -0
- package/src/compiler/transformers/declarations-pseudo.ts +969 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1867 -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 +1213 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +253 -0
- package/src/compiler/transformers/syntax-facts.ts +358 -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 +1422 -0
- package/src/compiler/tsc-cli.ts +669 -0
- package/src/compiler/tsc-compile.ts +446 -0
- package/src/compiler/tsc-watch.ts +922 -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 +141 -167
- package/src/library/ast.ts +4 -1
- package/src/library/checker.ts +384 -0
- package/src/library/diagnostics.ts +72 -0
- package/src/library/disk.ts +73 -0
- package/src/library/errors.ts +26 -0
- package/src/library/host.ts +63 -0
- package/src/library/index.ts +21 -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/types.ts +14 -1
|
@@ -0,0 +1,1138 @@
|
|
|
1
|
+
// The type checker: one `Checker` per program (or per partition of its files), holding the
|
|
2
|
+
// type system's caches and the diagnostics it reports.
|
|
3
|
+
//
|
|
4
|
+
// The checker's logic lives in free functions taking the checker first, grouped by area:
|
|
5
|
+
//
|
|
6
|
+
// | Module | Area |
|
|
7
|
+
// | ------------------------------- | ------------------------------------------------------- |
|
|
8
|
+
// | checker-type-factory.ts | creating and interning types (unions, literals, tuples) |
|
|
9
|
+
// | checker-symbols.ts | merging, aliases, exports, name resolution |
|
|
10
|
+
// | checker-modules.ts | module resolution, import and export aliases |
|
|
11
|
+
// | checker-declared-types.ts | declared types of classes, interfaces, aliases, enums |
|
|
12
|
+
// | checker-type-nodes.ts | `getTypeFromTypeNode` |
|
|
13
|
+
// | checker-symbol-types.ts | types of values: variables, parameters, properties |
|
|
14
|
+
// | checker-members.ts | members, signatures, index infos, apparent types |
|
|
15
|
+
// | instantiation.ts | mappers and `instantiateType` |
|
|
16
|
+
// | relations.ts | assignability, comparability, subtype, identity |
|
|
17
|
+
// | type-printer.ts | `typeToString`, `symbolToString`, `signatureToString` |
|
|
18
|
+
// | checker-source-file.ts | `checkSourceFile` and statement dispatch |
|
|
19
|
+
// | checker-expressions.ts | expressions |
|
|
20
|
+
// | checker-calls.ts | call resolution |
|
|
21
|
+
// | checker-statements.ts | statements |
|
|
22
|
+
// | checker-declarations.ts | variable, function and type declarations |
|
|
23
|
+
// | checker-overloads.ts | overloads and implementations |
|
|
24
|
+
// | checker-classes.ts | classes and interfaces |
|
|
25
|
+
// | checker-heritage.ts | base types, overrides, index constraints, duplicates |
|
|
26
|
+
// | checker-jsx.ts | JSX |
|
|
27
|
+
// | checker-javascript.ts | CommonJS, expando and `this.x` assignment declarations |
|
|
28
|
+
// | checker-jsdoc.ts | JSDoc type references, `@type` on functions, `@param` |
|
|
29
|
+
// | checker-elaboration.ts | reporting relation errors at the failing subexpression |
|
|
30
|
+
// | checker-grammar.ts | grammar checks |
|
|
31
|
+
// | checker-flow.ts | control flow narrowing |
|
|
32
|
+
import type { DeferredCollisionCheck } from './checker-generated-code.js';
|
|
33
|
+
import type { EmitHelperFileLinks } from './checker-emit-helpers.js';
|
|
34
|
+
import { sideOf } from './side-state.js';
|
|
35
|
+
import type { Node, PatternAmbientModule, SourceFile } from './ast.js';
|
|
36
|
+
import { CompactSymbolLinkTable, IntLinkTable, LinkTable, SparseLinkTable } from './link-tables.js';
|
|
37
|
+
import { getErrorRangeForNode, getSourceFileOfNode } from './binder-utilities.js';
|
|
38
|
+
import { Diagnostic, type DiagnosticMessage, Diagnostics, compareDiagnostics } from './diagnostics.js';
|
|
39
|
+
import {
|
|
40
|
+
type CompilerOptions,
|
|
41
|
+
ModuleKind,
|
|
42
|
+
ScriptTarget,
|
|
43
|
+
getEmitScriptTarget,
|
|
44
|
+
getIsolatedModules,
|
|
45
|
+
getStrictOptionValue,
|
|
46
|
+
shouldPreserveConstEnums,
|
|
47
|
+
} from './options.js';
|
|
48
|
+
import { CheckFlags, Symbol, SymbolFlags, type SymbolTable, getSymbolId } from './symbol.js';
|
|
49
|
+
import {
|
|
50
|
+
IndexInfo,
|
|
51
|
+
IntrinsicType,
|
|
52
|
+
LiteralType,
|
|
53
|
+
MemberNames,
|
|
54
|
+
NodeLinks,
|
|
55
|
+
ObjectFlags,
|
|
56
|
+
ObjectType,
|
|
57
|
+
Signature,
|
|
58
|
+
SignatureFlags,
|
|
59
|
+
SymbolLinks,
|
|
60
|
+
type Type,
|
|
61
|
+
TypeFlags,
|
|
62
|
+
TypeMapper,
|
|
63
|
+
TypeParameter,
|
|
64
|
+
TypePredicate,
|
|
65
|
+
TypePredicateKind,
|
|
66
|
+
emptyTypes,
|
|
67
|
+
VarianceFlags,
|
|
68
|
+
TypeListCache,
|
|
69
|
+
TypeListTable,
|
|
70
|
+
type ConditionalType,
|
|
71
|
+
type InterfaceType,
|
|
72
|
+
type TypeChecking,
|
|
73
|
+
} from './checker-types.js';
|
|
74
|
+
import { getBaseTypes } from './checker-declared-types.js';
|
|
75
|
+
import { getFalseTypeFromConditionalType, getTrueTypeFromConditionalType } from './checker-type-operators.js';
|
|
76
|
+
import {
|
|
77
|
+
createArrayType,
|
|
78
|
+
createTypeFromGenericGlobalType,
|
|
79
|
+
getBigIntLiteralType,
|
|
80
|
+
getNumberLiteralType,
|
|
81
|
+
getStringLiteralType,
|
|
82
|
+
getTemplateLiteralType,
|
|
83
|
+
getUnionType,
|
|
84
|
+
newAnonymousType,
|
|
85
|
+
newObjectType,
|
|
86
|
+
} from './checker-type-factory.js';
|
|
87
|
+
import {
|
|
88
|
+
CheckerNameResolver,
|
|
89
|
+
type LibGlobals,
|
|
90
|
+
type MergedGlobals,
|
|
91
|
+
TableChanges,
|
|
92
|
+
borrowLibGlobals,
|
|
93
|
+
findLibGlobals,
|
|
94
|
+
returnLibGlobals,
|
|
95
|
+
setGlobal,
|
|
96
|
+
SuggestionNameResolver,
|
|
97
|
+
getGlobalStrictFunctionType,
|
|
98
|
+
getGlobalType,
|
|
99
|
+
initializeGlobals,
|
|
100
|
+
mergeAmbientModulesAndAugmentations,
|
|
101
|
+
} from './checker-symbols.js';
|
|
102
|
+
import { PermissiveMapper, ReportingMapper, RestrictiveMapper, UniqueLiteralMapper } from './instantiation.js';
|
|
103
|
+
import { Relation, RelationKey, type InternedRelationKey, type Relater, TypeComparer } from './relations.js';
|
|
104
|
+
import { TypeNodeVisitor, checkSourceFile } from './checker-source-file.js';
|
|
105
|
+
import { InferenceCaches } from './checker-inference.js';
|
|
106
|
+
import { AssignmentMarker, type FlowLoopInfo, type FlowState, type FlowWalk } from './checker-narrowing.js';
|
|
107
|
+
import type { FlowNode, FlowReduceLabel } from './flow.js';
|
|
108
|
+
import { JsxState } from './checker-jsx.js';
|
|
109
|
+
import type { DeferredIterationError, IterationTypes } from './checker-iteration.js';
|
|
110
|
+
import type { SpreadIndices } from './checker-contextual.js';
|
|
111
|
+
import { SourceFileMetadata, getEmitModuleFormatOfFile } from './program-utilities.js';
|
|
112
|
+
import type { GrammarChecker } from './checker-grammar.js';
|
|
113
|
+
import type { ResolvedModule } from './module-resolution-types.js';
|
|
114
|
+
import type { ModuleSpecifierHost } from './module-specifiers.js';
|
|
115
|
+
|
|
116
|
+
/** What the checker needs from a program. */
|
|
117
|
+
export abstract class CheckerHost {
|
|
118
|
+
abstract getCompilerOptions(): CompilerOptions;
|
|
119
|
+
/** Every file of the program, libraries first, in program order. */
|
|
120
|
+
abstract getSourceFiles(): readonly SourceFile[];
|
|
121
|
+
abstract isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
|
122
|
+
/** How a module name in `file` resolved in `mode`, if the program resolved it. */
|
|
123
|
+
getResolvedModule(_file: SourceFile, _moduleName: string, _mode: ModuleKind): ResolvedModule | undefined {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
/** The program file for a resolved file name, following project reference redirects. */
|
|
127
|
+
getSourceFileForResolvedModule(_fileName: string): SourceFile | undefined {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
/** The resolution mode of the module specifier `location` in `file`. */
|
|
131
|
+
getModeForUsageLocation(_file: SourceFile, _location: Node): ModuleKind {
|
|
132
|
+
return ModuleKind.None;
|
|
133
|
+
}
|
|
134
|
+
/** The resolution mode of module names in `file` without a specifier of their own. */
|
|
135
|
+
getDefaultResolutionModeForFile(_file: SourceFile): ModuleKind {
|
|
136
|
+
return ModuleKind.None;
|
|
137
|
+
}
|
|
138
|
+
/** Packages that modules resolved into, by name: whether any of their resolutions was a declaration file. */
|
|
139
|
+
getPackagesMap(): ReadonlyMap<string, boolean> {
|
|
140
|
+
return new Map<string, boolean>();
|
|
141
|
+
}
|
|
142
|
+
/** The declaration output of a referenced project's source file, or `''`. */
|
|
143
|
+
getProjectReferenceOutputDts(_fileName: string): string {
|
|
144
|
+
return '';
|
|
145
|
+
}
|
|
146
|
+
fileExists(_path: string): boolean {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
/** The synthetic specifier of a file's implicit JSX runtime import, such as `react/jsx-runtime`, if any. */
|
|
150
|
+
/** The `tslib` import the program adds to `file` under --importHelpers. */
|
|
151
|
+
getImportHelpersImportSpecifier(_file: SourceFile): Node | undefined {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
getJSXRuntimeImportSpecifier(_file: SourceFile): Node | undefined {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
/** The globals and module augmentations of the program, if a checker merged them for the others. */
|
|
158
|
+
getMergedGlobals(): MergedGlobals | undefined {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
/** The format `file` is emitted in when it differs from `module`, else `None`. */
|
|
162
|
+
getImpliedNodeFormatForEmit(_file: SourceFile): ModuleKind {
|
|
163
|
+
return ModuleKind.None;
|
|
164
|
+
}
|
|
165
|
+
/** The module syntax (`ESNext` or `CommonJS`) of the import or export with module specifier `usage`. */
|
|
166
|
+
getEmitSyntaxForUsageLocation(_file: SourceFile, _usage: Node): ModuleKind {
|
|
167
|
+
return ModuleKind.None;
|
|
168
|
+
}
|
|
169
|
+
/** The `package.json` scope and implied module format of a file, if known. */
|
|
170
|
+
getSourceFileMetadata(_file: SourceFile): SourceFileMetadata | undefined {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
/** The module format `file` is emitted in. */
|
|
174
|
+
getEmitModuleFormatOfFile(file: SourceFile): ModuleKind {
|
|
175
|
+
return getEmitModuleFormatOfFile(
|
|
176
|
+
file.fileName,
|
|
177
|
+
this.getCompilerOptions(),
|
|
178
|
+
this.getSourceFileMetadata(file) ?? new SourceFileMetadata('', '', ModuleKind.None),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
/** What module specifier generation needs; without it, specifiers are relative paths. */
|
|
182
|
+
getModuleSpecifierHost(): ModuleSpecifierHost | undefined {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Per-file and global diagnostics, sorted on read like tsgo's DiagnosticsCollection. */
|
|
188
|
+
class DiagnosticCollection {
|
|
189
|
+
private readonly byFile = new Map<string, Diagnostic[]>();
|
|
190
|
+
private readonly sortedFiles = new Set<string>();
|
|
191
|
+
private readonly global: Diagnostic[] = [];
|
|
192
|
+
private globalSorted = true;
|
|
193
|
+
/** The diagnostics added since `startLog`, while recording. */
|
|
194
|
+
private log: Diagnostic[] | undefined = undefined;
|
|
195
|
+
|
|
196
|
+
add(diagnostic: Diagnostic): void {
|
|
197
|
+
if (this.log !== undefined) this.log.push(diagnostic);
|
|
198
|
+
const file = diagnostic.file;
|
|
199
|
+
if (file === undefined) {
|
|
200
|
+
this.global.push(diagnostic);
|
|
201
|
+
this.globalSorted = false;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let list = this.byFile.get(file.fileName);
|
|
205
|
+
if (list === undefined) {
|
|
206
|
+
list = [];
|
|
207
|
+
this.byFile.set(file.fileName, list);
|
|
208
|
+
}
|
|
209
|
+
list.push(diagnostic);
|
|
210
|
+
this.sortedFiles.delete(file.fileName);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
forFile(fileName: string): Diagnostic[] {
|
|
214
|
+
const list = this.byFile.get(fileName);
|
|
215
|
+
if (list === undefined) return [];
|
|
216
|
+
if (!this.sortedFiles.has(fileName)) {
|
|
217
|
+
stableSort(list);
|
|
218
|
+
this.sortedFiles.add(fileName);
|
|
219
|
+
}
|
|
220
|
+
return list.slice();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
count(): number {
|
|
224
|
+
let count = this.global.length;
|
|
225
|
+
for (const list of this.byFile.values()) count += list.length;
|
|
226
|
+
return count;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** An already reported diagnostic equal to `diagnostic`, if any. */
|
|
230
|
+
lookup(diagnostic: Diagnostic): Diagnostic | undefined {
|
|
231
|
+
const file = diagnostic.file;
|
|
232
|
+
const list = file === undefined ? this.global : this.byFile.get(file.fileName);
|
|
233
|
+
if (list === undefined) return undefined;
|
|
234
|
+
for (const d of list) if (compareDiagnostics(d, diagnostic) === 0) return d;
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
globals(): Diagnostic[] {
|
|
239
|
+
if (!this.globalSorted) {
|
|
240
|
+
stableSort(this.global);
|
|
241
|
+
this.globalSorted = true;
|
|
242
|
+
}
|
|
243
|
+
return this.global.slice();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Records the diagnostics added from now on. */
|
|
247
|
+
startLog(): void {
|
|
248
|
+
this.log = [];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The diagnostics added since `startLog`, in order; stops recording. */
|
|
252
|
+
takeLog(): Diagnostic[] {
|
|
253
|
+
const log = this.log!;
|
|
254
|
+
this.log = undefined;
|
|
255
|
+
return log;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function stableSort(list: Diagnostic[]): void {
|
|
260
|
+
// Array.prototype.sort is stable.
|
|
261
|
+
list.sort(compareDiagnostics);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Maximum depth of nested `typeToString` calls before diagnostics are discarded. */
|
|
265
|
+
export const maxSerializationLevel = 2;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* File positions per symbol id in `ExternalModuleContainerIndex.keys`. Symbol ids are int32, so the
|
|
269
|
+
* keys stay exact.
|
|
270
|
+
*/
|
|
271
|
+
export const fileIndexScale = 2 ** 21;
|
|
272
|
+
|
|
273
|
+
/** The modules that export each symbol, built once from every module's exports. */
|
|
274
|
+
export class ExternalModuleContainerIndex {
|
|
275
|
+
complete = false;
|
|
276
|
+
/**
|
|
277
|
+
* One key per symbol and module that exports it, ascending: the id of the symbol the export
|
|
278
|
+
* resolves to times `fileIndexScale`, plus the module's file position in `Checker.files`. The
|
|
279
|
+
* keys of one symbol are contiguous and in program order.
|
|
280
|
+
*/
|
|
281
|
+
keys: number[] = [];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** The checker's caches for symbol accessibility. */
|
|
285
|
+
export class SymbolAccessibilityCaches {
|
|
286
|
+
/** Accessible chains by symbol id, then by `chainCacheKey`. */
|
|
287
|
+
readonly accessibleChains = new Map<number, Map<string, Symbol[]>>();
|
|
288
|
+
/** Alias symbols of large tables (globals and exports), by table id. */
|
|
289
|
+
readonly tableAliases = new Map<number, Symbol[]>();
|
|
290
|
+
/** Modules imported by a file that export a symbol, by symbol id then file node id. */
|
|
291
|
+
readonly containersByFile = new Map<number, Map<number, Symbol[]>>();
|
|
292
|
+
/** All modules that export a symbol, by symbol id. */
|
|
293
|
+
readonly containers = new Map<number, Symbol[]>();
|
|
294
|
+
/** The modules each symbol is exported from, built on the first search of all modules. */
|
|
295
|
+
externalModuleContainers: ExternalModuleContainerIndex | undefined = undefined;
|
|
296
|
+
/** The name tables of named class expressions, by node id. */
|
|
297
|
+
readonly classExpressionNames = new Map<number, SymbolTable>();
|
|
298
|
+
/** Computed declaration visibility by node id (see isDeclarationVisible), 0 if not computed. */
|
|
299
|
+
readonly declarationVisibility = new IntLinkTable();
|
|
300
|
+
/** The checker slots (bit `slot + 1`) whose declaration emit marked a node visible, by node id. */
|
|
301
|
+
readonly markedSlots = new IntLinkTable();
|
|
302
|
+
/** The checker slot of the file in declaration emit, -1 before declaration emit. */
|
|
303
|
+
markedSlot = -1;
|
|
304
|
+
/** Counts the times declaration emit left a checker slot. */
|
|
305
|
+
visibilityEpoch = 0;
|
|
306
|
+
/** The epoch at which each slot (index `slot + 1`) was last left. */
|
|
307
|
+
readonly slotsLeftAt: number[] = [0, 0, 0, 0, 0];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export class Checker implements TypeChecking {
|
|
311
|
+
readonly host: CheckerHost;
|
|
312
|
+
readonly compilerOptions: CompilerOptions;
|
|
313
|
+
readonly files: readonly SourceFile[];
|
|
314
|
+
readonly fileIndex: Map<SourceFile, number>;
|
|
315
|
+
readonly languageVersion: ScriptTarget;
|
|
316
|
+
readonly strictNullChecks: boolean;
|
|
317
|
+
readonly strictFunctionTypes: boolean;
|
|
318
|
+
readonly strictBindCallApply: boolean;
|
|
319
|
+
readonly strictPropertyInitialization: boolean;
|
|
320
|
+
readonly strictBuiltinIteratorReturn: boolean;
|
|
321
|
+
readonly noImplicitAny: boolean;
|
|
322
|
+
readonly noImplicitThis: boolean;
|
|
323
|
+
readonly legacyDecorators: boolean;
|
|
324
|
+
readonly useUnknownInCatchVariables: boolean;
|
|
325
|
+
readonly exactOptionalPropertyTypes: boolean;
|
|
326
|
+
readonly isolatedModules: boolean;
|
|
327
|
+
readonly preserveConstEnums: boolean;
|
|
328
|
+
readonly noUncheckedIndexedAccess: boolean;
|
|
329
|
+
|
|
330
|
+
// Counters for type and signature ids.
|
|
331
|
+
typeCount = 0;
|
|
332
|
+
signatureCount = 0;
|
|
333
|
+
/** Positions of members by name in the tables and lists that lazily instantiated members come from. */
|
|
334
|
+
readonly memberPositionsInLists = new Map<Symbol[], Map<string, number>>();
|
|
335
|
+
/** The property names of the last instantiation of each such list whose table is built on demand. */
|
|
336
|
+
readonly memberNamesOfLists = new Map<Symbol[], MemberNames>();
|
|
337
|
+
/** Long lists of inherited properties, by name. */
|
|
338
|
+
readonly propertiesByName = new Map<Symbol[], Map<string, Symbol>>();
|
|
339
|
+
/** Number of `typeToString` calls in progress. */
|
|
340
|
+
serializationLevel = 0;
|
|
341
|
+
/** Whether `globalObjectType` is set; global type lookups before it can't suggest `typeof`. */
|
|
342
|
+
hasGlobalObjectType = false;
|
|
343
|
+
/** The node being checked, for errors with no better location. */
|
|
344
|
+
currentNode: Node | undefined = undefined;
|
|
345
|
+
|
|
346
|
+
readonly diagnostics = new DiagnosticCollection();
|
|
347
|
+
readonly suggestionDiagnostics = new DiagnosticCollection();
|
|
348
|
+
/** Module specifiers of `import("…")` types, by module symbol id, importing file path and resolution mode. */
|
|
349
|
+
readonly moduleSpecifiers = new Map<string, string>();
|
|
350
|
+
/** Specifier generation for hosts without a program. */
|
|
351
|
+
fallbackModuleSpecifierHost: ModuleSpecifierHost | undefined = undefined;
|
|
352
|
+
|
|
353
|
+
// Links of symbols and nodes by symbol and node id (see link-tables.ts). Values that many symbols
|
|
354
|
+
// or nodes have are columns of their own; the rest share one links object per symbol or node,
|
|
355
|
+
// created on first use.
|
|
356
|
+
readonly symbolLinkTable = new SparseLinkTable<SymbolLinks>();
|
|
357
|
+
readonly nodeLinkTable = new SparseLinkTable<NodeLinks>();
|
|
358
|
+
/** The holders of the lazily computed state of types with side state (`sideOf`), by type id. */
|
|
359
|
+
readonly sideHolders = new LinkTable<Type>();
|
|
360
|
+
/** The same for signatures with side state (`signatureSideOf`), by signature id. */
|
|
361
|
+
readonly signatureSideHolders = new LinkTable<Signature>();
|
|
362
|
+
/** The type of a value symbol. */
|
|
363
|
+
readonly symbolTypes = new LinkTable<Type>();
|
|
364
|
+
/** For instantiated and synthetic symbols, the symbol they come from. */
|
|
365
|
+
readonly symbolTargets = new LinkTable<Symbol>();
|
|
366
|
+
/** The mapper of an instantiated symbol or a mapped type property. */
|
|
367
|
+
readonly symbolMappers = new LinkTable<TypeMapper>();
|
|
368
|
+
/** The literal type of a property name. */
|
|
369
|
+
readonly symbolNameTypes = new LinkTable<Type>();
|
|
370
|
+
/** The mapped type of a mapped type property, or the union/intersection of a synthetic property. */
|
|
371
|
+
readonly symbolContainingTypes = new LinkTable<Type>();
|
|
372
|
+
/** The key type of a mapped type property. */
|
|
373
|
+
readonly symbolKeyTypes = new LinkTable<Type>();
|
|
374
|
+
/** The property a mapped, spread or synthetic property comes from. */
|
|
375
|
+
readonly symbolSyntheticOrigins = new LinkTable<Symbol>();
|
|
376
|
+
/** The left and right properties a spread property combines. */
|
|
377
|
+
readonly symbolLeftSpreads = new LinkTable<Symbol>();
|
|
378
|
+
readonly symbolRightSpreads = new LinkTable<Symbol>();
|
|
379
|
+
/** Bits of SymbolFlags for the meanings in which a symbol was referenced. */
|
|
380
|
+
readonly symbolReferenceKinds = new IntLinkTable();
|
|
381
|
+
/** The resolved symbol of an identifier, entity name or call. */
|
|
382
|
+
readonly resolvedSymbols = new CompactSymbolLinkTable();
|
|
383
|
+
/** The resolved type of a type node or expression. */
|
|
384
|
+
readonly resolvedTypes = new SparseLinkTable<Type>();
|
|
385
|
+
/** The resolved signature of a call-like node or a signature declaration. */
|
|
386
|
+
readonly resolvedSignatures = new SparseLinkTable<Signature>();
|
|
387
|
+
/** Merged symbols, indexed by the id of the symbol merged into them. */
|
|
388
|
+
readonly mergedSymbols: Map<number, Symbol>;
|
|
389
|
+
/** Globals merged from the default libraries, shared with other checkers. */
|
|
390
|
+
libGlobals: LibGlobals | undefined;
|
|
391
|
+
/** The program's globals and module augmentations as another checker merged them, shared with it. */
|
|
392
|
+
mergedGlobals: MergedGlobals | undefined;
|
|
393
|
+
/**
|
|
394
|
+
* The diagnostics and suggestions the merges reported: those of the globals, then those of the
|
|
395
|
+
* ambient modules and module augmentations.
|
|
396
|
+
*/
|
|
397
|
+
readonly mergeDiagnostics: Diagnostic[][] = [];
|
|
398
|
+
/**
|
|
399
|
+
* This checker's changes to `globals` and `mergedSymbols` when it uses the tables of
|
|
400
|
+
* `libGlobals` in place rather than copies; they are undone when it is disposed.
|
|
401
|
+
*/
|
|
402
|
+
globalChanges: TableChanges<string, Symbol> | undefined = undefined;
|
|
403
|
+
mergedSymbolChanges: TableChanges<number, Symbol> | undefined = undefined;
|
|
404
|
+
/** This checker's copies of shared symbols, and the symbols they stand for. */
|
|
405
|
+
readonly sharedSymbolCopies = new Map<Symbol, Symbol>();
|
|
406
|
+
/** Accessible symbol chains and declaration visibility, created on first use. */
|
|
407
|
+
symbolAccessibilityCaches: SymbolAccessibilityCaches | undefined = undefined;
|
|
408
|
+
|
|
409
|
+
// Symbols
|
|
410
|
+
readonly globals: SymbolTable;
|
|
411
|
+
readonly resolver: CheckerNameResolver;
|
|
412
|
+
readonly undefinedSymbol: Symbol;
|
|
413
|
+
readonly argumentsSymbol: Symbol;
|
|
414
|
+
readonly requireSymbol: Symbol;
|
|
415
|
+
readonly unknownSymbol: Symbol;
|
|
416
|
+
readonly globalThisSymbol: Symbol;
|
|
417
|
+
readonly unresolvedSymbols = new Map<string, Symbol>();
|
|
418
|
+
/** Widening's optional `undefined` properties by the id of the property each is created from. */
|
|
419
|
+
readonly undefinedProperties = new Map<number, Symbol>();
|
|
420
|
+
|
|
421
|
+
// Interning tables.
|
|
422
|
+
readonly stringLiteralTypes = new Map<string, LiteralType>();
|
|
423
|
+
readonly numberLiteralTypes = new Map<number, LiteralType>();
|
|
424
|
+
readonly bigintLiteralTypes = new Map<string, LiteralType>();
|
|
425
|
+
readonly enumLiteralTypes = new Map<string, LiteralType>();
|
|
426
|
+
readonly uniqueESSymbolTypes = new Map<Symbol, Type>();
|
|
427
|
+
/** Unions by a hash of their key; `unionTypes` holds the unions whose key hash was taken. */
|
|
428
|
+
readonly unionTypesByHash = new Map<number, Type>();
|
|
429
|
+
readonly unionTypes = new Map<string, Type>();
|
|
430
|
+
readonly unionOfUnionTypes = new Map<string, Type>();
|
|
431
|
+
/** `unionOfUnionTypes` without an alias, by both ids and the reduction packed into one number. */
|
|
432
|
+
readonly unionOfUnionTypesById = new Map<number, Type>();
|
|
433
|
+
readonly intersectionTypes = new TypeListCache<Type>();
|
|
434
|
+
readonly tupleTypes = new Map<string, Type>();
|
|
435
|
+
readonly indexedAccessTypes = new Map<string, Type>();
|
|
436
|
+
readonly templateLiteralTypes = new Map<string, Type>();
|
|
437
|
+
/** Instantiations of template literal types: the instantiated types, tagged with the template's id. */
|
|
438
|
+
readonly templateLiteralInstantiations = new TypeListCache<Type>();
|
|
439
|
+
/** The type argument lists that references and instantiations keep, one of each (`TypeListTable`). */
|
|
440
|
+
readonly typeLists = new TypeListTable();
|
|
441
|
+
readonly stringMappingTypes = new Map<string, Type>();
|
|
442
|
+
readonly substitutionTypes = new Map<string, Type>();
|
|
443
|
+
readonly subtypeReductionCache = new TypeListCache<Type[]>();
|
|
444
|
+
readonly cachedTypes = new Map<string, Type>();
|
|
445
|
+
/** Cached types by `cachedTypeKey` and by `cachedTypePairKey`, without spelled keys. */
|
|
446
|
+
readonly cachedTypesById = new Map<number, Type>();
|
|
447
|
+
readonly cachedTypesByPair = new Map<number, Type>();
|
|
448
|
+
readonly errorTypes = new Map<string, Type>();
|
|
449
|
+
|
|
450
|
+
// Intrinsic types, created in tsgo's order so ids (the last-resort union order) match.
|
|
451
|
+
readonly anyType: IntrinsicType;
|
|
452
|
+
readonly autoType: IntrinsicType;
|
|
453
|
+
readonly wildcardType: IntrinsicType;
|
|
454
|
+
readonly blockedStringType: IntrinsicType;
|
|
455
|
+
readonly errorType: IntrinsicType;
|
|
456
|
+
readonly unresolvedType: IntrinsicType;
|
|
457
|
+
readonly nonInferrableAnyType: IntrinsicType;
|
|
458
|
+
readonly intrinsicMarkerType: IntrinsicType;
|
|
459
|
+
readonly unknownType: IntrinsicType;
|
|
460
|
+
readonly undefinedType: IntrinsicType;
|
|
461
|
+
readonly undefinedWideningType: IntrinsicType;
|
|
462
|
+
readonly missingType: IntrinsicType;
|
|
463
|
+
readonly undefinedOrMissingType: IntrinsicType;
|
|
464
|
+
readonly optionalType: IntrinsicType;
|
|
465
|
+
readonly nullType: IntrinsicType;
|
|
466
|
+
readonly nullWideningType: IntrinsicType;
|
|
467
|
+
readonly stringType: IntrinsicType;
|
|
468
|
+
readonly numberType: IntrinsicType;
|
|
469
|
+
readonly bigintType: IntrinsicType;
|
|
470
|
+
readonly regularFalseType: LiteralType;
|
|
471
|
+
readonly falseType: LiteralType;
|
|
472
|
+
readonly regularTrueType: LiteralType;
|
|
473
|
+
readonly trueType: LiteralType;
|
|
474
|
+
readonly booleanType: Type;
|
|
475
|
+
readonly esSymbolType: IntrinsicType;
|
|
476
|
+
readonly voidType: IntrinsicType;
|
|
477
|
+
readonly neverType: IntrinsicType;
|
|
478
|
+
readonly silentNeverType: IntrinsicType;
|
|
479
|
+
readonly implicitNeverType: IntrinsicType;
|
|
480
|
+
readonly unreachableNeverType: IntrinsicType;
|
|
481
|
+
readonly nonPrimitiveType: IntrinsicType;
|
|
482
|
+
readonly stringOrNumberType: Type;
|
|
483
|
+
readonly stringNumberSymbolType: Type;
|
|
484
|
+
readonly numberOrBigIntType: Type;
|
|
485
|
+
readonly numericStringType: Type;
|
|
486
|
+
readonly templateConstraintType: Type;
|
|
487
|
+
readonly uniqueLiteralType: IntrinsicType;
|
|
488
|
+
readonly emptyObjectType: ObjectType;
|
|
489
|
+
readonly emptyJsxObjectType: ObjectType;
|
|
490
|
+
readonly emptyFreshJsxObjectType: ObjectType;
|
|
491
|
+
readonly emptyTypeLiteralType: ObjectType;
|
|
492
|
+
readonly unknownEmptyObjectType: ObjectType;
|
|
493
|
+
readonly unknownUnionType: Type;
|
|
494
|
+
readonly emptyGenericType: ObjectType;
|
|
495
|
+
readonly anyFunctionType: ObjectType;
|
|
496
|
+
readonly noConstraintType: ObjectType;
|
|
497
|
+
readonly circularConstraintType: ObjectType;
|
|
498
|
+
readonly resolvingDefaultType: ObjectType;
|
|
499
|
+
readonly markerSuperType: TypeParameter;
|
|
500
|
+
readonly markerSubType: TypeParameter;
|
|
501
|
+
readonly markerOtherType: TypeParameter;
|
|
502
|
+
readonly markerSuperTypeForCheck: TypeParameter;
|
|
503
|
+
readonly markerSubTypeForCheck: TypeParameter;
|
|
504
|
+
readonly noTypePredicate: TypePredicate;
|
|
505
|
+
readonly anySignature: Signature;
|
|
506
|
+
readonly unknownSignature: Signature;
|
|
507
|
+
readonly resolvingSignature: Signature;
|
|
508
|
+
readonly silentNeverSignature: Signature;
|
|
509
|
+
readonly enumNumberIndexInfo: IndexInfo;
|
|
510
|
+
readonly anyBaseTypeIndexInfo: IndexInfo;
|
|
511
|
+
readonly emptyStringType: Type;
|
|
512
|
+
readonly zeroType: Type;
|
|
513
|
+
readonly zeroBigIntType: Type;
|
|
514
|
+
readonly typeofType: Type;
|
|
515
|
+
|
|
516
|
+
// Mappers that observe the types they map.
|
|
517
|
+
readonly reportUnreliableMapper: TypeMapper;
|
|
518
|
+
readonly reportUnmeasurableMapper: TypeMapper;
|
|
519
|
+
readonly restrictiveMapper: TypeMapper;
|
|
520
|
+
readonly permissiveMapper: TypeMapper;
|
|
521
|
+
readonly uniqueLiteralMapper: TypeMapper;
|
|
522
|
+
/** Set by the reporting mappers during variance measurement. */
|
|
523
|
+
reliabilityFlags = 0;
|
|
524
|
+
|
|
525
|
+
// Relations
|
|
526
|
+
readonly subtypeRelation = new Relation();
|
|
527
|
+
readonly strictSubtypeRelation = new Relation();
|
|
528
|
+
readonly assignableRelation = new Relation();
|
|
529
|
+
readonly comparableRelation = new Relation();
|
|
530
|
+
readonly identityRelation = new Relation();
|
|
531
|
+
readonly enumRelation = new Map<string, number>();
|
|
532
|
+
/** A relater that is not in use, kept so that relation checks don't allocate one each. */
|
|
533
|
+
spareRelater: Relater | undefined = undefined;
|
|
534
|
+
|
|
535
|
+
// Global types, set by `initializeChecker`.
|
|
536
|
+
globalArrayType: Type;
|
|
537
|
+
globalObjectType: Type;
|
|
538
|
+
globalFunctionType: Type;
|
|
539
|
+
globalCallableFunctionType: Type;
|
|
540
|
+
globalNewableFunctionType: Type;
|
|
541
|
+
globalStringType: Type;
|
|
542
|
+
globalNumberType: Type;
|
|
543
|
+
globalBooleanType: Type;
|
|
544
|
+
globalRegExpType: Type;
|
|
545
|
+
anyArrayType: Type;
|
|
546
|
+
autoArrayType: Type;
|
|
547
|
+
globalReadonlyArrayType: Type;
|
|
548
|
+
anyReadonlyArrayType: Type;
|
|
549
|
+
globalThisType: Type;
|
|
550
|
+
/** Lazily resolved global types and symbols, by name. */
|
|
551
|
+
readonly globalTypeCache = new Map<string, Map<number, Type>>();
|
|
552
|
+
/** Module namespace types with synthetic defaults, by kind and type id. */
|
|
553
|
+
readonly moduleTypeCache = new Map<string, Type>();
|
|
554
|
+
readonly globalSymbolCache = new Map<string, Symbol | null>();
|
|
555
|
+
|
|
556
|
+
// Resolution stacks for cycle detection (see pushTypeResolution).
|
|
557
|
+
resolutionStart = 0;
|
|
558
|
+
inVarianceComputation = false;
|
|
559
|
+
|
|
560
|
+
// Instantiation
|
|
561
|
+
instantiationDepth = 0;
|
|
562
|
+
instantiationCount = 0;
|
|
563
|
+
/** Instantiations over the checker's lifetime (statistics). */
|
|
564
|
+
totalInstantiations = 0;
|
|
565
|
+
/** Mappers of the instantiations in progress: the first `activeMapperDepth` entries are live. */
|
|
566
|
+
readonly activeMappers: TypeMapper[] = [];
|
|
567
|
+
activeMapperDepth = 0;
|
|
568
|
+
/** Per active mapper: its instantiations by type id, created on the first nested write. */
|
|
569
|
+
readonly activeMapperCaches: (Map<number, Type> | undefined)[] = [];
|
|
570
|
+
/** Per active mapper: its instantiations with an alias, by type id and alias key. */
|
|
571
|
+
readonly activeMapperAliasCaches: (Map<string, Type> | undefined)[] = [];
|
|
572
|
+
/**
|
|
573
|
+
* Cleared caches of popped mappers, reused as tsgo's pushActiveMapper reuses the maps
|
|
574
|
+
* popActiveMapper clears: the first `freeMapperCacheCount` are free.
|
|
575
|
+
*/
|
|
576
|
+
readonly freeMapperCaches: Map<number, Type>[] = [];
|
|
577
|
+
freeMapperCacheCount = 0;
|
|
578
|
+
/** Empty lists for type arguments that are compared with cached instantiations before any is kept. */
|
|
579
|
+
readonly freeTypeLists: Type[][] = [];
|
|
580
|
+
/**
|
|
581
|
+
* 1 by type id for the anonymous and mapped types whose declaration has no outer type parameters
|
|
582
|
+
* to instantiate (`getObjectTypeInstantiation`).
|
|
583
|
+
*/
|
|
584
|
+
readonly withoutOuterTypeParameters = new IntLinkTable();
|
|
585
|
+
conditionalConstraintDepth = 0;
|
|
586
|
+
|
|
587
|
+
readonly suggestionResolver: SuggestionNameResolver;
|
|
588
|
+
readonly awaitedTypeStack: number[] = [];
|
|
589
|
+
/** Iteration types by type id and iteration use. */
|
|
590
|
+
readonly iterationTypesCache = new Map<number, IterationTypes>();
|
|
591
|
+
/** Whether diagnostics can be deferred to the end of the file being checked. */
|
|
592
|
+
saveDeferredDiagnostics = false;
|
|
593
|
+
deferredIterationErrors: DeferredIterationError[] = [];
|
|
594
|
+
/** Collision checks waiting for the end of the file (checker-generated-code.ts). */
|
|
595
|
+
deferredCollisionChecks: DeferredCollisionCheck[] = [];
|
|
596
|
+
/** Binding patterns whose implied type is being computed as a contextual type. */
|
|
597
|
+
readonly contextualBindingPatterns: Node[] = [];
|
|
598
|
+
/** The binding pattern or assignment pattern that implied each type. */
|
|
599
|
+
readonly patternForType = new Map<Type, Node>();
|
|
600
|
+
/** Spread element indices of array literals with contextually typed elements. */
|
|
601
|
+
readonly spreadIndices = new Map<Node, SpreadIndices>();
|
|
602
|
+
/** Instantiation expression types by node and expression type id. */
|
|
603
|
+
readonly instantiationExpressionTypes = new Map<string, Type>();
|
|
604
|
+
relationComparers: TypeComparer[] = [];
|
|
605
|
+
readonly relationScratchKey = new RelationKey();
|
|
606
|
+
/** Numbers for relation keys that are spelled as strings (see getRelationKey). */
|
|
607
|
+
readonly relationKeyIds = new Map<string, number>();
|
|
608
|
+
/** Numbers for generic relation keys spelled as tokens, by a hash of the tokens. */
|
|
609
|
+
readonly relationKeyTokens = new Map<number, InternedRelationKey>();
|
|
610
|
+
/** The number of interned relation keys of both kinds. */
|
|
611
|
+
relationKeyCount = 0;
|
|
612
|
+
readonly markerTypes = new Set<Type>();
|
|
613
|
+
readonly arrayVariances: VarianceFlags[] = [VarianceFlags.Covariant];
|
|
614
|
+
nanLiteralType: LiteralType | undefined = undefined;
|
|
615
|
+
/** `{ meta: ImportMeta }`, the type of `import.meta` for symbol queries. */
|
|
616
|
+
importMetaExpressionType: Type | undefined = undefined;
|
|
617
|
+
|
|
618
|
+
// Control flow analysis
|
|
619
|
+
flowAnalysisDisabled = false;
|
|
620
|
+
inlineLevel = 0;
|
|
621
|
+
/**
|
|
622
|
+
* Shared flow nodes cached by the walks in progress, with their types: the first
|
|
623
|
+
* `sharedFlowCount` entries are live, later slots are reused.
|
|
624
|
+
*/
|
|
625
|
+
readonly sharedFlowNodes: FlowNode[] = [];
|
|
626
|
+
readonly sharedFlowTypes: Type[] = [];
|
|
627
|
+
readonly sharedFlowIncomplete: boolean[] = [];
|
|
628
|
+
sharedFlowCount = 0;
|
|
629
|
+
/**
|
|
630
|
+
* For each walk in progress, by its depth (`flowStateDepth`), once it has cached
|
|
631
|
+
* `sharedFlowIndexThreshold` shared nodes: the index of each node's first entry in the cache above.
|
|
632
|
+
*/
|
|
633
|
+
readonly sharedFlowIndexes: Map<FlowNode, number>[] = [];
|
|
634
|
+
/**
|
|
635
|
+
* Flow states, reused as in tsgo's getFlowState/putFlowState: the first `flowStateDepth` belong
|
|
636
|
+
* to walks in progress, the rest are free.
|
|
637
|
+
*/
|
|
638
|
+
readonly flowStates: FlowState[] = [];
|
|
639
|
+
flowStateDepth = 0;
|
|
640
|
+
readonly flowLoopCaches = new Map<FlowNode, Map<string, Type>>();
|
|
641
|
+
/** The last long walk of each reference key outside loops: see `FlowWalk`. */
|
|
642
|
+
readonly flowWalks = new Map<string, FlowWalk>();
|
|
643
|
+
flowLoopStack: FlowLoopInfo[] = [];
|
|
644
|
+
/** Types of expressions whose computation needed flow analysis, outside loop back edges. */
|
|
645
|
+
flowTypeCache: Map<Node, Type> | undefined = undefined;
|
|
646
|
+
flowInvocationCount = 0;
|
|
647
|
+
/** The reduce labels being passed, innermost last; each limits its target label's antecedents. */
|
|
648
|
+
readonly flowReduceLabels: FlowReduceLabel[] = [];
|
|
649
|
+
readonly flowNodeReachable = new Map<FlowNode, boolean>();
|
|
650
|
+
readonly flowNodePostSuper = new Map<FlowNode, boolean>();
|
|
651
|
+
lastFlowNode: FlowNode | undefined = undefined;
|
|
652
|
+
lastFlowNodeReachable = false;
|
|
653
|
+
readonly assignmentMarker: AssignmentMarker;
|
|
654
|
+
readonly primitiveTypeAliasSuggestions = new Map<string, Symbol>();
|
|
655
|
+
|
|
656
|
+
/** Renamed binding elements in parameters of bodiless signatures, checked for use with their file. */
|
|
657
|
+
readonly renamedBindingElementsInTypes: Node[] = [];
|
|
658
|
+
/** The type parameter whose variance annotation is being checked, to name its marker types. */
|
|
659
|
+
varianceTypeParameter: Type | undefined = undefined;
|
|
660
|
+
/** Whether the statement being checked is unreachable, to report unreachable code once. */
|
|
661
|
+
withinUnreachableCode = false;
|
|
662
|
+
readonly reportedUnreachableNodes = new Set<Node>();
|
|
663
|
+
/** The grammar checker of the file whose expressions are being checked. */
|
|
664
|
+
grammarChecker: GrammarChecker | undefined = undefined;
|
|
665
|
+
/** Nodes queued for a deferred check (checkNodeDeferred), each checked once. */
|
|
666
|
+
readonly deferredNodeIds = new Set<number>();
|
|
667
|
+
readonly typeNodeVisitor: TypeNodeVisitor;
|
|
668
|
+
|
|
669
|
+
readonly jsx = new JsxState();
|
|
670
|
+
/** Per file: its tslib module and the emit helpers checked against it (checkExternalEmitHelpers). */
|
|
671
|
+
readonly emitHelperFileLinks = new Map<SourceFile, EmitHelperFileLinks>();
|
|
672
|
+
/** The file checkSourceFile is checking. */
|
|
673
|
+
fileBeingChecked: SourceFile | undefined = undefined;
|
|
674
|
+
|
|
675
|
+
// Ambient modules
|
|
676
|
+
readonly ambientModuleSymbols: Symbol[] = [];
|
|
677
|
+
readonly patternAmbientModules: PatternAmbientModule[] = [];
|
|
678
|
+
readonly patternAmbientModuleAugmentations = new Map<string, Symbol>();
|
|
679
|
+
|
|
680
|
+
readonly inferenceCaches = new InferenceCaches();
|
|
681
|
+
/** The type resolution stack: the first `resolutionDepth` entries are live, later slots are reused. */
|
|
682
|
+
readonly resolutionTargets: (Symbol | Type | Signature | Node)[] = [];
|
|
683
|
+
readonly resolutionResults: boolean[] = [];
|
|
684
|
+
readonly resolutionPropertyNames: number[] = [];
|
|
685
|
+
resolutionDepth = 0;
|
|
686
|
+
/** The number of resolution cycles found (`pushTypeResolution`). */
|
|
687
|
+
resolutionCycleCount = 0;
|
|
688
|
+
|
|
689
|
+
constructor(host: CheckerHost) {
|
|
690
|
+
this.host = host;
|
|
691
|
+
const options = host.getCompilerOptions();
|
|
692
|
+
this.compilerOptions = options;
|
|
693
|
+
this.files = host.getSourceFiles();
|
|
694
|
+
this.fileIndex = new Map<SourceFile, number>();
|
|
695
|
+
for (let i = 0; i < this.files.length; i++) this.fileIndex.set(this.files[i]!, i);
|
|
696
|
+
this.languageVersion = getEmitScriptTarget(options);
|
|
697
|
+
this.strictNullChecks = getStrictOptionValue(options, options.strictNullChecks);
|
|
698
|
+
this.strictFunctionTypes = getStrictOptionValue(options, options.strictFunctionTypes);
|
|
699
|
+
this.strictBindCallApply = getStrictOptionValue(options, options.strictBindCallApply);
|
|
700
|
+
this.strictPropertyInitialization = getStrictOptionValue(options, options.strictPropertyInitialization);
|
|
701
|
+
this.strictBuiltinIteratorReturn = getStrictOptionValue(options, options.strictBuiltinIteratorReturn);
|
|
702
|
+
this.noImplicitAny = getStrictOptionValue(options, options.noImplicitAny);
|
|
703
|
+
this.noImplicitThis = getStrictOptionValue(options, options.noImplicitThis);
|
|
704
|
+
this.legacyDecorators = options.experimentalDecorators === true;
|
|
705
|
+
this.useUnknownInCatchVariables = getStrictOptionValue(options, options.useUnknownInCatchVariables);
|
|
706
|
+
this.exactOptionalPropertyTypes = options.exactOptionalPropertyTypes === true;
|
|
707
|
+
this.isolatedModules = getIsolatedModules(options);
|
|
708
|
+
this.preserveConstEnums = shouldPreserveConstEnums(options);
|
|
709
|
+
this.noUncheckedIndexedAccess = options.noUncheckedIndexedAccess === true;
|
|
710
|
+
|
|
711
|
+
this.undefinedSymbol = this.newSymbol(SymbolFlags.Property, 'undefined');
|
|
712
|
+
this.argumentsSymbol = this.newSymbol(SymbolFlags.Property, 'arguments');
|
|
713
|
+
this.requireSymbol = this.newSymbol(SymbolFlags.Property, 'require');
|
|
714
|
+
this.unknownSymbol = this.newSymbol(SymbolFlags.Property, 'unknown');
|
|
715
|
+
const merged = host.getMergedGlobals();
|
|
716
|
+
this.mergedGlobals = merged;
|
|
717
|
+
const libs = merged === undefined ? findLibGlobals(this) : undefined;
|
|
718
|
+
this.libGlobals = libs;
|
|
719
|
+
if (merged !== undefined) {
|
|
720
|
+
this.globals = new Map(merged.globals);
|
|
721
|
+
this.mergedSymbols = new Map(merged.mergedSymbols);
|
|
722
|
+
} else if (libs === undefined) {
|
|
723
|
+
this.globals = new Map<string, Symbol>();
|
|
724
|
+
this.mergedSymbols = new Map<number, Symbol>();
|
|
725
|
+
} else if (libs.borrower === undefined) {
|
|
726
|
+
borrowLibGlobals(this, libs);
|
|
727
|
+
this.globals = libs.globals;
|
|
728
|
+
this.mergedSymbols = libs.mergedSymbols;
|
|
729
|
+
} else {
|
|
730
|
+
this.globals = libs.copyGlobals();
|
|
731
|
+
this.mergedSymbols = libs.copyMergedSymbols();
|
|
732
|
+
}
|
|
733
|
+
this.globalThisSymbol = this.newSymbol(SymbolFlags.Module, 'globalThis');
|
|
734
|
+
this.globalThisSymbol.checkFlags = CheckFlags.Readonly;
|
|
735
|
+
this.globalThisSymbol.exports = this.globals;
|
|
736
|
+
setGlobal(this, this.globalThisSymbol.name, this.globalThisSymbol);
|
|
737
|
+
this.resolver = new CheckerNameResolver(this);
|
|
738
|
+
this.suggestionResolver = new SuggestionNameResolver(this);
|
|
739
|
+
this.typeNodeVisitor = new TypeNodeVisitor(this);
|
|
740
|
+
this.assignmentMarker = new AssignmentMarker(this);
|
|
741
|
+
|
|
742
|
+
this.anyType = this.newIntrinsicType(TypeFlags.Any, 'any', ObjectFlags.None);
|
|
743
|
+
this.autoType = this.newIntrinsicType(TypeFlags.Any, 'any', ObjectFlags.NonInferrableType);
|
|
744
|
+
this.wildcardType = this.newIntrinsicType(TypeFlags.Any, 'any', ObjectFlags.None);
|
|
745
|
+
this.blockedStringType = this.newIntrinsicType(TypeFlags.Any, 'any', ObjectFlags.None);
|
|
746
|
+
this.errorType = this.newIntrinsicType(TypeFlags.Any, 'error', ObjectFlags.None);
|
|
747
|
+
this.unresolvedType = this.newIntrinsicType(TypeFlags.Any, 'unresolved', ObjectFlags.None);
|
|
748
|
+
this.nonInferrableAnyType = this.newIntrinsicType(TypeFlags.Any, 'any', ObjectFlags.ContainsWideningType);
|
|
749
|
+
this.intrinsicMarkerType = this.newIntrinsicType(TypeFlags.Any, 'intrinsic', ObjectFlags.None);
|
|
750
|
+
this.unknownType = this.newIntrinsicType(TypeFlags.Unknown, 'unknown', ObjectFlags.None);
|
|
751
|
+
this.undefinedType = this.newIntrinsicType(TypeFlags.Undefined, 'undefined', ObjectFlags.None);
|
|
752
|
+
this.undefinedWideningType = this.strictNullChecks
|
|
753
|
+
? this.undefinedType
|
|
754
|
+
: this.newIntrinsicType(TypeFlags.Undefined, 'undefined', ObjectFlags.ContainsWideningType);
|
|
755
|
+
this.missingType = this.newIntrinsicType(TypeFlags.Undefined, 'undefined', ObjectFlags.None);
|
|
756
|
+
this.undefinedOrMissingType = this.exactOptionalPropertyTypes ? this.missingType : this.undefinedType;
|
|
757
|
+
this.optionalType = this.newIntrinsicType(TypeFlags.Undefined, 'undefined', ObjectFlags.None);
|
|
758
|
+
this.nullType = this.newIntrinsicType(TypeFlags.Null, 'null', ObjectFlags.None);
|
|
759
|
+
this.nullWideningType = this.strictNullChecks
|
|
760
|
+
? this.nullType
|
|
761
|
+
: this.newIntrinsicType(TypeFlags.Null, 'null', ObjectFlags.ContainsWideningType);
|
|
762
|
+
this.stringType = this.newIntrinsicType(TypeFlags.String, 'string', ObjectFlags.None);
|
|
763
|
+
this.numberType = this.newIntrinsicType(TypeFlags.Number, 'number', ObjectFlags.None);
|
|
764
|
+
this.bigintType = this.newIntrinsicType(TypeFlags.BigInt, 'bigint', ObjectFlags.None);
|
|
765
|
+
this.regularFalseType = this.newLiteralType(TypeFlags.BooleanLiteral, 'false', 0, undefined);
|
|
766
|
+
this.falseType = this.newLiteralType(TypeFlags.BooleanLiteral, 'false', 0, undefined);
|
|
767
|
+
this.falseType.regularType = this.regularFalseType;
|
|
768
|
+
this.regularFalseType.freshType = this.falseType;
|
|
769
|
+
this.falseType.freshType = this.falseType;
|
|
770
|
+
this.regularTrueType = this.newLiteralType(TypeFlags.BooleanLiteral, 'true', 0, undefined);
|
|
771
|
+
this.trueType = this.newLiteralType(TypeFlags.BooleanLiteral, 'true', 0, undefined);
|
|
772
|
+
this.trueType.regularType = this.regularTrueType;
|
|
773
|
+
this.regularTrueType.freshType = this.trueType;
|
|
774
|
+
this.trueType.freshType = this.trueType;
|
|
775
|
+
this.booleanType = getUnionType(this, [this.regularFalseType, this.regularTrueType]);
|
|
776
|
+
this.esSymbolType = this.newIntrinsicType(TypeFlags.ESSymbol, 'symbol', ObjectFlags.None);
|
|
777
|
+
this.voidType = this.newIntrinsicType(TypeFlags.Void, 'void', ObjectFlags.None);
|
|
778
|
+
this.neverType = this.newIntrinsicType(TypeFlags.Never, 'never', ObjectFlags.None);
|
|
779
|
+
this.silentNeverType = this.newIntrinsicType(TypeFlags.Never, 'never', ObjectFlags.NonInferrableType);
|
|
780
|
+
this.implicitNeverType = this.newIntrinsicType(TypeFlags.Never, 'never', ObjectFlags.None);
|
|
781
|
+
this.unreachableNeverType = this.newIntrinsicType(TypeFlags.Never, 'never', ObjectFlags.None);
|
|
782
|
+
this.nonPrimitiveType = this.newIntrinsicType(TypeFlags.NonPrimitive, 'object', ObjectFlags.None);
|
|
783
|
+
this.stringOrNumberType = getUnionType(this, [this.stringType, this.numberType]);
|
|
784
|
+
this.stringNumberSymbolType = getUnionType(this, [this.stringType, this.numberType, this.esSymbolType]);
|
|
785
|
+
this.numberOrBigIntType = getUnionType(this, [this.numberType, this.bigintType]);
|
|
786
|
+
this.numericStringType = getTemplateLiteralType(this, ['', ''], [this.numberType]);
|
|
787
|
+
this.templateConstraintType = getUnionType(this, [
|
|
788
|
+
this.stringType,
|
|
789
|
+
this.numberType,
|
|
790
|
+
this.booleanType,
|
|
791
|
+
this.bigintType,
|
|
792
|
+
this.nullType,
|
|
793
|
+
this.undefinedType,
|
|
794
|
+
]);
|
|
795
|
+
this.uniqueLiteralType = this.newIntrinsicType(TypeFlags.Never, 'never', ObjectFlags.None);
|
|
796
|
+
this.reportUnreliableMapper = new ReportingMapper(this, VarianceReporting.Unreliable);
|
|
797
|
+
this.reportUnmeasurableMapper = new ReportingMapper(this, VarianceReporting.Unmeasurable);
|
|
798
|
+
this.restrictiveMapper = new RestrictiveMapper(this);
|
|
799
|
+
this.permissiveMapper = new PermissiveMapper(this);
|
|
800
|
+
this.uniqueLiteralMapper = new UniqueLiteralMapper(this);
|
|
801
|
+
this.emptyObjectType = newAnonymousType(this, undefined);
|
|
802
|
+
this.emptyJsxObjectType = newAnonymousType(this, undefined);
|
|
803
|
+
this.emptyFreshJsxObjectType = newAnonymousType(this, undefined);
|
|
804
|
+
this.emptyTypeLiteralType = newAnonymousType(this, this.newSymbol(SymbolFlags.TypeLiteral, 'type'));
|
|
805
|
+
this.unknownEmptyObjectType = newAnonymousType(this, undefined);
|
|
806
|
+
this.unknownUnionType = this.strictNullChecks
|
|
807
|
+
? getUnionType(this, [this.undefinedType, this.nullType, this.unknownEmptyObjectType])
|
|
808
|
+
: this.unknownType;
|
|
809
|
+
this.emptyGenericType = newAnonymousType(this, undefined);
|
|
810
|
+
sideOf(this, this.emptyGenericType).instantiations = new TypeListCache<Type>();
|
|
811
|
+
this.anyFunctionType = newAnonymousType(this, undefined);
|
|
812
|
+
this.anyFunctionType.objectFlags |= ObjectFlags.NonInferrableType;
|
|
813
|
+
this.noConstraintType = newAnonymousType(this, undefined);
|
|
814
|
+
this.circularConstraintType = newAnonymousType(this, undefined);
|
|
815
|
+
this.resolvingDefaultType = newAnonymousType(this, undefined);
|
|
816
|
+
this.markerSuperType = this.newTypeParameter(undefined);
|
|
817
|
+
this.markerSubType = this.newTypeParameter(undefined);
|
|
818
|
+
this.markerSubType.constraint = this.markerSuperType;
|
|
819
|
+
this.markerOtherType = this.newTypeParameter(undefined);
|
|
820
|
+
this.markerSuperTypeForCheck = this.newTypeParameter(undefined);
|
|
821
|
+
this.markerSubTypeForCheck = this.newTypeParameter(undefined);
|
|
822
|
+
this.markerSubTypeForCheck.constraint = this.markerSuperTypeForCheck;
|
|
823
|
+
this.noTypePredicate = new TypePredicate(TypePredicateKind.Identifier, '<<unresolved>>', 0, this.anyType);
|
|
824
|
+
this.anySignature = this.newSignature(SignatureFlags.None, undefined, emptyTypes, undefined, [], this.anyType, 0);
|
|
825
|
+
this.unknownSignature = this.newSignature(
|
|
826
|
+
SignatureFlags.None,
|
|
827
|
+
undefined,
|
|
828
|
+
emptyTypes,
|
|
829
|
+
undefined,
|
|
830
|
+
[],
|
|
831
|
+
this.errorType,
|
|
832
|
+
0,
|
|
833
|
+
);
|
|
834
|
+
this.resolvingSignature = this.newSignature(
|
|
835
|
+
SignatureFlags.None,
|
|
836
|
+
undefined,
|
|
837
|
+
emptyTypes,
|
|
838
|
+
undefined,
|
|
839
|
+
[],
|
|
840
|
+
this.anyType,
|
|
841
|
+
0,
|
|
842
|
+
);
|
|
843
|
+
this.silentNeverSignature = this.newSignature(
|
|
844
|
+
SignatureFlags.None,
|
|
845
|
+
undefined,
|
|
846
|
+
emptyTypes,
|
|
847
|
+
undefined,
|
|
848
|
+
[],
|
|
849
|
+
this.silentNeverType,
|
|
850
|
+
0,
|
|
851
|
+
);
|
|
852
|
+
this.enumNumberIndexInfo = new IndexInfo(this.numberType, this.stringType, true, undefined, []);
|
|
853
|
+
this.anyBaseTypeIndexInfo = new IndexInfo(this.stringType, this.anyType, false, undefined, []);
|
|
854
|
+
this.emptyStringType = getStringLiteralType(this, '');
|
|
855
|
+
this.zeroType = getNumberLiteralType(this, 0);
|
|
856
|
+
this.zeroBigIntType = getBigIntLiteralType(this, '0');
|
|
857
|
+
const typeofNames = ['bigint', 'boolean', 'function', 'number', 'object', 'string', 'symbol', 'undefined'];
|
|
858
|
+
const typeofTypes: Type[] = [];
|
|
859
|
+
for (const name of typeofNames) typeofTypes.push(getStringLiteralType(this, name));
|
|
860
|
+
this.typeofType = getUnionType(this, typeofTypes);
|
|
861
|
+
|
|
862
|
+
// initializeChecker
|
|
863
|
+
this.diagnostics.startLog();
|
|
864
|
+
this.suggestionDiagnostics.startLog();
|
|
865
|
+
initializeGlobals(this);
|
|
866
|
+
this.mergeDiagnostics.push(this.diagnostics.takeLog(), this.suggestionDiagnostics.takeLog());
|
|
867
|
+
this.symbolTypes.set(getSymbolId(this.undefinedSymbol), this.undefinedWideningType);
|
|
868
|
+
this.symbolTypes.set(getSymbolId(this.argumentsSymbol), getGlobalType(this, 'IArguments', 0, true));
|
|
869
|
+
this.symbolTypes.set(getSymbolId(this.unknownSymbol), this.errorType);
|
|
870
|
+
this.symbolTypes.set(
|
|
871
|
+
getSymbolId(this.globalThisSymbol),
|
|
872
|
+
newObjectType(this, ObjectFlags.Anonymous, this.globalThisSymbol),
|
|
873
|
+
);
|
|
874
|
+
this.globalArrayType = getGlobalType(this, 'Array', 1, true);
|
|
875
|
+
this.globalObjectType = getGlobalType(this, 'Object', 0, true);
|
|
876
|
+
this.hasGlobalObjectType = true;
|
|
877
|
+
this.globalFunctionType = getGlobalType(this, 'Function', 0, true);
|
|
878
|
+
this.globalCallableFunctionType = getGlobalStrictFunctionType(this, 'CallableFunction');
|
|
879
|
+
this.globalNewableFunctionType = getGlobalStrictFunctionType(this, 'NewableFunction');
|
|
880
|
+
this.globalStringType = getGlobalType(this, 'String', 0, true);
|
|
881
|
+
this.globalNumberType = getGlobalType(this, 'Number', 0, true);
|
|
882
|
+
this.globalBooleanType = getGlobalType(this, 'Boolean', 0, true);
|
|
883
|
+
this.globalRegExpType = getGlobalType(this, 'RegExp', 0, true);
|
|
884
|
+
this.anyArrayType = createArrayType(this, this.anyType);
|
|
885
|
+
let autoArrayType = createArrayType(this, this.autoType);
|
|
886
|
+
// autoArrayType is a marker, so it must be unique even without a global Array type.
|
|
887
|
+
if (autoArrayType === this.emptyObjectType) autoArrayType = newAnonymousType(this, undefined);
|
|
888
|
+
this.autoArrayType = autoArrayType;
|
|
889
|
+
let readonlyArrayType = getGlobalType(this, 'ReadonlyArray', 1, false);
|
|
890
|
+
if (readonlyArrayType === this.emptyGenericType) readonlyArrayType = this.globalArrayType;
|
|
891
|
+
this.globalReadonlyArrayType = readonlyArrayType;
|
|
892
|
+
this.anyReadonlyArrayType = createTypeFromGenericGlobalType(this, readonlyArrayType, [this.anyType]);
|
|
893
|
+
this.globalThisType = getGlobalType(this, 'ThisType', 1, false);
|
|
894
|
+
this.diagnostics.startLog();
|
|
895
|
+
this.suggestionDiagnostics.startLog();
|
|
896
|
+
mergeAmbientModulesAndAugmentations(this);
|
|
897
|
+
this.mergeDiagnostics.push(this.diagnostics.takeLog(), this.suggestionDiagnostics.takeLog());
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// ---- Public API
|
|
901
|
+
|
|
902
|
+
/** Checks `file` if needed and returns its semantic diagnostics, sorted. */
|
|
903
|
+
getDiagnostics(file: SourceFile): Diagnostic[] {
|
|
904
|
+
const options = this.compilerOptions;
|
|
905
|
+
checkSourceFile(this, file, options.noUnusedLocals === true || options.noUnusedParameters === true);
|
|
906
|
+
return this.diagnostics.forFile(file.fileName);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** Checks `file`, including unused identifiers, and returns its suggestion diagnostics. */
|
|
910
|
+
getSuggestionDiagnostics(file: SourceFile): Diagnostic[] {
|
|
911
|
+
checkSourceFile(this, file, true);
|
|
912
|
+
return this.suggestionDiagnostics.forFile(file.fileName);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/** Diagnostics without a file, such as missing global types. */
|
|
916
|
+
getGlobalDiagnostics(): Diagnostic[] {
|
|
917
|
+
return this.diagnostics.globals();
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// ---- Links
|
|
921
|
+
|
|
922
|
+
/** The rarely used links of `symbol`, created on first use. */
|
|
923
|
+
symbolLinks(symbol: Symbol): SymbolLinks {
|
|
924
|
+
const id = getSymbolId(symbol);
|
|
925
|
+
let links = this.symbolLinkTable.get(id);
|
|
926
|
+
if (links === undefined) {
|
|
927
|
+
links = new SymbolLinks();
|
|
928
|
+
this.symbolLinkTable.set(id, links);
|
|
929
|
+
}
|
|
930
|
+
return links;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/** The links of `symbol` if it has any, without creating them. */
|
|
934
|
+
existingSymbolLinks(symbol: Symbol): SymbolLinks | undefined {
|
|
935
|
+
return this.symbolLinkTable.get(symbol.id);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/** The rarely used links of `node`, created on first use. */
|
|
939
|
+
nodeLinks(node: Node): NodeLinks {
|
|
940
|
+
const id = node.id;
|
|
941
|
+
let links = this.nodeLinkTable.get(id);
|
|
942
|
+
if (links === undefined) {
|
|
943
|
+
links = new NodeLinks();
|
|
944
|
+
this.nodeLinkTable.set(id, links);
|
|
945
|
+
}
|
|
946
|
+
return links;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/** The links of `node` if it has any, without creating them. */
|
|
950
|
+
existingNodeLinks(node: Node): NodeLinks | undefined {
|
|
951
|
+
return this.nodeLinkTable.get(node.id);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// ---- Constructors for types, symbols and signatures
|
|
955
|
+
|
|
956
|
+
nextTypeId(): number {
|
|
957
|
+
return ++this.typeCount;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// TypeChecking: for the methods of types tsc-ts's public API calls.
|
|
961
|
+
|
|
962
|
+
baseTypesOf(t: InterfaceType): readonly Type[] {
|
|
963
|
+
return getBaseTypes(this, t);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
trueTypeOf(t: ConditionalType): Type {
|
|
967
|
+
return getTrueTypeFromConditionalType(this, t);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
falseTypeOf(t: ConditionalType): Type {
|
|
971
|
+
return getFalseTypeFromConditionalType(this, t);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
newIntrinsicType(flags: TypeFlags, name: string, objectFlags: ObjectFlags): IntrinsicType {
|
|
975
|
+
return new IntrinsicType(flags, objectFlags, this.nextTypeId(), name);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
newLiteralType(flags: TypeFlags, stringValue: string, numberValue: number, symbol: Symbol | undefined): LiteralType {
|
|
979
|
+
return new LiteralType(flags, this.nextTypeId(), symbol, stringValue, numberValue);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
newTypeParameter(symbol: Symbol | undefined): TypeParameter {
|
|
983
|
+
return new TypeParameter(this.nextTypeId(), symbol);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
newSymbol(flags: SymbolFlags, name: string): Symbol {
|
|
987
|
+
const symbol = new Symbol(flags | SymbolFlags.Transient, name);
|
|
988
|
+
return symbol;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
newSymbolWithCheckFlags(flags: SymbolFlags, name: string, checkFlags: CheckFlags): Symbol {
|
|
992
|
+
const symbol = new Symbol(flags | SymbolFlags.Transient, name);
|
|
993
|
+
symbol.checkFlags = checkFlags;
|
|
994
|
+
return symbol;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
newSignature(
|
|
998
|
+
flags: SignatureFlags,
|
|
999
|
+
declaration: Node | undefined,
|
|
1000
|
+
typeParameters: Type[],
|
|
1001
|
+
thisParameter: Symbol | undefined,
|
|
1002
|
+
parameters: Symbol[],
|
|
1003
|
+
resolvedReturnType: Type | undefined,
|
|
1004
|
+
minArgumentCount: number,
|
|
1005
|
+
): Signature {
|
|
1006
|
+
return new Signature(
|
|
1007
|
+
++this.signatureCount,
|
|
1008
|
+
flags,
|
|
1009
|
+
declaration,
|
|
1010
|
+
typeParameters,
|
|
1011
|
+
thisParameter,
|
|
1012
|
+
parameters,
|
|
1013
|
+
resolvedReturnType,
|
|
1014
|
+
undefined,
|
|
1015
|
+
minArgumentCount,
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// ---- Diagnostics
|
|
1020
|
+
|
|
1021
|
+
/** Reports `message` at `node`, or as a global diagnostic without a node. */
|
|
1022
|
+
error(node: Node | undefined, message: DiagnosticMessage, ...args: string[]): Diagnostic {
|
|
1023
|
+
const diagnostic = createDiagnosticForNode(node, message, args);
|
|
1024
|
+
this.addDiagnostic(diagnostic);
|
|
1025
|
+
return diagnostic;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
addDiagnostic(diagnostic: Diagnostic): void {
|
|
1029
|
+
// Discard diagnostics created while at the maximum number of nested typeToString calls.
|
|
1030
|
+
if (this.serializationLevel < maxSerializationLevel) this.diagnostics.add(diagnostic);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
addSuggestion(diagnostic: Diagnostic): void {
|
|
1034
|
+
this.suggestionDiagnostics.add(diagnostic);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Reports an error, or a suggestion when `isError` is false. */
|
|
1038
|
+
addErrorOrSuggestion(isError: boolean, diagnostic: Diagnostic): void {
|
|
1039
|
+
if (isError) this.addDiagnostic(diagnostic);
|
|
1040
|
+
else this.addSuggestion(diagnostic);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Drops a checker's links and type caches. Native builds free memory by reference counting, and
|
|
1046
|
+
* the checker's caches, types and mappers reference each other; releasing them early lets most of
|
|
1047
|
+
* them go without a cycle collection.
|
|
1048
|
+
*/
|
|
1049
|
+
export function disposeChecker(c: Checker): void {
|
|
1050
|
+
c.symbolLinkTable.clear();
|
|
1051
|
+
c.nodeLinkTable.clear();
|
|
1052
|
+
c.symbolTypes.clear();
|
|
1053
|
+
c.symbolTargets.clear();
|
|
1054
|
+
c.symbolMappers.clear();
|
|
1055
|
+
c.symbolNameTypes.clear();
|
|
1056
|
+
c.symbolContainingTypes.clear();
|
|
1057
|
+
c.symbolKeyTypes.clear();
|
|
1058
|
+
c.symbolSyntheticOrigins.clear();
|
|
1059
|
+
c.symbolLeftSpreads.clear();
|
|
1060
|
+
c.symbolRightSpreads.clear();
|
|
1061
|
+
c.symbolReferenceKinds.clear();
|
|
1062
|
+
c.resolvedSymbols.clear();
|
|
1063
|
+
c.resolvedTypes.clear();
|
|
1064
|
+
c.resolvedSignatures.clear();
|
|
1065
|
+
c.spareRelater = undefined;
|
|
1066
|
+
if (c.globalChanges !== undefined) returnLibGlobals(c);
|
|
1067
|
+
else {
|
|
1068
|
+
c.mergedSymbols.clear();
|
|
1069
|
+
c.globals.clear();
|
|
1070
|
+
}
|
|
1071
|
+
c.sharedSymbolCopies.clear();
|
|
1072
|
+
c.memberPositionsInLists.clear();
|
|
1073
|
+
c.memberNamesOfLists.clear();
|
|
1074
|
+
c.propertiesByName.clear();
|
|
1075
|
+
c.symbolAccessibilityCaches = undefined;
|
|
1076
|
+
c.unresolvedSymbols.clear();
|
|
1077
|
+
c.undefinedProperties.clear();
|
|
1078
|
+
c.stringLiteralTypes.clear();
|
|
1079
|
+
c.numberLiteralTypes.clear();
|
|
1080
|
+
c.bigintLiteralTypes.clear();
|
|
1081
|
+
c.enumLiteralTypes.clear();
|
|
1082
|
+
c.uniqueESSymbolTypes.clear();
|
|
1083
|
+
c.unionTypesByHash.clear();
|
|
1084
|
+
c.unionTypes.clear();
|
|
1085
|
+
c.unionOfUnionTypes.clear();
|
|
1086
|
+
c.unionOfUnionTypesById.clear();
|
|
1087
|
+
c.intersectionTypes.clear();
|
|
1088
|
+
c.tupleTypes.clear();
|
|
1089
|
+
c.indexedAccessTypes.clear();
|
|
1090
|
+
c.templateLiteralTypes.clear();
|
|
1091
|
+
c.templateLiteralInstantiations.clear();
|
|
1092
|
+
c.stringMappingTypes.clear();
|
|
1093
|
+
c.substitutionTypes.clear();
|
|
1094
|
+
c.subtypeReductionCache.clear();
|
|
1095
|
+
c.cachedTypes.clear();
|
|
1096
|
+
c.cachedTypesById.clear();
|
|
1097
|
+
c.cachedTypesByPair.clear();
|
|
1098
|
+
c.iterationTypesCache.clear();
|
|
1099
|
+
c.deferredIterationErrors = [];
|
|
1100
|
+
c.deferredCollisionChecks = [];
|
|
1101
|
+
c.errorTypes.clear();
|
|
1102
|
+
c.globalTypeCache.clear();
|
|
1103
|
+
c.globalSymbolCache.clear();
|
|
1104
|
+
c.markerTypes.clear();
|
|
1105
|
+
c.flowLoopCaches.clear();
|
|
1106
|
+
c.flowWalks.clear();
|
|
1107
|
+
c.flowNodeReachable.clear();
|
|
1108
|
+
c.flowNodePostSuper.clear();
|
|
1109
|
+
c.primitiveTypeAliasSuggestions.clear();
|
|
1110
|
+
c.patternAmbientModuleAugmentations.clear();
|
|
1111
|
+
c.sharedFlowTypes.length = 0;
|
|
1112
|
+
c.relationComparers = [];
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
export const enum VarianceReporting {
|
|
1116
|
+
Unreliable = 1 << 4,
|
|
1117
|
+
Unmeasurable = 1 << 3,
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/** A diagnostic at `node`'s error range, or a global one without a node. */
|
|
1121
|
+
export function createDiagnosticForNode(
|
|
1122
|
+
node: Node | undefined,
|
|
1123
|
+
message: DiagnosticMessage,
|
|
1124
|
+
args: string[],
|
|
1125
|
+
): Diagnostic {
|
|
1126
|
+
// Without a node, the diagnostic has no file and an empty range at 0, as in tsgo.
|
|
1127
|
+
if (node === undefined) return new Diagnostic(undefined, 0, 0, message, args);
|
|
1128
|
+
const file = getSourceFileOfNode(node);
|
|
1129
|
+
const range = getErrorRangeForNode(file, node);
|
|
1130
|
+
return new Diagnostic(file.diagnosticFile(), range.pos, range.end, message, args);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/** A message for `chainDiagnostic`-style elaboration; the location is taken from the head. */
|
|
1134
|
+
export function messageDiagnostic(message: DiagnosticMessage, args: string[]): Diagnostic {
|
|
1135
|
+
return new Diagnostic(undefined, 0, 0, message, args);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export { Diagnostics, ScriptTarget };
|