tsc-ts 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/api/compiler/ast-utilities.d.ts +82 -0
- package/dist/api/compiler/ast-utilities.js +462 -0
- package/dist/api/compiler/ast.d.ts +2350 -0
- package/dist/api/compiler/ast.js +11206 -0
- package/dist/api/compiler/astnav.d.ts +37 -0
- package/dist/api/compiler/astnav.js +767 -0
- package/dist/api/compiler/binder-utilities.d.ts +182 -0
- package/dist/api/compiler/binder-utilities.js +1240 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2358 -0
- package/dist/api/compiler/character-codes.d.ts +161 -0
- package/dist/api/compiler/character-codes.js +160 -0
- package/dist/api/compiler/checker-calls.d.ts +46 -0
- package/dist/api/compiler/checker-calls.js +1640 -0
- package/dist/api/compiler/checker-classes.d.ts +30 -0
- package/dist/api/compiler/checker-classes.js +582 -0
- package/dist/api/compiler/checker-contextual.d.ts +77 -0
- package/dist/api/compiler/checker-contextual.js +1136 -0
- package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
- package/dist/api/compiler/checker-declaration-order.js +356 -0
- package/dist/api/compiler/checker-declarations.d.ts +33 -0
- package/dist/api/compiler/checker-declarations.js +888 -0
- package/dist/api/compiler/checker-declared-types.d.ts +48 -0
- package/dist/api/compiler/checker-declared-types.js +787 -0
- package/dist/api/compiler/checker-decorators.d.ts +26 -0
- package/dist/api/compiler/checker-decorators.js +562 -0
- package/dist/api/compiler/checker-deprecation.d.ts +33 -0
- package/dist/api/compiler/checker-deprecation.js +315 -0
- package/dist/api/compiler/checker-destructuring.d.ts +34 -0
- package/dist/api/compiler/checker-destructuring.js +584 -0
- package/dist/api/compiler/checker-elaboration.d.ts +15 -0
- package/dist/api/compiler/checker-elaboration.js +290 -0
- package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
- package/dist/api/compiler/checker-emit-helpers.js +154 -0
- package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
- package/dist/api/compiler/checker-emit-resolver.js +579 -0
- package/dist/api/compiler/checker-evaluator.d.ts +27 -0
- package/dist/api/compiler/checker-evaluator.js +188 -0
- package/dist/api/compiler/checker-expressions.d.ts +67 -0
- package/dist/api/compiler/checker-expressions.js +1351 -0
- package/dist/api/compiler/checker-features.d.ts +6 -0
- package/dist/api/compiler/checker-features.js +354 -0
- package/dist/api/compiler/checker-flow.d.ts +86 -0
- package/dist/api/compiler/checker-flow.js +169 -0
- package/dist/api/compiler/checker-functions.d.ts +43 -0
- package/dist/api/compiler/checker-functions.js +1002 -0
- package/dist/api/compiler/checker-generated-code.d.ts +25 -0
- package/dist/api/compiler/checker-generated-code.js +168 -0
- package/dist/api/compiler/checker-globals.d.ts +14 -0
- package/dist/api/compiler/checker-globals.js +37 -0
- package/dist/api/compiler/checker-grammar.d.ts +35 -0
- package/dist/api/compiler/checker-grammar.js +2573 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +900 -0
- package/dist/api/compiler/checker-inference.d.ts +179 -0
- package/dist/api/compiler/checker-inference.js +2105 -0
- package/dist/api/compiler/checker-iteration.d.ts +115 -0
- package/dist/api/compiler/checker-iteration.js +857 -0
- package/dist/api/compiler/checker-javascript.d.ts +42 -0
- package/dist/api/compiler/checker-javascript.js +441 -0
- package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
- package/dist/api/compiler/checker-jsdoc.js +320 -0
- package/dist/api/compiler/checker-jsx.d.ts +94 -0
- package/dist/api/compiler/checker-jsx.js +1433 -0
- package/dist/api/compiler/checker-literals.d.ts +6 -0
- package/dist/api/compiler/checker-literals.js +43 -0
- package/dist/api/compiler/checker-members.d.ts +198 -0
- package/dist/api/compiler/checker-members.js +2126 -0
- package/dist/api/compiler/checker-modules.d.ts +85 -0
- package/dist/api/compiler/checker-modules.js +2141 -0
- package/dist/api/compiler/checker-narrowing.d.ts +120 -0
- package/dist/api/compiler/checker-narrowing.js +2797 -0
- package/dist/api/compiler/checker-object-literals.d.ts +14 -0
- package/dist/api/compiler/checker-object-literals.js +479 -0
- package/dist/api/compiler/checker-operators.d.ts +33 -0
- package/dist/api/compiler/checker-operators.js +1040 -0
- package/dist/api/compiler/checker-overloads.d.ts +7 -0
- package/dist/api/compiler/checker-overloads.js +270 -0
- package/dist/api/compiler/checker-property-access.d.ts +34 -0
- package/dist/api/compiler/checker-property-access.js +672 -0
- package/dist/api/compiler/checker-services.d.ts +49 -0
- package/dist/api/compiler/checker-services.js +995 -0
- package/dist/api/compiler/checker-signatures.d.ts +55 -0
- package/dist/api/compiler/checker-signatures.js +788 -0
- package/dist/api/compiler/checker-source-file.d.ts +27 -0
- package/dist/api/compiler/checker-source-file.js +619 -0
- package/dist/api/compiler/checker-statements.d.ts +18 -0
- package/dist/api/compiler/checker-statements.js +226 -0
- package/dist/api/compiler/checker-super.d.ts +13 -0
- package/dist/api/compiler/checker-super.js +241 -0
- package/dist/api/compiler/checker-symbol-types.d.ts +67 -0
- package/dist/api/compiler/checker-symbol-types.js +1885 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1782 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2501 -0
- package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
- package/dist/api/compiler/checker-type-nodes.js +828 -0
- package/dist/api/compiler/checker-type-operators.d.ts +109 -0
- package/dist/api/compiler/checker-type-operators.js +1842 -0
- package/dist/api/compiler/checker-types.d.ts +1027 -0
- package/dist/api/compiler/checker-types.js +1697 -0
- package/dist/api/compiler/checker-unused.d.ts +19 -0
- package/dist/api/compiler/checker-unused.js +524 -0
- package/dist/api/compiler/checker-utilities.d.ts +33 -0
- package/dist/api/compiler/checker-utilities.js +141 -0
- package/dist/api/compiler/checker.d.ts +491 -0
- package/dist/api/compiler/checker.js +912 -0
- package/dist/api/compiler/command-line.d.ts +32 -0
- package/dist/api/compiler/command-line.js +383 -0
- package/dist/api/compiler/compile-program.d.ts +118 -0
- package/dist/api/compiler/compile-program.js +384 -0
- package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
- package/dist/api/compiler/diagnostic-locales.js +64 -0
- package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
- package/dist/api/compiler/diagnostic-messages.js +184 -0
- package/dist/api/compiler/diagnostics.d.ts +167 -0
- package/dist/api/compiler/diagnostics.js +820 -0
- package/dist/api/compiler/emitter.d.ts +71 -0
- package/dist/api/compiler/emitter.js +327 -0
- package/dist/api/compiler/file-include.d.ts +117 -0
- package/dist/api/compiler/file-include.js +536 -0
- package/dist/api/compiler/file-loader.d.ts +261 -0
- package/dist/api/compiler/file-loader.js +1257 -0
- package/dist/api/compiler/file-system.d.ts +51 -0
- package/dist/api/compiler/file-system.js +132 -0
- package/dist/api/compiler/flow.d.ts +60 -0
- package/dist/api/compiler/flow.js +45 -0
- package/dist/api/compiler/instantiation.d.ts +74 -0
- package/dist/api/compiler/instantiation.js +799 -0
- package/dist/api/compiler/jsdoc.d.ts +75 -0
- package/dist/api/compiler/jsdoc.js +1229 -0
- package/dist/api/compiler/link-tables.d.ts +36 -0
- package/dist/api/compiler/link-tables.js +83 -0
- package/dist/api/compiler/locale-data.d.ts +24 -0
- package/dist/api/compiler/locale-data.js +183 -0
- package/dist/api/compiler/locale.d.ts +4 -0
- package/dist/api/compiler/locale.js +317 -0
- package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
- package/dist/api/compiler/locales/cs-CZ.js +3 -0
- package/dist/api/compiler/locales/de-DE.d.ts +2 -0
- package/dist/api/compiler/locales/de-DE.js +3 -0
- package/dist/api/compiler/locales/es-ES.d.ts +2 -0
- package/dist/api/compiler/locales/es-ES.js +3 -0
- package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
- package/dist/api/compiler/locales/fr-FR.js +3 -0
- package/dist/api/compiler/locales/it-IT.d.ts +2 -0
- package/dist/api/compiler/locales/it-IT.js +3 -0
- package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
- package/dist/api/compiler/locales/ja-JP.js +3 -0
- package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
- package/dist/api/compiler/locales/ko-KR.js +3 -0
- package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
- package/dist/api/compiler/locales/pl-PL.js +3 -0
- package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
- package/dist/api/compiler/locales/pt-BR.js +3 -0
- package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
- package/dist/api/compiler/locales/ru-RU.js +3 -0
- package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
- package/dist/api/compiler/locales/tr-TR.js +3 -0
- package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
- package/dist/api/compiler/locales/zh-CN.js +3 -0
- package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
- package/dist/api/compiler/locales/zh-TW.js +3 -0
- package/dist/api/compiler/module-resolution-types.d.ts +83 -0
- package/dist/api/compiler/module-resolution-types.js +176 -0
- package/dist/api/compiler/module-resolution.d.ts +71 -0
- package/dist/api/compiler/module-resolution.js +1598 -0
- package/dist/api/compiler/module-specifiers.d.ts +64 -0
- package/dist/api/compiler/module-specifiers.js +1101 -0
- package/dist/api/compiler/name-resolver.d.ts +43 -0
- package/dist/api/compiler/name-resolver.js +509 -0
- package/dist/api/compiler/node-builder-names.d.ts +32 -0
- package/dist/api/compiler/node-builder-names.js +854 -0
- package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
- package/dist/api/compiler/node-builder-pseudo.js +744 -0
- package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
- package/dist/api/compiler/node-builder-reuse.js +647 -0
- package/dist/api/compiler/node-builder.d.ts +270 -0
- package/dist/api/compiler/node-builder.js +2645 -0
- package/dist/api/compiler/option-declarations.d.ts +90 -0
- package/dist/api/compiler/option-declarations.js +1460 -0
- package/dist/api/compiler/options.d.ts +289 -0
- package/dist/api/compiler/options.js +1197 -0
- package/dist/api/compiler/output-paths.d.ts +42 -0
- package/dist/api/compiler/output-paths.js +195 -0
- package/dist/api/compiler/package-json.d.ts +175 -0
- package/dist/api/compiler/package-json.js +1015 -0
- package/dist/api/compiler/parallel-parse.d.ts +219 -0
- package/dist/api/compiler/parallel-parse.js +537 -0
- package/dist/api/compiler/parser.d.ts +587 -0
- package/dist/api/compiler/parser.js +6407 -0
- package/dist/api/compiler/path.d.ts +91 -0
- package/dist/api/compiler/path.js +705 -0
- package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
- package/dist/api/compiler/printer/async-helpers.js +91 -0
- package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
- package/dist/api/compiler/printer/auto-generate.js +20 -0
- package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
- package/dist/api/compiler/printer/decorator-helpers.js +118 -0
- package/dist/api/compiler/printer/emit-context.d.ts +154 -0
- package/dist/api/compiler/printer/emit-context.js +576 -0
- package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
- package/dist/api/compiler/printer/emit-flags.js +2 -0
- package/dist/api/compiler/printer/factory-base.d.ts +171 -0
- package/dist/api/compiler/printer/factory-base.js +1505 -0
- package/dist/api/compiler/printer/factory.d.ts +147 -0
- package/dist/api/compiler/printer/factory.js +542 -0
- package/dist/api/compiler/printer/helpers.d.ts +27 -0
- package/dist/api/compiler/printer/helpers.js +164 -0
- package/dist/api/compiler/printer/name-generator.d.ts +41 -0
- package/dist/api/compiler/printer/name-generator.js +283 -0
- package/dist/api/compiler/printer/printer.d.ts +411 -0
- package/dist/api/compiler/printer/printer.js +4517 -0
- package/dist/api/compiler/printer/text-writer.d.ts +46 -0
- package/dist/api/compiler/printer/text-writer.js +172 -0
- package/dist/api/compiler/printer/utilities.d.ts +82 -0
- package/dist/api/compiler/printer/utilities.js +817 -0
- package/dist/api/compiler/program-checker.d.ts +156 -0
- package/dist/api/compiler/program-checker.js +526 -0
- package/dist/api/compiler/program-utilities.d.ts +52 -0
- package/dist/api/compiler/program-utilities.js +365 -0
- package/dist/api/compiler/program.d.ts +180 -0
- package/dist/api/compiler/program.js +1011 -0
- package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
- package/dist/api/compiler/pseudo-bigint.js +61 -0
- package/dist/api/compiler/regexp-checker.d.ts +38 -0
- package/dist/api/compiler/regexp-checker.js +942 -0
- package/dist/api/compiler/relations.d.ts +263 -0
- package/dist/api/compiler/relations.js +4002 -0
- package/dist/api/compiler/reparser.d.ts +48 -0
- package/dist/api/compiler/reparser.js +1323 -0
- package/dist/api/compiler/scanner.d.ts +256 -0
- package/dist/api/compiler/scanner.js +2853 -0
- package/dist/api/compiler/side-state.d.ts +16 -0
- package/dist/api/compiler/side-state.js +89 -0
- package/dist/api/compiler/sourcemap.d.ts +55 -0
- package/dist/api/compiler/sourcemap.js +340 -0
- package/dist/api/compiler/spelling.d.ts +14 -0
- package/dist/api/compiler/spelling.js +128 -0
- package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
- package/dist/api/compiler/symbol-accessibility.js +894 -0
- package/dist/api/compiler/symbol.d.ts +240 -0
- package/dist/api/compiler/symbol.js +228 -0
- package/dist/api/compiler/symlinks.d.ts +32 -0
- package/dist/api/compiler/symlinks.js +114 -0
- package/dist/api/compiler/syntax-kind.d.ts +389 -0
- package/dist/api/compiler/syntax-kind.js +2 -0
- package/dist/api/compiler/timeline.d.ts +9 -0
- package/dist/api/compiler/timeline.js +54 -0
- package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
- package/dist/api/compiler/transformers/alias-references.js +676 -0
- package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
- package/dist/api/compiler/transformers/async-utilities.js +260 -0
- package/dist/api/compiler/transformers/async.d.ts +53 -0
- package/dist/api/compiler/transformers/async.js +645 -0
- package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
- package/dist/api/compiler/transformers/class-fields.js +2418 -0
- package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
- package/dist/api/compiler/transformers/class-utilities.js +261 -0
- package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
- package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
- package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
- package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.js +538 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +797 -0
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
- package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
- package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
- package/dist/api/compiler/transformers/declarations-tracker.js +197 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2380 -0
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
- package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
- package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
- package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
- package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
- package/dist/api/compiler/transformers/destructuring.js +626 -0
- package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
- package/dist/api/compiler/transformers/downlevel.js +45 -0
- package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
- package/dist/api/compiler/transformers/emit-resolver.js +197 -0
- package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
- package/dist/api/compiler/transformers/es-decorators.js +1901 -0
- package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
- package/dist/api/compiler/transformers/exponentiation.js +76 -0
- package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
- package/dist/api/compiler/transformers/external-module-info.js +351 -0
- package/dist/api/compiler/transformers/for-await.d.ts +43 -0
- package/dist/api/compiler/transformers/for-await.js +469 -0
- package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
- package/dist/api/compiler/transformers/import-elision.js +124 -0
- package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
- package/dist/api/compiler/transformers/jsx-entities.js +256 -0
- package/dist/api/compiler/transformers/jsx.d.ts +71 -0
- package/dist/api/compiler/transformers/jsx.js +700 -0
- package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
- package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
- package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
- package/dist/api/compiler/transformers/logical-assignment.js +62 -0
- package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
- package/dist/api/compiler/transformers/module-utilities.js +36 -0
- package/dist/api/compiler/transformers/module.d.ts +49 -0
- package/dist/api/compiler/transformers/module.js +296 -0
- package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
- package/dist/api/compiler/transformers/named-evaluation.js +266 -0
- package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
- package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
- package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
- package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
- package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
- package/dist/api/compiler/transformers/optional-catch.js +20 -0
- package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
- package/dist/api/compiler/transformers/optional-chain.js +188 -0
- package/dist/api/compiler/transformers/reference-resolver.d.ts +128 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1155 -0
- package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
- package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
- package/dist/api/compiler/transformers/subtree-facts.d.ts +9 -0
- package/dist/api/compiler/transformers/subtree-facts.js +203 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +51 -0
- package/dist/api/compiler/transformers/syntax-facts.js +254 -0
- package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
- package/dist/api/compiler/transformers/tagged-template.js +148 -0
- package/dist/api/compiler/transformers/transformer.d.ts +17 -0
- package/dist/api/compiler/transformers/transformer.js +54 -0
- package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
- package/dist/api/compiler/transformers/type-eraser.js +346 -0
- package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
- package/dist/api/compiler/transformers/type-serialization.js +347 -0
- package/dist/api/compiler/transformers/using.d.ts +56 -0
- package/dist/api/compiler/transformers/using.js +453 -0
- package/dist/api/compiler/transformers/utilities.d.ts +50 -0
- package/dist/api/compiler/transformers/utilities.js +347 -0
- package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
- package/dist/api/compiler/transformers/visitor-base.js +817 -0
- package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
- package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
- package/dist/api/compiler/tsconfig.d.ts +177 -0
- package/dist/api/compiler/tsconfig.js +1311 -0
- package/dist/api/compiler/type-printer.d.ts +15 -0
- package/dist/api/compiler/type-printer.js +74 -0
- package/dist/api/compiler/types.d.ts +87 -0
- package/dist/api/compiler/types.js +23 -0
- package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
- package/dist/api/compiler/unicode-identifiers.js +209 -0
- package/dist/api/compiler/unicode-properties.d.ts +8 -0
- package/dist/api/compiler/unicode-properties.js +531 -0
- package/dist/api/compiler/vfs-match.d.ts +24 -0
- package/dist/api/compiler/vfs-match.js +587 -0
- package/dist/api/library/ast.d.ts +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 +12862 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2703 -0
- package/src/compiler/build-info.ts +1197 -0
- package/src/compiler/character-codes.ts +323 -0
- package/src/compiler/checker-calls.ts +2155 -0
- package/src/compiler/checker-classes.ts +706 -0
- package/src/compiler/checker-contextual.ts +1457 -0
- package/src/compiler/checker-declaration-order.ts +438 -0
- package/src/compiler/checker-declarations.ts +1194 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +359 -0
- package/src/compiler/checker-destructuring.ts +805 -0
- package/src/compiler/checker-elaboration.ts +477 -0
- package/src/compiler/checker-emit-helpers.ts +224 -0
- package/src/compiler/checker-emit-resolver.ts +769 -0
- package/src/compiler/checker-evaluator.ts +243 -0
- package/src/compiler/checker-expressions.ts +1831 -0
- package/src/compiler/checker-features.ts +361 -0
- package/src/compiler/checker-flow.ts +394 -0
- package/src/compiler/checker-functions.ts +1296 -0
- package/src/compiler/checker-generated-code.ts +227 -0
- package/src/compiler/checker-globals.ts +52 -0
- package/src/compiler/checker-grammar.ts +3584 -0
- package/src/compiler/checker-heritage.ts +1233 -0
- package/src/compiler/checker-inference.ts +2576 -0
- package/src/compiler/checker-iteration.ts +1206 -0
- package/src/compiler/checker-javascript.ts +502 -0
- package/src/compiler/checker-jsdoc.ts +360 -0
- package/src/compiler/checker-jsx.ts +1924 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2436 -0
- package/src/compiler/checker-modules.ts +2886 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +575 -0
- package/src/compiler/checker-operators.ts +1422 -0
- package/src/compiler/checker-overloads.ts +328 -0
- package/src/compiler/checker-property-access.ts +906 -0
- package/src/compiler/checker-services.ts +1149 -0
- package/src/compiler/checker-signatures.ts +1032 -0
- package/src/compiler/checker-source-file.ts +732 -0
- package/src/compiler/checker-statements.ts +292 -0
- package/src/compiler/checker-super.ts +261 -0
- package/src/compiler/checker-symbol-types.ts +2107 -0
- package/src/compiler/checker-symbols.ts +2150 -0
- package/src/compiler/checker-type-factory.ts +2579 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2502 -0
- package/src/compiler/checker-types.ts +2340 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1116 -0
- package/src/compiler/command-line.ts +436 -0
- package/src/compiler/compile-program.ts +439 -0
- package/src/compiler/decoder.ts +1209 -0
- package/src/compiler/diagnostic-locales.ts +86 -0
- package/src/compiler/diagnostic-messages.ts +2349 -0
- package/src/compiler/diagnostics.ts +897 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +673 -0
- package/src/compiler/file-loader.ts +1528 -0
- package/src/compiler/file-system.ts +143 -0
- package/src/compiler/flow.ts +89 -0
- package/src/compiler/help.ts +473 -0
- package/src/compiler/incremental.ts +2784 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +894 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +98 -0
- package/src/compiler/locale-data.ts +203 -0
- package/src/compiler/locale.ts +307 -0
- package/src/compiler/locales/cs-CZ.ts +5 -0
- package/src/compiler/locales/de-DE.ts +5 -0
- package/src/compiler/locales/es-ES.ts +5 -0
- package/src/compiler/locales/fr-FR.ts +5 -0
- package/src/compiler/locales/it-IT.ts +5 -0
- package/src/compiler/locales/ja-JP.ts +5 -0
- package/src/compiler/locales/ko-KR.ts +5 -0
- package/src/compiler/locales/pl-PL.ts +5 -0
- package/src/compiler/locales/pt-BR.ts +5 -0
- package/src/compiler/locales/ru-RU.ts +5 -0
- package/src/compiler/locales/tr-TR.ts +5 -0
- package/src/compiler/locales/zh-CN.ts +5 -0
- package/src/compiler/locales/zh-TW.ts +5 -0
- package/src/compiler/module-resolution-types.ts +243 -0
- package/src/compiler/module-resolution.ts +2072 -0
- package/src/compiler/module-specifiers.ts +1491 -0
- package/src/compiler/name-resolver.ts +646 -0
- package/src/compiler/node-builder-names.ts +1069 -0
- package/src/compiler/node-builder-pseudo.ts +892 -0
- package/src/compiler/node-builder-reuse.ts +764 -0
- package/src/compiler/node-builder.ts +3425 -0
- package/src/compiler/option-declarations.ts +1560 -0
- package/src/compiler/options.ts +1576 -0
- package/src/compiler/output-paths.ts +334 -0
- package/src/compiler/package-json.ts +1083 -0
- package/src/compiler/parallel-check.ts +1951 -0
- package/src/compiler/parallel-parse.ts +590 -0
- package/src/compiler/parse-thread.ts +140 -0
- package/src/compiler/parser.ts +7716 -0
- package/src/compiler/path.ts +717 -0
- package/src/compiler/printer/async-helpers.ts +183 -0
- package/src/compiler/printer/auto-generate.ts +27 -0
- package/src/compiler/printer/decorator-helpers.ts +218 -0
- package/src/compiler/printer/emit-context.ts +679 -0
- package/src/compiler/printer/emit-flags.ts +64 -0
- package/src/compiler/printer/factory-base.ts +2577 -0
- package/src/compiler/printer/factory.ts +764 -0
- package/src/compiler/printer/helpers.ts +291 -0
- package/src/compiler/printer/name-generator.ts +372 -0
- package/src/compiler/printer/printer.ts +5072 -0
- package/src/compiler/printer/text-writer.ts +183 -0
- package/src/compiler/printer/utilities.ts +884 -0
- package/src/compiler/program-checker.ts +592 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1419 -0
- package/src/compiler/pseudo-bigint.ts +62 -0
- package/src/compiler/regexp-checker.ts +1142 -0
- package/src/compiler/relations.ts +5149 -0
- package/src/compiler/reparser.ts +1566 -0
- package/src/compiler/scanner.ts +2951 -0
- package/src/compiler/show-config.ts +239 -0
- package/src/compiler/side-state.ts +125 -0
- package/src/compiler/sourcemap.ts +366 -0
- package/src/compiler/spelling.ts +122 -0
- package/src/compiler/symbol-accessibility.ts +1071 -0
- package/src/compiler/symbol.ts +439 -0
- package/src/compiler/symlinks.ts +137 -0
- package/src/compiler/syntax-kind.ts +391 -0
- package/src/compiler/thread-entry.ts +191 -0
- package/src/compiler/timeline.ts +53 -0
- package/src/compiler/transformers/alias-references.ts +757 -0
- package/src/compiler/transformers/async-utilities.ts +335 -0
- package/src/compiler/transformers/async.ts +838 -0
- package/src/compiler/transformers/class-fields.ts +2967 -0
- package/src/compiler/transformers/class-utilities.ts +324 -0
- package/src/compiler/transformers/commonjs-module.ts +1621 -0
- package/src/compiler/transformers/const-enum-inliner.ts +50 -0
- package/src/compiler/transformers/declarations-diagnostics.ts +832 -0
- package/src/compiler/transformers/declarations-pseudo.ts +966 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1859 -0
- package/src/compiler/transformers/declarations-tracker.ts +269 -0
- package/src/compiler/transformers/declarations.ts +3120 -0
- package/src/compiler/transformers/decorator-metadata.ts +697 -0
- package/src/compiler/transformers/decorator-utilities.ts +283 -0
- package/src/compiler/transformers/destructuring.ts +708 -0
- package/src/compiler/transformers/downlevel.ts +50 -0
- package/src/compiler/transformers/emit-resolver.ts +258 -0
- package/src/compiler/transformers/es-decorators.ts +2682 -0
- package/src/compiler/transformers/exponentiation.ts +80 -0
- package/src/compiler/transformers/external-module-info.ts +412 -0
- package/src/compiler/transformers/for-await.ts +687 -0
- package/src/compiler/transformers/import-elision.ts +152 -0
- package/src/compiler/transformers/jsx-entities.ts +256 -0
- package/src/compiler/transformers/jsx.ts +824 -0
- package/src/compiler/transformers/legacy-decorators.ts +726 -0
- package/src/compiler/transformers/logical-assignment.ts +75 -0
- package/src/compiler/transformers/module-utilities.ts +42 -0
- package/src/compiler/transformers/module.ts +474 -0
- package/src/compiler/transformers/named-evaluation.ts +389 -0
- package/src/compiler/transformers/nullish-coalescing.ts +35 -0
- package/src/compiler/transformers/object-rest-spread.ts +577 -0
- package/src/compiler/transformers/optional-catch.ts +29 -0
- package/src/compiler/transformers/optional-chain.ts +246 -0
- package/src/compiler/transformers/reference-resolver.ts +1201 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +245 -0
- package/src/compiler/transformers/syntax-facts.ts +353 -0
- package/src/compiler/transformers/tagged-template.ts +167 -0
- package/src/compiler/transformers/transformer.ts +56 -0
- package/src/compiler/transformers/type-eraser.ts +520 -0
- package/src/compiler/transformers/type-serialization.ts +374 -0
- package/src/compiler/transformers/using.ts +613 -0
- package/src/compiler/transformers/utilities.ts +419 -0
- package/src/compiler/transformers/visitor-base.ts +1601 -0
- package/src/compiler/transformers/visitor-hooks.ts +252 -0
- package/src/compiler/tsc-build.ts +1418 -0
- package/src/compiler/tsc-cli.ts +666 -0
- package/src/compiler/tsc-compile.ts +437 -0
- package/src/compiler/tsc-watch.ts +854 -0
- package/src/compiler/tsconfig.ts +1574 -0
- package/src/compiler/type-printer.ts +110 -0
- package/src/compiler/types.ts +115 -0
- package/src/compiler/unicode-identifiers.ts +212 -0
- package/src/compiler/unicode-properties.ts +537 -0
- package/src/compiler/vfs-match.ts +597 -0
- package/src/compiler/xxh3.ts +650 -0
- package/src/library/ast.generated.ts +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,769 @@
|
|
|
1
|
+
// Declaration emit's queries answered by the checker, as tsgo's emit resolver: visibility and
|
|
2
|
+
// accessibility from resolved symbols, and type nodes built from types. JavaScript emit's
|
|
3
|
+
// queries, enum values and references between files are answered syntactically, except how
|
|
4
|
+
// decorator metadata serializes a type reference, which comes from the referenced type.
|
|
5
|
+
import {
|
|
6
|
+
BigIntLiteral,
|
|
7
|
+
BinaryExpression,
|
|
8
|
+
ElementAccessExpression,
|
|
9
|
+
type EntityName,
|
|
10
|
+
ExportAssignment,
|
|
11
|
+
ExportSpecifier,
|
|
12
|
+
ExpressionStatement,
|
|
13
|
+
type FileReference,
|
|
14
|
+
type Identifier,
|
|
15
|
+
type ImportDeclaration,
|
|
16
|
+
ImportEqualsDeclaration,
|
|
17
|
+
IndexSignatureDeclaration,
|
|
18
|
+
ModifierFlags,
|
|
19
|
+
type Node,
|
|
20
|
+
NodeFlags,
|
|
21
|
+
NodeVisitor,
|
|
22
|
+
PrefixUnaryExpression,
|
|
23
|
+
PropertyAccessExpression,
|
|
24
|
+
PropertyDeclaration,
|
|
25
|
+
SourceFile,
|
|
26
|
+
VariableDeclaration,
|
|
27
|
+
Token,
|
|
28
|
+
getBody,
|
|
29
|
+
getExpression,
|
|
30
|
+
getName,
|
|
31
|
+
getPostfixToken,
|
|
32
|
+
getQuestionToken,
|
|
33
|
+
getText,
|
|
34
|
+
getSymbol,
|
|
35
|
+
} from './ast.js';
|
|
36
|
+
import { nodeIsPresent } from './ast-utilities.js';
|
|
37
|
+
import {
|
|
38
|
+
JSDeclarationKind,
|
|
39
|
+
getAssignmentDeclarationKind,
|
|
40
|
+
getCombinedModifierFlags,
|
|
41
|
+
getCombinedNodeFlags,
|
|
42
|
+
getSourceFileOfNode,
|
|
43
|
+
isEntityNameExpression,
|
|
44
|
+
isParameterPropertyDeclaration,
|
|
45
|
+
isStringOrNumericLiteralLike,
|
|
46
|
+
} from './binder-utilities.js';
|
|
47
|
+
import type { Checker } from './checker.js';
|
|
48
|
+
import { getEffectiveDeclarationFlags } from './checker-declarations.js';
|
|
49
|
+
import { getBaseTypes, getDeclaredTypeOfSymbol, isConstructorType } from './checker-declared-types.js';
|
|
50
|
+
import { getResolvedSymbol } from './checker-expressions.js';
|
|
51
|
+
import { tryGetNameFromEntityNameExpression } from './checker-narrowing.js';
|
|
52
|
+
import {
|
|
53
|
+
getIndexInfosOfType,
|
|
54
|
+
getIndexSymbol,
|
|
55
|
+
getPropertiesOfType,
|
|
56
|
+
getPropertyOfType,
|
|
57
|
+
getSignaturesOfType,
|
|
58
|
+
} from './checker-members.js';
|
|
59
|
+
import {
|
|
60
|
+
getExternalModuleFileFromDeclaration,
|
|
61
|
+
getTargetOfExportSpecifier,
|
|
62
|
+
getTypeOnlyAliasDeclarationOfMeaning,
|
|
63
|
+
isTypeOnlyImportOrExportDeclaration,
|
|
64
|
+
} from './checker-modules.js';
|
|
65
|
+
import {
|
|
66
|
+
getIndexInfosOfIndexSymbol,
|
|
67
|
+
getSignatureFromDeclaration,
|
|
68
|
+
getSignaturesOfSymbol,
|
|
69
|
+
} from './checker-signatures.js';
|
|
70
|
+
import { getTypeOfSymbol, getWidenedType, isReadonlySymbol } from './checker-symbol-types.js';
|
|
71
|
+
import {
|
|
72
|
+
getExportsOfModule,
|
|
73
|
+
getFirstIdentifier,
|
|
74
|
+
getGlobalSymbol,
|
|
75
|
+
getGlobalValueSymbol,
|
|
76
|
+
getMergedSymbol,
|
|
77
|
+
getMembersOfSymbol,
|
|
78
|
+
getSymbolOfDeclaration,
|
|
79
|
+
resolveAlias,
|
|
80
|
+
resolveEntityName,
|
|
81
|
+
resolveName,
|
|
82
|
+
} from './checker-symbols.js';
|
|
83
|
+
import { isArrayType, isErrorType, isFreshLiteralType, isTupleType } from './checker-type-factory.js';
|
|
84
|
+
import { isTypeAssignableToKind } from './checker-type-operators.js';
|
|
85
|
+
import { type IndexInfo, type LiteralType, SignatureKind, type Type, TypeFlags } from './checker-types.js';
|
|
86
|
+
import { hasLateBindableName } from './checker-utilities.js';
|
|
87
|
+
import { NodeBuilder, isEntityNameVisible, isOptionalParameter } from './node-builder.js';
|
|
88
|
+
import {
|
|
89
|
+
getRegularTypeOfExpression,
|
|
90
|
+
newPseudoChecker,
|
|
91
|
+
requiresAddingImplicitUndefinedForDeclaration,
|
|
92
|
+
} from './node-builder-pseudo.js';
|
|
93
|
+
import { symbolToExpression } from './node-builder-names.js';
|
|
94
|
+
import { tryReuseExistingNode } from './node-builder-reuse.js';
|
|
95
|
+
import type { CompilerOptions, ModuleKind } from './options.js';
|
|
96
|
+
import type { EmitContext } from './printer/emit-context.js';
|
|
97
|
+
import { isTypeIdenticalTo } from './relations.js';
|
|
98
|
+
import { CheckFlags, type Symbol, SymbolFlags } from './symbol.js';
|
|
99
|
+
import {
|
|
100
|
+
beginDeclarationEmitVisibility,
|
|
101
|
+
isDeclarationVisible,
|
|
102
|
+
isSymbolAccessible,
|
|
103
|
+
markDeclarationVisible,
|
|
104
|
+
} from './symbol-accessibility.js';
|
|
105
|
+
import { SyntaxKind } from './syntax-kind.js';
|
|
106
|
+
import {
|
|
107
|
+
DeclarationEmitResolver,
|
|
108
|
+
NodeBuilderFlags,
|
|
109
|
+
NodeBuilderInternalFlags,
|
|
110
|
+
SymbolAccessibility,
|
|
111
|
+
type SymbolAccessibilityResult,
|
|
112
|
+
type SymbolTracker,
|
|
113
|
+
} from './transformers/declarations-resolver.js';
|
|
114
|
+
import type { SyntacticDeclarationEmitResolver } from './transformers/declarations-syntactic.js';
|
|
115
|
+
import { SyntacticEmitResolver } from './transformers/emit-resolver.js';
|
|
116
|
+
import type { Evaluation, ReferenceResolver } from './transformers/reference-resolver.js';
|
|
117
|
+
import { TypeReferenceSerializationKind } from './transformers/type-serialization.js';
|
|
118
|
+
import { TokenFlags } from './types.js';
|
|
119
|
+
|
|
120
|
+
const declarationEmitInternalFlags = NodeBuilderInternalFlags.AllowUnresolvedNames;
|
|
121
|
+
const aliasMeaning = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias;
|
|
122
|
+
|
|
123
|
+
export class CheckerDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
124
|
+
readonly checker: Checker;
|
|
125
|
+
/** Answers the queries that don't need types. */
|
|
126
|
+
private readonly syntactic: SyntacticDeclarationEmitResolver;
|
|
127
|
+
private readonly aliasesMarked: Set<SourceFile>;
|
|
128
|
+
|
|
129
|
+
constructor(checker: Checker, syntactic: SyntacticDeclarationEmitResolver) {
|
|
130
|
+
super();
|
|
131
|
+
this.checker = checker;
|
|
132
|
+
this.syntactic = syntactic;
|
|
133
|
+
this.aliasesMarked = new Set<SourceFile>();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// JavaScript emit
|
|
137
|
+
|
|
138
|
+
markLinkedReferences(file: SourceFile): boolean {
|
|
139
|
+
return this.syntactic.markLinkedReferences(file);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
isReferencedAliasDeclaration(node: Node): boolean {
|
|
143
|
+
return this.syntactic.isReferencedAliasDeclaration(node);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
isValueAliasDeclaration(node: Node): boolean {
|
|
147
|
+
return this.syntactic.isValueAliasDeclaration(node);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
isTopLevelValueImportEqualsWithEntityName(node: Node): boolean {
|
|
151
|
+
return this.syntactic.isTopLevelValueImportEqualsWithEntityName(node);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getTypeReferenceSerializationKind(typeName: Node, location: Node | undefined): TypeReferenceSerializationKind {
|
|
155
|
+
return getTypeReferenceSerializationKind(this.checker, typeName, location);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
getReferencedExportContainer(node: Identifier, prefixLocals: boolean): Node | undefined {
|
|
159
|
+
return this.syntactic.getReferencedExportContainer(node, prefixLocals);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getReferencedImportDeclaration(node: Identifier): Node | undefined {
|
|
163
|
+
return this.syntactic.getReferencedImportDeclaration(node);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
getReferencedValueDeclaration(node: Identifier): Node | undefined {
|
|
167
|
+
return this.syntactic.getReferencedValueDeclaration(node);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getReferencedValueDeclarations(node: Identifier): Node[] | undefined {
|
|
171
|
+
return this.syntactic.getReferencedValueDeclarations(node);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getEnumMemberValue(member: Node): Evaluation {
|
|
175
|
+
return this.syntactic.getEnumMemberValue(member);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
setReferencedImportDeclaration(name: Identifier, declaration: Node): void {
|
|
179
|
+
this.syntactic.setReferencedImportDeclaration(name, declaration);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
getJsxFactoryEntity(file: SourceFile): EntityName | undefined {
|
|
183
|
+
return this.syntactic.getJsxFactoryEntity(file);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getJsxFragmentFactoryEntity(file: SourceFile): EntityName | undefined {
|
|
187
|
+
return this.syntactic.getJsxFragmentFactoryEntity(file);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
getConstantValue(node: Node): Evaluation {
|
|
191
|
+
return this.syntactic.getConstantValue(node);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Visibility
|
|
195
|
+
|
|
196
|
+
precalculateDeclarationEmitVisibility(file: SourceFile): boolean {
|
|
197
|
+
beginDeclarationEmitVisibility(this.checker, file);
|
|
198
|
+
if (this.aliasesMarked.has(file)) return false;
|
|
199
|
+
this.aliasesMarked.add(file);
|
|
200
|
+
file.forEachChild(new AliasMarker(this));
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Marks the declarations an export names visible, following `import x = a.b` chains. */
|
|
205
|
+
markLinkedAliases(node: Node): boolean {
|
|
206
|
+
const c = this.checker;
|
|
207
|
+
const parent = node.parent;
|
|
208
|
+
let exportSymbol: Symbol | undefined = undefined;
|
|
209
|
+
if (
|
|
210
|
+
node.kind !== SyntaxKind.StringLiteral &&
|
|
211
|
+
parent !== undefined &&
|
|
212
|
+
(parent.kind === SyntaxKind.ExportAssignment || isCommonJSModuleExports(parent))
|
|
213
|
+
)
|
|
214
|
+
exportSymbol = resolveName(c, node, getText(node), aliasMeaning, undefined, false, false);
|
|
215
|
+
else if (parent !== undefined && parent.kind === SyntaxKind.ExportSpecifier)
|
|
216
|
+
exportSymbol = getTargetOfExportSpecifier(c, parent, aliasMeaning, false);
|
|
217
|
+
const visited = new Set<Symbol>();
|
|
218
|
+
while (exportSymbol !== undefined && !visited.has(exportSymbol)) {
|
|
219
|
+
visited.add(exportSymbol);
|
|
220
|
+
let next: Symbol | undefined = undefined;
|
|
221
|
+
for (const declaration of exportSymbol.declarations) {
|
|
222
|
+
markDeclarationVisible(c, declaration);
|
|
223
|
+
if (
|
|
224
|
+
declaration instanceof ImportEqualsDeclaration &&
|
|
225
|
+
declaration.moduleReference.kind !== SyntaxKind.ExternalModuleReference
|
|
226
|
+
) {
|
|
227
|
+
const first = getFirstIdentifier(declaration.moduleReference);
|
|
228
|
+
next = resolveName(c, declaration, getText(first), aliasMeaning, undefined, false, false);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exportSymbol = next;
|
|
232
|
+
}
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
isDeclarationVisible(node: Node): boolean {
|
|
237
|
+
return isDeclarationVisible(this.checker, node);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
isEntityNameVisible(entityName: Node, enclosingDeclaration: Node): SymbolAccessibilityResult {
|
|
241
|
+
return isEntityNameVisible(this.checker, entityName, enclosingDeclaration, true);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
isSymbolAccessible(
|
|
245
|
+
symbol: Symbol,
|
|
246
|
+
enclosingDeclaration: Node,
|
|
247
|
+
meaning: SymbolFlags,
|
|
248
|
+
shouldComputeAliasesToMakeVisible: boolean,
|
|
249
|
+
): SymbolAccessibilityResult {
|
|
250
|
+
return isSymbolAccessible(this.checker, symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
isNameResolvable(location: Node, name: string): boolean {
|
|
254
|
+
const meaning = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace;
|
|
255
|
+
return resolveName(this.checker, location, name, meaning, undefined, false, false) !== undefined;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
isImportRequiredByAugmentation(node: ImportDeclaration): boolean {
|
|
259
|
+
if ((node.flags & NodeFlags.Synthesized) !== 0) return false;
|
|
260
|
+
const c = this.checker;
|
|
261
|
+
const file = getSourceFileOfNode(node);
|
|
262
|
+
if (file.symbol === undefined) return false;
|
|
263
|
+
const importTarget = getExternalModuleFileFromDeclaration(c, node);
|
|
264
|
+
if (importTarget === undefined || importTarget === file) return false;
|
|
265
|
+
for (const s of getExportsOfModule(c, file.symbol).values()) {
|
|
266
|
+
const merged = getMergedSymbol(c, s);
|
|
267
|
+
if (merged === s) continue;
|
|
268
|
+
for (const d of merged.declarations) if (getSourceFileOfNode(d) === importTarget) return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Declarations
|
|
274
|
+
|
|
275
|
+
getEffectiveDeclarationFlags(node: Node, flags: ModifierFlags): ModifierFlags {
|
|
276
|
+
return getEffectiveDeclarationFlags(node, flags);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
isImplementationOfOverload(node: Node): boolean {
|
|
280
|
+
if ((node.flags & NodeFlags.Synthesized) !== 0 || !nodeIsPresent(getBody(node))) return false;
|
|
281
|
+
// Accessors have up to two signatures but never overloads.
|
|
282
|
+
if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) return false;
|
|
283
|
+
const c = this.checker;
|
|
284
|
+
const signatures = getSignaturesOfSymbol(c, getSymbolOfDeclaration(c, node));
|
|
285
|
+
if (signatures.length > 1) return true;
|
|
286
|
+
if (signatures.length === 1) {
|
|
287
|
+
const declaration = signatures[0].declaration;
|
|
288
|
+
if (declaration !== node && declaration !== undefined && (declaration.flags & NodeFlags.JSDoc) === 0) return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
isLateBound(node: Node): boolean {
|
|
294
|
+
if ((node.flags & NodeFlags.Synthesized) !== 0) return false;
|
|
295
|
+
const symbol = getSymbolOfDeclaration(this.checker, node);
|
|
296
|
+
return symbol !== undefined && (symbol.checkFlags & CheckFlags.Late) !== 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean {
|
|
300
|
+
if (!(node instanceof PropertyAccessExpression) || node.name.kind !== SyntaxKind.Identifier) return false;
|
|
301
|
+
const c = this.checker;
|
|
302
|
+
const expression = node.expression;
|
|
303
|
+
if (expression.kind === SyntaxKind.Identifier) {
|
|
304
|
+
if (getText(expression) !== 'Symbol') return false;
|
|
305
|
+
// `Symbol` doesn't resolve or is the global `Symbol`.
|
|
306
|
+
return (
|
|
307
|
+
getResolvedSymbol(c, expression) ===
|
|
308
|
+
getGlobalSymbol(c, 'Symbol', SymbolFlags.Value | SymbolFlags.ExportValue, undefined)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
if (!(expression instanceof PropertyAccessExpression)) return false;
|
|
312
|
+
const inner = expression.expression;
|
|
313
|
+
if (
|
|
314
|
+
inner.kind !== SyntaxKind.Identifier ||
|
|
315
|
+
getText(inner) !== 'globalThis' ||
|
|
316
|
+
getText(expression.name) !== 'Symbol'
|
|
317
|
+
)
|
|
318
|
+
return false;
|
|
319
|
+
return getResolvedSymbol(c, inner) === c.globalThisSymbol;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
isLiteralConstDeclaration(node: Node): boolean {
|
|
323
|
+
if ((node.flags & NodeFlags.Synthesized) !== 0) return false;
|
|
324
|
+
const isConstVariable =
|
|
325
|
+
node instanceof VariableDeclaration && (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === NodeFlags.Const;
|
|
326
|
+
if (!isDeclarationReadonly(node) && !isConstVariable) return false;
|
|
327
|
+
const c = this.checker;
|
|
328
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
329
|
+
return symbol !== undefined && isFreshLiteralType(getTypeOfSymbol(c, symbol));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
isOptionalParameter(node: Node): boolean {
|
|
333
|
+
return isOptionalParameter(this.checker, node);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
requiresAddingImplicitUndefined(node: Node, enclosingDeclaration: Node | undefined): boolean {
|
|
337
|
+
return requiresAddingImplicitUndefinedForDeclaration(this.checker, node, undefined, enclosingDeclaration);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
isExpandoFunctionDeclaration(node: Node): boolean {
|
|
341
|
+
if ((node.flags & NodeFlags.Synthesized) !== 0) return false;
|
|
342
|
+
for (const p of this.getPropertiesOfContainerFunction(node))
|
|
343
|
+
if (p.valueDeclaration !== undefined && p.valueDeclaration.kind === SyntaxKind.BinaryExpression) return true;
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
getExpandoPropertyDeclarations(node: Node): Node[] {
|
|
348
|
+
const result: Node[] = [];
|
|
349
|
+
for (const p of this.getPropertiesOfContainerFunction(node))
|
|
350
|
+
if (p.valueDeclaration !== undefined && p.valueDeclaration.kind === SyntaxKind.BinaryExpression)
|
|
351
|
+
result.push(p.valueDeclaration);
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private getPropertiesOfContainerFunction(node: Node): Symbol[] {
|
|
356
|
+
const c = this.checker;
|
|
357
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
358
|
+
if (symbol === undefined) return [];
|
|
359
|
+
return getPropertiesOfType(c, getTypeOfSymbol(c, symbol));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
getResolutionModeOverride(node: Node): ModuleKind | undefined {
|
|
363
|
+
return this.syntactic.getResolutionModeOverride(node);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
getSourceFileFromReference(file: SourceFile, reference: FileReference): SourceFile | undefined {
|
|
367
|
+
return this.syntactic.getSourceFileFromReference(file, reference);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// JavaScript
|
|
371
|
+
|
|
372
|
+
getReferencedMemberValueDeclaration(node: Node): Node | undefined {
|
|
373
|
+
return this.syntactic.getReferencedMemberValueDeclaration(node);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
isThisPropertyAssignmentDeclarationRedundant(node: Node): boolean {
|
|
377
|
+
const c = this.checker;
|
|
378
|
+
const s = getSymbolOfDeclaration(c, node);
|
|
379
|
+
if (s === undefined || s.parent === undefined) return false;
|
|
380
|
+
const parentType = getDeclaredTypeOfSymbol(c, s.parent);
|
|
381
|
+
for (const base of getBaseTypes(c, parentType)) {
|
|
382
|
+
const baseProp = getPropertyOfType(c, base, s.name);
|
|
383
|
+
if (baseProp === undefined) continue;
|
|
384
|
+
if ((baseProp.flags & (SymbolFlags.Accessor | SymbolFlags.Method | SymbolFlags.Function)) !== 0) return true;
|
|
385
|
+
if (
|
|
386
|
+
isReadonlySymbol(c, baseProp) === isReadonlySymbol(c, s) &&
|
|
387
|
+
(s.flags & SymbolFlags.Optional) === (baseProp.flags & SymbolFlags.Optional) &&
|
|
388
|
+
isTypeIdenticalTo(c, getTypeOfSymbol(c, s), getTypeOfSymbol(c, baseProp))
|
|
389
|
+
)
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
getElementAccessExpressionName(node: Node): string {
|
|
396
|
+
if (!(node instanceof ElementAccessExpression) || (node.flags & NodeFlags.Synthesized) !== 0) return '';
|
|
397
|
+
const argument = node.argumentExpression;
|
|
398
|
+
if (isStringOrNumericLiteralLike(argument)) return getText(argument);
|
|
399
|
+
if (isEntityNameExpression(argument, false))
|
|
400
|
+
return tryGetNameFromEntityNameExpression(this.checker, argument) ?? '';
|
|
401
|
+
return '';
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// Type nodes
|
|
405
|
+
|
|
406
|
+
private builder(
|
|
407
|
+
context: EmitContext,
|
|
408
|
+
enclosingDeclaration: Node | undefined,
|
|
409
|
+
flags: NodeBuilderFlags,
|
|
410
|
+
tracker: SymbolTracker,
|
|
411
|
+
): NodeBuilder {
|
|
412
|
+
const b = new NodeBuilder(
|
|
413
|
+
this.checker,
|
|
414
|
+
enclosingDeclaration,
|
|
415
|
+
flags,
|
|
416
|
+
declarationEmitInternalFlags,
|
|
417
|
+
tracker,
|
|
418
|
+
context,
|
|
419
|
+
);
|
|
420
|
+
b.pseudo = newPseudoChecker(this.checker);
|
|
421
|
+
b.declarationOrder = true;
|
|
422
|
+
return b;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
createTypeOfDeclaration(
|
|
426
|
+
context: EmitContext,
|
|
427
|
+
declaration: Node,
|
|
428
|
+
enclosingDeclaration: Node,
|
|
429
|
+
flags: NodeBuilderFlags,
|
|
430
|
+
tracker: SymbolTracker,
|
|
431
|
+
): Node | undefined {
|
|
432
|
+
const original = context.parseNode(declaration);
|
|
433
|
+
if (original === undefined) return undefined;
|
|
434
|
+
const b = this.builder(context, enclosingDeclaration, flags | NodeBuilderFlags.MultilineObjectLiterals, tracker);
|
|
435
|
+
const symbol = getSymbolOfDeclaration(this.checker, declaration);
|
|
436
|
+
return b.finish(b.serializeTypeForDeclaration(declaration, undefined, symbol, true));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
createReturnTypeOfSignatureDeclaration(
|
|
440
|
+
context: EmitContext,
|
|
441
|
+
signature: Node,
|
|
442
|
+
enclosingDeclaration: Node,
|
|
443
|
+
flags: NodeBuilderFlags,
|
|
444
|
+
tracker: SymbolTracker,
|
|
445
|
+
): Node | undefined {
|
|
446
|
+
const original = context.parseNode(signature);
|
|
447
|
+
if (original === undefined) return undefined;
|
|
448
|
+
const b = this.builder(context, enclosingDeclaration, flags, tracker);
|
|
449
|
+
const sig = getSignatureFromDeclaration(this.checker, original);
|
|
450
|
+
const cleanup = b.enterSignatureScope(sig);
|
|
451
|
+
const result = b.serializeReturnTypeForSignatureEx(sig, true);
|
|
452
|
+
cleanup();
|
|
453
|
+
return b.finish(result);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
createTypeParametersOfSignatureDeclaration(
|
|
457
|
+
context: EmitContext,
|
|
458
|
+
signature: Node,
|
|
459
|
+
enclosingDeclaration: Node,
|
|
460
|
+
flags: NodeBuilderFlags,
|
|
461
|
+
tracker: SymbolTracker,
|
|
462
|
+
): Node[] | undefined {
|
|
463
|
+
const original = context.parseNode(signature);
|
|
464
|
+
if (original === undefined) return undefined;
|
|
465
|
+
const symbol = getSymbolOfDeclaration(this.checker, original);
|
|
466
|
+
if (symbol === undefined) return undefined;
|
|
467
|
+
const b = this.builder(context, enclosingDeclaration, flags, tracker);
|
|
468
|
+
const result = b.finish(b.typeParametersToTypeParameterDeclarations(symbol));
|
|
469
|
+
return result !== undefined && result.length > 0 ? result : undefined;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
createLiteralConstValue(context: EmitContext, nodeIn: Node, tracker: SymbolTracker): Node | undefined {
|
|
473
|
+
const c = this.checker;
|
|
474
|
+
const node = context.parseNode(nodeIn) ?? nodeIn;
|
|
475
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
476
|
+
if (symbol === undefined) return undefined;
|
|
477
|
+
const t = getTypeOfSymbol(c, symbol);
|
|
478
|
+
const factory = context.factory;
|
|
479
|
+
if ((t.flags & TypeFlags.EnumLike) !== 0 && t.symbol !== undefined) {
|
|
480
|
+
const b = this.builder(context, node, NodeBuilderFlags.None, tracker);
|
|
481
|
+
return b.finish(symbolToExpression(b, t.symbol, SymbolFlags.Value));
|
|
482
|
+
}
|
|
483
|
+
if (t === c.trueType) return factory.createKeywordExpression(SyntaxKind.TrueKeyword);
|
|
484
|
+
if (t === c.falseType) return factory.createKeywordExpression(SyntaxKind.FalseKeyword);
|
|
485
|
+
if ((t.flags & TypeFlags.Literal) === 0) return undefined;
|
|
486
|
+
return literalValueToExpression(context, t as LiteralType);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
createTypeOfExpression(
|
|
490
|
+
context: EmitContext,
|
|
491
|
+
expression: Node,
|
|
492
|
+
enclosingDeclaration: Node,
|
|
493
|
+
flags: NodeBuilderFlags,
|
|
494
|
+
tracker: SymbolTracker,
|
|
495
|
+
): Node | undefined {
|
|
496
|
+
const original = context.parseNode(expression);
|
|
497
|
+
if (original === undefined) return undefined;
|
|
498
|
+
const b = this.builder(context, enclosingDeclaration, flags | NodeBuilderFlags.MultilineObjectLiterals, tracker);
|
|
499
|
+
return b.finish(b.typeToTypeNode(getWidenedType(this.checker, getRegularTypeOfExpression(this.checker, original))));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
createLateBoundIndexSignatures(
|
|
503
|
+
context: EmitContext,
|
|
504
|
+
containerIn: Node,
|
|
505
|
+
enclosingDeclaration: Node,
|
|
506
|
+
flags: NodeBuilderFlags,
|
|
507
|
+
tracker: SymbolTracker,
|
|
508
|
+
): Node[] {
|
|
509
|
+
const c = this.checker;
|
|
510
|
+
const container = context.parseNode(containerIn) ?? containerIn;
|
|
511
|
+
// The declaration's own symbol: members merged in from other files aren't written here.
|
|
512
|
+
const sym = getSymbol(container);
|
|
513
|
+
if (sym === undefined) return [];
|
|
514
|
+
const staticInfos = getIndexInfosOfType(c, getTypeOfSymbol(c, sym));
|
|
515
|
+
const instanceIndexSymbol = getIndexSymbol(c, sym);
|
|
516
|
+
let instanceInfos: IndexInfo[] = [];
|
|
517
|
+
if (instanceIndexSymbol !== undefined) {
|
|
518
|
+
const siblingSymbols = [...getMembersOfSymbol(c, sym).values()];
|
|
519
|
+
instanceInfos = getIndexInfosOfIndexSymbol(c, instanceIndexSymbol, siblingSymbols);
|
|
520
|
+
}
|
|
521
|
+
const factory = context.factory;
|
|
522
|
+
const result: Node[] = [];
|
|
523
|
+
const lists = [staticInfos, instanceInfos];
|
|
524
|
+
for (let i = 0; i < lists.length; i++) {
|
|
525
|
+
const isStatic = i === 0;
|
|
526
|
+
for (const info of lists[i]!) {
|
|
527
|
+
if (info.declaration !== undefined) continue;
|
|
528
|
+
// Inherited, but looks late-bound as it has no declarations.
|
|
529
|
+
if (info === c.anyBaseTypeIndexInfo) continue;
|
|
530
|
+
if (info.components.length > 0) {
|
|
531
|
+
if (areComponentsSerializable(c, info.components, enclosingDeclaration)) {
|
|
532
|
+
for (const component of info.components) {
|
|
533
|
+
// Late-bound members of the index signature are kept as members.
|
|
534
|
+
if (hasLateBindableName(c, component)) continue;
|
|
535
|
+
const name = getName(component)!;
|
|
536
|
+
const first = getFirstIdentifier(getExpression(name)!);
|
|
537
|
+
const resolved = resolveName(
|
|
538
|
+
c,
|
|
539
|
+
first,
|
|
540
|
+
getText(first),
|
|
541
|
+
SymbolFlags.Value | SymbolFlags.ExportValue,
|
|
542
|
+
undefined,
|
|
543
|
+
true,
|
|
544
|
+
false,
|
|
545
|
+
);
|
|
546
|
+
if (resolved !== undefined) tracker.trackSymbol(resolved, enclosingDeclaration, SymbolFlags.Value);
|
|
547
|
+
const modifiers: Node[] = [];
|
|
548
|
+
if (isStatic) modifiers.push(factory.createToken(SyntaxKind.StaticKeyword));
|
|
549
|
+
if (info.isReadonly) modifiers.push(factory.createToken(SyntaxKind.ReadonlyKeyword));
|
|
550
|
+
const componentSymbol = getSymbolOfDeclaration(c, component);
|
|
551
|
+
const b = this.builder(context, enclosingDeclaration, flags, tracker);
|
|
552
|
+
const typeNode =
|
|
553
|
+
componentSymbol === undefined
|
|
554
|
+
? undefined
|
|
555
|
+
: b.finish(b.typeToTypeNode(getTypeOfSymbol(c, componentSymbol)));
|
|
556
|
+
result.push(
|
|
557
|
+
factory.created(
|
|
558
|
+
new PropertyDeclaration(
|
|
559
|
+
modifiers.length > 0 ? factory.createModifierList(modifiers) : undefined,
|
|
560
|
+
name,
|
|
561
|
+
getQuestionTokenOf(component),
|
|
562
|
+
typeNode,
|
|
563
|
+
undefined,
|
|
564
|
+
),
|
|
565
|
+
),
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const b = this.builder(context, enclosingDeclaration, flags, tracker);
|
|
572
|
+
let node = b.finish(b.indexInfoToIndexSignatureDeclaration(info, undefined));
|
|
573
|
+
if (node !== undefined && isStatic) node = addStaticModifier(context, node);
|
|
574
|
+
if (node !== undefined) result.push(node);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return result;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
tryJSTypeNodeToTypeNode(
|
|
581
|
+
context: EmitContext,
|
|
582
|
+
typeNode: Node,
|
|
583
|
+
enclosingDeclaration: Node,
|
|
584
|
+
flags: NodeBuilderFlags,
|
|
585
|
+
tracker: SymbolTracker,
|
|
586
|
+
): Node | undefined {
|
|
587
|
+
const original = context.parseNode(typeNode) ?? typeNode;
|
|
588
|
+
const b = this.builder(context, enclosingDeclaration, flags, tracker);
|
|
589
|
+
return b.finish(tryReuseExistingNode(b, original));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Visits every node, marking the declarations exports name visible. */
|
|
594
|
+
/** JavaScript emit's resolver, with decorator metadata's type references serialized from the checker's types. */
|
|
595
|
+
export class CheckerEmitResolver extends SyntacticEmitResolver {
|
|
596
|
+
constructor(
|
|
597
|
+
options: CompilerOptions,
|
|
598
|
+
referenceResolver: ReferenceResolver,
|
|
599
|
+
readonly checker: Checker,
|
|
600
|
+
) {
|
|
601
|
+
super(options, referenceResolver);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
getTypeReferenceSerializationKind(typeName: Node, location: Node | undefined): TypeReferenceSerializationKind {
|
|
605
|
+
return getTypeReferenceSerializationKind(this.checker, typeName, location);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* How decorator metadata serializes a reference to `typeName` from `location`, as tsgo's
|
|
611
|
+
* `GetTypeReferenceSerializationKind`: the name of a class or another value with construct
|
|
612
|
+
* signatures that is reachable at runtime, else the kind of the declared type it names.
|
|
613
|
+
*/
|
|
614
|
+
export function getTypeReferenceSerializationKind(
|
|
615
|
+
c: Checker,
|
|
616
|
+
typeName: Node,
|
|
617
|
+
location: Node | undefined,
|
|
618
|
+
): TypeReferenceSerializationKind {
|
|
619
|
+
if (location === undefined) return TypeReferenceSerializationKind.Unknown;
|
|
620
|
+
// The value must be reachable at runtime.
|
|
621
|
+
let isTypeOnly = false;
|
|
622
|
+
if (typeName.kind === SyntaxKind.QualifiedName) {
|
|
623
|
+
const root = resolveEntityName(c, getFirstIdentifier(typeName), SymbolFlags.Value, true, true, location);
|
|
624
|
+
if (root !== undefined && root.declarations.length > 0)
|
|
625
|
+
isTypeOnly = root.declarations.every(isTypeOnlyImportOrExportDeclaration);
|
|
626
|
+
}
|
|
627
|
+
const valueSymbol = resolveEntityName(c, typeName, SymbolFlags.Value, true, true, location);
|
|
628
|
+
let resolvedValue = valueSymbol;
|
|
629
|
+
if (valueSymbol !== undefined && (valueSymbol.flags & SymbolFlags.Alias) !== 0)
|
|
630
|
+
resolvedValue = resolveAlias(c, valueSymbol);
|
|
631
|
+
if (
|
|
632
|
+
valueSymbol !== undefined &&
|
|
633
|
+
getTypeOnlyAliasDeclarationOfMeaning(c, valueSymbol, SymbolFlags.Value) !== undefined
|
|
634
|
+
)
|
|
635
|
+
isTypeOnly = true;
|
|
636
|
+
// The type gives a more specific constructor, and tells whether the value is reachable when it doesn't resolve.
|
|
637
|
+
const typeSymbol = resolveEntityName(c, typeName, SymbolFlags.Type, true, true, location);
|
|
638
|
+
let resolvedType = typeSymbol;
|
|
639
|
+
if (typeSymbol !== undefined && (typeSymbol.flags & SymbolFlags.Alias) !== 0)
|
|
640
|
+
resolvedType = resolveAlias(c, typeSymbol);
|
|
641
|
+
if (typeSymbol !== undefined && getTypeOnlyAliasDeclarationOfMeaning(c, typeSymbol, SymbolFlags.Type) !== undefined)
|
|
642
|
+
isTypeOnly = true;
|
|
643
|
+
if (resolvedValue !== undefined && resolvedValue === resolvedType) {
|
|
644
|
+
const promise = getGlobalValueSymbol(c, 'Promise', false);
|
|
645
|
+
if (promise !== undefined && resolvedValue === promise) return TypeReferenceSerializationKind.Promise;
|
|
646
|
+
if (isConstructorType(c, getTypeOfSymbol(c, resolvedValue)))
|
|
647
|
+
return isTypeOnly
|
|
648
|
+
? TypeReferenceSerializationKind.TypeWithCallSignature
|
|
649
|
+
: TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
|
|
650
|
+
}
|
|
651
|
+
if (resolvedType === undefined)
|
|
652
|
+
return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown;
|
|
653
|
+
const t = getDeclaredTypeOfSymbol(c, resolvedType);
|
|
654
|
+
if (isErrorType(c, t))
|
|
655
|
+
return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown;
|
|
656
|
+
if ((t.flags & TypeFlags.AnyOrUnknown) !== 0) return TypeReferenceSerializationKind.ObjectType;
|
|
657
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.Void | TypeFlags.Nullable | TypeFlags.Never))
|
|
658
|
+
return TypeReferenceSerializationKind.VoidNullableOrNeverType;
|
|
659
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.BooleanLike)) return TypeReferenceSerializationKind.BooleanType;
|
|
660
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.NumberLike)) return TypeReferenceSerializationKind.NumberLikeType;
|
|
661
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.BigIntLike)) return TypeReferenceSerializationKind.BigIntLikeType;
|
|
662
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.StringLike)) return TypeReferenceSerializationKind.StringLikeType;
|
|
663
|
+
if (isTupleType(t)) return TypeReferenceSerializationKind.ArrayLikeType;
|
|
664
|
+
if (isTypeAssignableToKind(c, t, TypeFlags.ESSymbolLike)) return TypeReferenceSerializationKind.ESSymbolType;
|
|
665
|
+
if (isFunctionType(c, t)) return TypeReferenceSerializationKind.TypeWithCallSignature;
|
|
666
|
+
if (isArrayType(c, t)) return TypeReferenceSerializationKind.ArrayLikeType;
|
|
667
|
+
return TypeReferenceSerializationKind.ObjectType;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function isFunctionType(c: Checker, t: Type): boolean {
|
|
671
|
+
return (t.flags & TypeFlags.Object) !== 0 && getSignaturesOfType(c, t, SignatureKind.Call).length > 0;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
class AliasMarker extends NodeVisitor {
|
|
675
|
+
readonly resolver: CheckerDeclarationEmitResolver;
|
|
676
|
+
|
|
677
|
+
constructor(resolver: CheckerDeclarationEmitResolver) {
|
|
678
|
+
super();
|
|
679
|
+
this.resolver = resolver;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
visitNode(node: Node): boolean {
|
|
683
|
+
if (node instanceof BinaryExpression) {
|
|
684
|
+
if (isCommonJSModuleExports(node) && node.right.kind === SyntaxKind.Identifier)
|
|
685
|
+
this.resolver.markLinkedAliases(node.right);
|
|
686
|
+
} else if (node instanceof ExportAssignment) {
|
|
687
|
+
if (node.expression.kind === SyntaxKind.Identifier) this.resolver.markLinkedAliases(node.expression);
|
|
688
|
+
} else if (node instanceof ExportSpecifier) this.resolver.markLinkedAliases(node.propertyName ?? node.name);
|
|
689
|
+
return node.forEachChild(this);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** `module.exports = x` or `exports.y = x` at the top of a CommonJS module. */
|
|
694
|
+
function isCommonJSModuleExports(node: Node): boolean {
|
|
695
|
+
if (!(node instanceof BinaryExpression)) return false;
|
|
696
|
+
const statement = node.parent;
|
|
697
|
+
if (!(statement instanceof ExpressionStatement)) return false;
|
|
698
|
+
const file = statement.parent;
|
|
699
|
+
if (!(file instanceof SourceFile) || file.commonJSModuleIndicator === undefined) return false;
|
|
700
|
+
const kind = getAssignmentDeclarationKind(node);
|
|
701
|
+
return kind === JSDeclarationKind.ModuleExports || kind === JSDeclarationKind.ExportsProperty;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function isDeclarationReadonly(node: Node): boolean {
|
|
705
|
+
return (
|
|
706
|
+
(getCombinedModifierFlags(node) & ModifierFlags.Readonly) !== 0 &&
|
|
707
|
+
!(node.parent !== undefined && isParameterPropertyDeclaration(node, node.parent))
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function isEntityNameExpressionNode(node: Node): boolean {
|
|
712
|
+
if (node.kind === SyntaxKind.Identifier) return true;
|
|
713
|
+
return (
|
|
714
|
+
node instanceof PropertyAccessExpression &&
|
|
715
|
+
node.name.kind === SyntaxKind.Identifier &&
|
|
716
|
+
isEntityNameExpressionNode(node.expression)
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function areComponentsSerializable(c: Checker, components: readonly Node[], enclosingDeclaration: Node): boolean {
|
|
721
|
+
for (const component of components) {
|
|
722
|
+
const name = getName(component);
|
|
723
|
+
if (
|
|
724
|
+
name === undefined ||
|
|
725
|
+
name.kind !== SyntaxKind.ComputedPropertyName ||
|
|
726
|
+
!isEntityNameExpressionNode(getExpression(name)!) ||
|
|
727
|
+
isEntityNameVisible(c, getExpression(name)!, enclosingDeclaration, false).accessibility !==
|
|
728
|
+
SymbolAccessibility.Accessible
|
|
729
|
+
)
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function getQuestionTokenOf(node: Node): Token | undefined {
|
|
736
|
+
const token = getQuestionToken(node) ?? getPostfixToken(node);
|
|
737
|
+
return token instanceof Token && token.kind === SyntaxKind.QuestionToken ? token : undefined;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** The initializer for a literal type's value: a string, number or bigint literal. */
|
|
741
|
+
function literalValueToExpression(context: EmitContext, t: LiteralType): Node | undefined {
|
|
742
|
+
const factory = context.factory;
|
|
743
|
+
if ((t.flags & TypeFlags.StringLiteral) !== 0) return factory.createStringLiteral(t.stringValue, TokenFlags.None);
|
|
744
|
+
if ((t.flags & TypeFlags.NumberLiteral) !== 0) {
|
|
745
|
+
const value = t.numberValue;
|
|
746
|
+
if (value === Infinity) return factory.createIdentifier('Infinity');
|
|
747
|
+
if (value === -Infinity)
|
|
748
|
+
return factory.created(new PrefixUnaryExpression(SyntaxKind.MinusToken, factory.createIdentifier('Infinity')));
|
|
749
|
+
if (Number.isNaN(value)) return factory.createIdentifier('NaN');
|
|
750
|
+
if (value < 0)
|
|
751
|
+
return factory.created(
|
|
752
|
+
new PrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(String(-value))),
|
|
753
|
+
);
|
|
754
|
+
return factory.createNumericLiteral(String(value));
|
|
755
|
+
}
|
|
756
|
+
if ((t.flags & TypeFlags.BigIntLiteral) !== 0)
|
|
757
|
+
return factory.created(new BigIntLiteral(t.stringValue + 'n', TokenFlags.None));
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function addStaticModifier(context: EmitContext, node: Node): Node {
|
|
762
|
+
if (!(node instanceof IndexSignatureDeclaration)) return node;
|
|
763
|
+
const factory = context.factory;
|
|
764
|
+
const modifiers: Node[] = [factory.createToken(SyntaxKind.StaticKeyword)];
|
|
765
|
+
if (node.modifiers !== undefined) for (const m of node.modifiers.nodes) modifiers.push(m);
|
|
766
|
+
return factory.created(
|
|
767
|
+
new IndexSignatureDeclaration(factory.createModifierList(modifiers), node.parameters, node.type),
|
|
768
|
+
);
|
|
769
|
+
}
|