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,577 @@
|
|
|
1
|
+
// Lowers object spread to `Object.assign` and object rest elements to `__rest`, for targets
|
|
2
|
+
// before ES2018.
|
|
3
|
+
import {
|
|
4
|
+
ArrowFunction,
|
|
5
|
+
BinaryExpression,
|
|
6
|
+
BindingPattern,
|
|
7
|
+
Block,
|
|
8
|
+
CatchClause,
|
|
9
|
+
ConstructorDeclaration,
|
|
10
|
+
ForInOrOfStatement,
|
|
11
|
+
FunctionDeclaration,
|
|
12
|
+
FunctionExpression,
|
|
13
|
+
GetAccessorDeclaration,
|
|
14
|
+
Identifier,
|
|
15
|
+
MethodDeclaration,
|
|
16
|
+
ModifierFlags,
|
|
17
|
+
type Node,
|
|
18
|
+
NodeFlags,
|
|
19
|
+
NodeList,
|
|
20
|
+
ObjectLiteralExpression,
|
|
21
|
+
ParameterDeclaration,
|
|
22
|
+
PropertyAssignment,
|
|
23
|
+
SourceFile,
|
|
24
|
+
SetAccessorDeclaration,
|
|
25
|
+
SpreadAssignment,
|
|
26
|
+
SyntaxList,
|
|
27
|
+
VariableDeclaration,
|
|
28
|
+
VariableStatement,
|
|
29
|
+
getBody,
|
|
30
|
+
getParameters,
|
|
31
|
+
} from '../ast.js';
|
|
32
|
+
import { isDestructuringAssignment, skipParentheses } from '../binder-utilities.js';
|
|
33
|
+
import type { EmitContext } from '../printer/emit-context.js';
|
|
34
|
+
import { EmitFlags } from '../printer/emit-flags.js';
|
|
35
|
+
import { isPrologueDirective } from '../printer/utilities.js';
|
|
36
|
+
import { SyntaxKind } from '../syntax-kind.js';
|
|
37
|
+
import { flattenDestructuringBinding, flattenObjectRestAssignment } from './destructuring.js';
|
|
38
|
+
import { SubtreeFacts, type SyntaxFacts } from './syntax-facts.js';
|
|
39
|
+
import { Transformer } from './transformer.js';
|
|
40
|
+
import { createForOfBindingStatement, hasSyntacticModifier } from './utilities.js';
|
|
41
|
+
|
|
42
|
+
export class ObjectRestSpreadTransformer extends Transformer {
|
|
43
|
+
readonly facts: SyntaxFacts;
|
|
44
|
+
private inExportedVariableStatement: boolean;
|
|
45
|
+
private expressionResultIsUnused: boolean;
|
|
46
|
+
/** Parameters after the first one with an object rest element, in the current parameter list. */
|
|
47
|
+
private parametersWithPrecedingObjectRestOrSpread: Set<Node> | undefined;
|
|
48
|
+
|
|
49
|
+
constructor(context: EmitContext, facts: SyntaxFacts) {
|
|
50
|
+
super(context);
|
|
51
|
+
this.facts = facts;
|
|
52
|
+
this.inExportedVariableStatement = false;
|
|
53
|
+
this.expressionResultIsUnused = false;
|
|
54
|
+
this.parametersWithPrecedingObjectRestOrSpread = undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
visit(node: Node): Node | undefined {
|
|
58
|
+
if (
|
|
59
|
+
!this.facts.has(node, SubtreeFacts.ContainsESObjectRestOrSpread) &&
|
|
60
|
+
this.parametersWithPrecedingObjectRestOrSpread === undefined
|
|
61
|
+
)
|
|
62
|
+
return node;
|
|
63
|
+
// Children see `false` unless a case below says otherwise.
|
|
64
|
+
const expressionResultIsUnused = this.expressionResultIsUnused;
|
|
65
|
+
this.expressionResultIsUnused = false;
|
|
66
|
+
const result = this.visitWorker(node, expressionResultIsUnused);
|
|
67
|
+
this.expressionResultIsUnused = expressionResultIsUnused;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private visitWorker(node: Node, expressionResultIsUnused: boolean): Node | undefined {
|
|
72
|
+
switch (node.kind) {
|
|
73
|
+
case SyntaxKind.SourceFile:
|
|
74
|
+
return this.visitSourceFile(node as SourceFile);
|
|
75
|
+
case SyntaxKind.ObjectLiteralExpression:
|
|
76
|
+
return this.visitObjectLiteralExpression(node as ObjectLiteralExpression);
|
|
77
|
+
case SyntaxKind.BinaryExpression:
|
|
78
|
+
return this.visitBinaryExpression(node as BinaryExpression, expressionResultIsUnused);
|
|
79
|
+
case SyntaxKind.ExpressionStatement:
|
|
80
|
+
this.expressionResultIsUnused = true;
|
|
81
|
+
return this.visitEachChild(node);
|
|
82
|
+
case SyntaxKind.ParenthesizedExpression:
|
|
83
|
+
this.expressionResultIsUnused = expressionResultIsUnused;
|
|
84
|
+
return this.visitEachChild(node);
|
|
85
|
+
case SyntaxKind.ForOfStatement:
|
|
86
|
+
return this.visitForOfStatement(node as ForInOrOfStatement);
|
|
87
|
+
case SyntaxKind.VariableStatement:
|
|
88
|
+
return this.visitVariableStatement(node as VariableStatement);
|
|
89
|
+
case SyntaxKind.VariableDeclaration:
|
|
90
|
+
return this.visitVariableDeclaration(node as VariableDeclaration);
|
|
91
|
+
case SyntaxKind.CatchClause:
|
|
92
|
+
return this.visitCatchClause(node as CatchClause);
|
|
93
|
+
case SyntaxKind.Parameter:
|
|
94
|
+
return this.visitParameter(node as ParameterDeclaration);
|
|
95
|
+
case SyntaxKind.Constructor:
|
|
96
|
+
case SyntaxKind.GetAccessor:
|
|
97
|
+
case SyntaxKind.SetAccessor:
|
|
98
|
+
case SyntaxKind.MethodDeclaration:
|
|
99
|
+
case SyntaxKind.FunctionDeclaration:
|
|
100
|
+
case SyntaxKind.ArrowFunction:
|
|
101
|
+
case SyntaxKind.FunctionExpression:
|
|
102
|
+
return this.visitFunctionLike(node);
|
|
103
|
+
}
|
|
104
|
+
return this.visitEachChild(node);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private visitSourceFile(node: SourceFile): Node {
|
|
108
|
+
const visited = this.visitEachChild(node);
|
|
109
|
+
const helpers = this.context.readEmitHelpers();
|
|
110
|
+
for (let i = 0; i < helpers.length; i++) this.context.addEmitHelper(visited, helpers[i]);
|
|
111
|
+
return visited;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private visitParameter(node: ParameterDeclaration): Node {
|
|
115
|
+
const factory = this.factory;
|
|
116
|
+
const preceding = this.parametersWithPrecedingObjectRestOrSpread;
|
|
117
|
+
if (preceding !== undefined && preceding.has(node as Node)) {
|
|
118
|
+
const name =
|
|
119
|
+
node.name instanceof BindingPattern ? factory.createGeneratedNameForNode(node, 0, '', '') : node.name;
|
|
120
|
+
return factory.updateParameterDeclaration(
|
|
121
|
+
node,
|
|
122
|
+
undefined,
|
|
123
|
+
node.dotDotDotToken,
|
|
124
|
+
name,
|
|
125
|
+
undefined,
|
|
126
|
+
undefined,
|
|
127
|
+
undefined,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
// A pattern with an object rest becomes a generated name, destructured in the body.
|
|
131
|
+
if (this.facts.has(node, SubtreeFacts.ContainsObjectRestOrSpread))
|
|
132
|
+
return factory.updateParameterDeclaration(
|
|
133
|
+
node,
|
|
134
|
+
undefined,
|
|
135
|
+
node.dotDotDotToken,
|
|
136
|
+
factory.createGeneratedNameForNode(node, 0, '', ''),
|
|
137
|
+
undefined,
|
|
138
|
+
undefined,
|
|
139
|
+
this.visitNode(node.initializer),
|
|
140
|
+
);
|
|
141
|
+
return this.visitEachChild(node);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private collectParametersWithPrecedingObjectRestOrSpread(node: Node): Set<Node> | undefined {
|
|
145
|
+
let result: Set<Node> | undefined = undefined;
|
|
146
|
+
const parameters = getParameters(node)!.nodes;
|
|
147
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
148
|
+
if (result !== undefined) result.add(parameters[i]);
|
|
149
|
+
else if (this.facts.has(parameters[i], SubtreeFacts.ContainsObjectRestOrSpread)) result = new Set<Node>();
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private visitFunctionLike(node: Node): Node {
|
|
155
|
+
const saved = this.parametersWithPrecedingObjectRestOrSpread;
|
|
156
|
+
this.parametersWithPrecedingObjectRestOrSpread = this.collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
157
|
+
const result = this.updateFunctionLike(node);
|
|
158
|
+
this.parametersWithPrecedingObjectRestOrSpread = saved;
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private updateFunctionLike(node: Node): Node {
|
|
163
|
+
const factory = this.factory;
|
|
164
|
+
if (node instanceof ConstructorDeclaration) {
|
|
165
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
166
|
+
return factory.updateConstructorDeclaration(
|
|
167
|
+
node as ConstructorDeclaration,
|
|
168
|
+
node.modifiers,
|
|
169
|
+
undefined,
|
|
170
|
+
parameters,
|
|
171
|
+
undefined,
|
|
172
|
+
undefined,
|
|
173
|
+
this.transformFunctionBody(node),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (node instanceof GetAccessorDeclaration) {
|
|
177
|
+
const name = this.visitNode(node.name)!;
|
|
178
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
179
|
+
return factory.updateGetAccessorDeclaration(
|
|
180
|
+
node as GetAccessorDeclaration,
|
|
181
|
+
node.modifiers,
|
|
182
|
+
name,
|
|
183
|
+
undefined,
|
|
184
|
+
parameters,
|
|
185
|
+
undefined,
|
|
186
|
+
undefined,
|
|
187
|
+
this.transformFunctionBody(node),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
if (node instanceof SetAccessorDeclaration) {
|
|
191
|
+
const name = this.visitNode(node.name)!;
|
|
192
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
193
|
+
return factory.updateSetAccessorDeclaration(
|
|
194
|
+
node as SetAccessorDeclaration,
|
|
195
|
+
node.modifiers,
|
|
196
|
+
name,
|
|
197
|
+
undefined,
|
|
198
|
+
parameters,
|
|
199
|
+
undefined,
|
|
200
|
+
undefined,
|
|
201
|
+
this.transformFunctionBody(node),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (node instanceof MethodDeclaration) {
|
|
205
|
+
const name = this.visitNode(node.name)!;
|
|
206
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
207
|
+
return factory.updateMethodDeclaration(
|
|
208
|
+
node as MethodDeclaration,
|
|
209
|
+
node.modifiers,
|
|
210
|
+
node.asteriskToken,
|
|
211
|
+
name,
|
|
212
|
+
node.postfixToken,
|
|
213
|
+
undefined,
|
|
214
|
+
parameters,
|
|
215
|
+
undefined,
|
|
216
|
+
undefined,
|
|
217
|
+
this.transformFunctionBody(node),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
if (node instanceof FunctionDeclaration) {
|
|
221
|
+
const name = node.name === undefined ? undefined : (this.visitNode(node.name) as Identifier);
|
|
222
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
223
|
+
return factory.updateFunctionDeclaration(
|
|
224
|
+
node as FunctionDeclaration,
|
|
225
|
+
node.modifiers,
|
|
226
|
+
node.asteriskToken,
|
|
227
|
+
name,
|
|
228
|
+
undefined,
|
|
229
|
+
parameters,
|
|
230
|
+
undefined,
|
|
231
|
+
undefined,
|
|
232
|
+
this.transformFunctionBody(node),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
if (node instanceof ArrowFunction) {
|
|
236
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
237
|
+
return factory.updateArrowFunction(
|
|
238
|
+
node as ArrowFunction,
|
|
239
|
+
node.modifiers,
|
|
240
|
+
undefined,
|
|
241
|
+
parameters,
|
|
242
|
+
undefined,
|
|
243
|
+
undefined,
|
|
244
|
+
node.equalsGreaterThanToken,
|
|
245
|
+
this.transformFunctionBody(node)!,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
if (node instanceof FunctionExpression) {
|
|
249
|
+
const name = node.name === undefined ? undefined : (this.visitNode(node.name) as Identifier);
|
|
250
|
+
const parameters = this.visitNodes(node.parameters)!;
|
|
251
|
+
return factory.updateFunctionExpression(
|
|
252
|
+
node as FunctionExpression,
|
|
253
|
+
node.modifiers,
|
|
254
|
+
node.asteriskToken,
|
|
255
|
+
name,
|
|
256
|
+
undefined,
|
|
257
|
+
parameters,
|
|
258
|
+
undefined,
|
|
259
|
+
undefined,
|
|
260
|
+
this.transformFunctionBody(node) as Block,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
return this.visitEachChild(node);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The visited body, with the destructuring of parameters with object rest elements prepended. */
|
|
267
|
+
private transformFunctionBody(node: Node): Node | undefined {
|
|
268
|
+
const factory = this.factory;
|
|
269
|
+
const context = this.context;
|
|
270
|
+
// Not `visitFunctionBody`: the rest assignments go between the body and the hoisted variables.
|
|
271
|
+
context.startVariableEnvironment();
|
|
272
|
+
let body = this.visitNode(getBody(node));
|
|
273
|
+
let extras = context.endVariableEnvironment();
|
|
274
|
+
context.startVariableEnvironment();
|
|
275
|
+
const newStatements = this.collectObjectRestAssignments(node);
|
|
276
|
+
extras = context.mergeEnvironment(extras, context.endVariableEnvironment());
|
|
277
|
+
if (newStatements.length === 0 && extras.length === 0) return body;
|
|
278
|
+
if (body === undefined) body = factory.createBlock([], true);
|
|
279
|
+
const prefix: Node[] = [];
|
|
280
|
+
let suffix: Node[] = [];
|
|
281
|
+
let block: Block;
|
|
282
|
+
if (body instanceof Block) {
|
|
283
|
+
block = body as Block;
|
|
284
|
+
const statements = body.statements.nodes;
|
|
285
|
+
let custom = false;
|
|
286
|
+
for (let i = 0; i < statements.length; i++) {
|
|
287
|
+
const statement = statements[i];
|
|
288
|
+
if (!custom && isPrologueDirective(statement)) prefix.push(statement);
|
|
289
|
+
else if ((context.getEmitFlags(statement) & EmitFlags.CustomPrologue) !== 0) {
|
|
290
|
+
custom = true;
|
|
291
|
+
prefix.push(statement);
|
|
292
|
+
} else {
|
|
293
|
+
suffix = statements.slice(i);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
const statement = factory.createReturnStatement(body);
|
|
299
|
+
statement.pos = body.pos;
|
|
300
|
+
statement.end = body.end;
|
|
301
|
+
const list = factory.createNodeList([]);
|
|
302
|
+
list.pos = body.pos;
|
|
303
|
+
list.end = body.end;
|
|
304
|
+
block = factory.created(new Block(list, true));
|
|
305
|
+
suffix.push(statement);
|
|
306
|
+
}
|
|
307
|
+
const statements = prefix.concat(extras, newStatements, suffix);
|
|
308
|
+
return factory.updateBlock(
|
|
309
|
+
block,
|
|
310
|
+
new NodeList(block.statements.pos, block.statements.end, statements),
|
|
311
|
+
block.multiLine,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private collectObjectRestAssignments(node: Node): Node[] {
|
|
316
|
+
const factory = this.factory;
|
|
317
|
+
const context = this.context;
|
|
318
|
+
const results: Node[] = [];
|
|
319
|
+
let containsPrecedingObjectRestOrSpread = false;
|
|
320
|
+
const parameters = getParameters(node)!.nodes;
|
|
321
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
322
|
+
const parameter = parameters[i] as ParameterDeclaration;
|
|
323
|
+
if (containsPrecedingObjectRestOrSpread) {
|
|
324
|
+
if (parameter.name instanceof BindingPattern) {
|
|
325
|
+
// `[]` and `{}` declare nothing, but an initializer may have side effects.
|
|
326
|
+
if (parameter.name.elements.nodes.length > 0) {
|
|
327
|
+
const declarations = flattenDestructuringBinding(
|
|
328
|
+
this,
|
|
329
|
+
undefined,
|
|
330
|
+
parameter,
|
|
331
|
+
factory.createGeneratedNameForNode(parameter, 0, '', ''),
|
|
332
|
+
false,
|
|
333
|
+
false,
|
|
334
|
+
);
|
|
335
|
+
if (declarations !== undefined) results.push(this.createPrologueVariableStatement(declarations));
|
|
336
|
+
} else if (parameter.initializer !== undefined) {
|
|
337
|
+
const name = factory.createGeneratedNameForNode(parameter, 0, '', '');
|
|
338
|
+
const statement = factory.createExpressionStatement(
|
|
339
|
+
factory.createAssignment(name, this.visitNode(parameter.initializer)!),
|
|
340
|
+
);
|
|
341
|
+
context.addEmitFlags(statement, EmitFlags.CustomPrologue);
|
|
342
|
+
results.push(statement);
|
|
343
|
+
}
|
|
344
|
+
} else if (parameter.initializer !== undefined) results.push(this.createDefaultValueStatement(parameter));
|
|
345
|
+
} else if (this.facts.has(parameter, SubtreeFacts.ContainsObjectRestOrSpread)) {
|
|
346
|
+
containsPrecedingObjectRestOrSpread = true;
|
|
347
|
+
const declarations = flattenDestructuringBinding(
|
|
348
|
+
this,
|
|
349
|
+
this.facts,
|
|
350
|
+
parameter,
|
|
351
|
+
factory.createGeneratedNameForNode(parameter, 0, '', ''),
|
|
352
|
+
false,
|
|
353
|
+
true,
|
|
354
|
+
);
|
|
355
|
+
if (declarations !== undefined) results.push(this.createPrologueVariableStatement(declarations));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return results;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** `if (x === void 0) { x = initializer; }` for a parameter after one with an object rest. */
|
|
362
|
+
private createDefaultValueStatement(parameter: ParameterDeclaration): Node {
|
|
363
|
+
const factory = this.factory;
|
|
364
|
+
const context = this.context;
|
|
365
|
+
const original = parameter.name;
|
|
366
|
+
const name = factory.cloneNode(original, original.deepClone());
|
|
367
|
+
name.pos = original.pos;
|
|
368
|
+
name.end = original.end;
|
|
369
|
+
context.addEmitFlags(name, EmitFlags.NoSourceMap);
|
|
370
|
+
const initializer = this.visitNode(parameter.initializer)!;
|
|
371
|
+
context.addEmitFlags(initializer, EmitFlags.NoSourceMap | EmitFlags.NoComments);
|
|
372
|
+
const assignment = factory.createAssignment(name, initializer);
|
|
373
|
+
assignment.pos = parameter.pos;
|
|
374
|
+
assignment.end = parameter.end;
|
|
375
|
+
context.addEmitFlags(assignment, EmitFlags.NoComments);
|
|
376
|
+
const block = factory.createBlock([factory.createExpressionStatement(assignment)], false);
|
|
377
|
+
block.pos = parameter.pos;
|
|
378
|
+
block.end = parameter.end;
|
|
379
|
+
context.addEmitFlags(
|
|
380
|
+
block,
|
|
381
|
+
EmitFlags.SingleLine | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments,
|
|
382
|
+
);
|
|
383
|
+
const statement = factory.createIfStatement(
|
|
384
|
+
factory.createTypeCheck(factory.cloneNode(name, name.deepClone()), 'undefined'),
|
|
385
|
+
block,
|
|
386
|
+
undefined,
|
|
387
|
+
);
|
|
388
|
+
statement.pos = parameter.pos;
|
|
389
|
+
statement.end = parameter.end;
|
|
390
|
+
context.addEmitFlags(
|
|
391
|
+
statement,
|
|
392
|
+
EmitFlags.NoTokenSourceMaps |
|
|
393
|
+
EmitFlags.NoTrailingSourceMap |
|
|
394
|
+
EmitFlags.CustomPrologue |
|
|
395
|
+
EmitFlags.NoComments |
|
|
396
|
+
EmitFlags.StartOnNewLine,
|
|
397
|
+
);
|
|
398
|
+
return statement;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** `var` of flattened declarations, as a custom prologue. */
|
|
402
|
+
private createPrologueVariableStatement(declarations: Node): Node {
|
|
403
|
+
const factory = this.factory;
|
|
404
|
+
const statement = factory.createVariableStatement(
|
|
405
|
+
undefined,
|
|
406
|
+
factory.createVariableDeclarationList(factory.createNodeList(declarationsOf(declarations)), NodeFlags.None),
|
|
407
|
+
);
|
|
408
|
+
this.context.addEmitFlags(statement, EmitFlags.CustomPrologue);
|
|
409
|
+
return statement;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
private visitCatchClause(node: CatchClause): Node {
|
|
413
|
+
const declaration = node.variableDeclaration;
|
|
414
|
+
if (
|
|
415
|
+
declaration === undefined ||
|
|
416
|
+
!(declaration.name instanceof BindingPattern) ||
|
|
417
|
+
!this.facts.has(declaration.name, SubtreeFacts.ContainsObjectRestOrSpread)
|
|
418
|
+
)
|
|
419
|
+
return this.visitEachChild(node);
|
|
420
|
+
const factory = this.factory;
|
|
421
|
+
const name = factory.createGeneratedNameForNode(declaration.name, 0, '', '');
|
|
422
|
+
const updated = factory.updateVariableDeclaration(declaration, declaration.name, undefined, undefined, name);
|
|
423
|
+
const bindings = flattenDestructuringBinding(this, this.facts, updated, undefined, false, false);
|
|
424
|
+
let block = this.visitNode(node.block) as Block;
|
|
425
|
+
if (bindings !== undefined) {
|
|
426
|
+
const statement = factory.createVariableStatement(
|
|
427
|
+
undefined,
|
|
428
|
+
factory.createVariableDeclarationList(factory.createNodeList(declarationsOf(bindings)), NodeFlags.None),
|
|
429
|
+
);
|
|
430
|
+
const statements: Node[] = [statement];
|
|
431
|
+
for (let i = 0; i < block.statements.nodes.length; i++) statements.push(block.statements.nodes[i]);
|
|
432
|
+
block = factory.updateBlock(
|
|
433
|
+
block,
|
|
434
|
+
new NodeList(block.statements.pos, block.statements.end, statements),
|
|
435
|
+
block.multiLine,
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
return factory.updateCatchClause(
|
|
439
|
+
node,
|
|
440
|
+
factory.updateVariableDeclaration(declaration, name, undefined, undefined, undefined),
|
|
441
|
+
block,
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
private visitVariableStatement(node: VariableStatement): Node {
|
|
446
|
+
if (!hasSyntacticModifier(node, ModifierFlags.Export)) return this.visitEachChild(node);
|
|
447
|
+
const saved = this.inExportedVariableStatement;
|
|
448
|
+
this.inExportedVariableStatement = true;
|
|
449
|
+
const result = this.visitEachChild(node);
|
|
450
|
+
this.inExportedVariableStatement = saved;
|
|
451
|
+
return result;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
private visitVariableDeclaration(node: VariableDeclaration): Node | undefined {
|
|
455
|
+
const exported = this.inExportedVariableStatement;
|
|
456
|
+
this.inExportedVariableStatement = false;
|
|
457
|
+
let result: Node | undefined;
|
|
458
|
+
// Only reached for a binding pattern with an object rest somewhere in it.
|
|
459
|
+
if (node.name instanceof BindingPattern && this.facts.has(node, SubtreeFacts.ContainsObjectRestOrSpread))
|
|
460
|
+
result = flattenDestructuringBinding(this, this.facts, node, undefined, exported, false);
|
|
461
|
+
else result = this.visitEachChild(node);
|
|
462
|
+
this.inExportedVariableStatement = exported;
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private visitForOfStatement(node: ForInOrOfStatement): Node {
|
|
467
|
+
const factory = this.factory;
|
|
468
|
+
const initializer = node.initializer;
|
|
469
|
+
if (
|
|
470
|
+
!this.facts.has(initializer, SubtreeFacts.ContainsObjectRestOrSpread) &&
|
|
471
|
+
!(isAssignmentPattern(initializer) && this.facts.containsObjectRestOrSpread(initializer))
|
|
472
|
+
)
|
|
473
|
+
return this.visitEachChild(node);
|
|
474
|
+
const head = skipParentheses(initializer);
|
|
475
|
+
if (head.kind !== SyntaxKind.VariableDeclarationList && !isAssignmentPattern(head))
|
|
476
|
+
return this.visitEachChild(node);
|
|
477
|
+
const temp = factory.createTempVariable(0);
|
|
478
|
+
const statements: Node[] = [];
|
|
479
|
+
const binding = this.visitNode(createForOfBindingStatement(factory, head, temp));
|
|
480
|
+
if (binding !== undefined) statements.push(binding);
|
|
481
|
+
let bodyPos = -1;
|
|
482
|
+
let bodyEnd = -1;
|
|
483
|
+
let statementsPos = -1;
|
|
484
|
+
let statementsEnd = -1;
|
|
485
|
+
const body = node.statement;
|
|
486
|
+
if (body instanceof Block) {
|
|
487
|
+
const nodes = body.statements.nodes;
|
|
488
|
+
for (let i = 0; i < nodes.length; i++) statements.push(this.visitEachChild(nodes[i]));
|
|
489
|
+
bodyPos = body.pos;
|
|
490
|
+
bodyEnd = body.end;
|
|
491
|
+
statementsPos = body.statements.pos;
|
|
492
|
+
statementsEnd = body.statements.end;
|
|
493
|
+
} else {
|
|
494
|
+
statements.push(this.visitEachChild(body));
|
|
495
|
+
bodyPos = body.pos;
|
|
496
|
+
bodyEnd = body.end;
|
|
497
|
+
statementsPos = body.pos;
|
|
498
|
+
statementsEnd = body.end;
|
|
499
|
+
}
|
|
500
|
+
const list = factory.createVariableDeclarationList(
|
|
501
|
+
factory.createNodeList([factory.createVariableDeclaration(temp, undefined, undefined, undefined)]),
|
|
502
|
+
NodeFlags.Let,
|
|
503
|
+
);
|
|
504
|
+
list.pos = initializer.pos;
|
|
505
|
+
list.end = initializer.end;
|
|
506
|
+
const expression = this.visitEachChild(node.expression);
|
|
507
|
+
const block = factory.created(new Block(new NodeList(statementsPos, statementsEnd, statements), true));
|
|
508
|
+
block.pos = bodyPos;
|
|
509
|
+
block.end = bodyEnd;
|
|
510
|
+
return factory.updateForInOrOfStatement(node, node.awaitModifier, list, expression, block);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
private visitBinaryExpression(node: BinaryExpression, expressionResultIsUnused: boolean): Node {
|
|
514
|
+
if (isDestructuringAssignment(node) && this.facts.containsObjectRestOrSpread(node.left))
|
|
515
|
+
return flattenObjectRestAssignment(this, this.facts, node, !expressionResultIsUnused);
|
|
516
|
+
if (node.operatorToken.kind === SyntaxKind.CommaToken) {
|
|
517
|
+
this.expressionResultIsUnused = true;
|
|
518
|
+
const left = this.visitNode(node.left)!;
|
|
519
|
+
this.expressionResultIsUnused = expressionResultIsUnused;
|
|
520
|
+
const right = this.visitNode(node.right)!;
|
|
521
|
+
return this.factory.updateBinaryExpression(node, undefined, left, undefined, node.operatorToken, right);
|
|
522
|
+
}
|
|
523
|
+
return this.visitEachChild(node);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
private visitObjectLiteralExpression(node: ObjectLiteralExpression): Node {
|
|
527
|
+
if ((this.facts.of(node) & SubtreeFacts.ContainsObjectRestOrSpread) === 0) return this.visitEachChild(node);
|
|
528
|
+
// Elements between spreads are chunked into object literals, each merged with one more
|
|
529
|
+
// `Object.assign` call so side effects run in order: `{ a, ...o, b }` becomes
|
|
530
|
+
// `Object.assign(Object.assign({ a }, o), { b })`.
|
|
531
|
+
const factory = this.factory;
|
|
532
|
+
const objects = this.chunkObjectLiteralElements(node.properties.nodes);
|
|
533
|
+
if (objects.length > 0 && objects[0].kind !== SyntaxKind.ObjectLiteralExpression)
|
|
534
|
+
objects.unshift(factory.createObjectLiteral([], false));
|
|
535
|
+
let expression = objects[0];
|
|
536
|
+
if (objects.length > 1) {
|
|
537
|
+
for (let i = 1; i < objects.length; i++) expression = this.createAssign([expression, objects[i]]);
|
|
538
|
+
return expression;
|
|
539
|
+
}
|
|
540
|
+
return this.createAssign(objects);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private createAssign(args: Node[]): Node {
|
|
544
|
+
return this.factory.createGlobalMethodCall('Object', 'assign', args);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
private chunkObjectLiteralElements(elements: Node[]): Node[] {
|
|
548
|
+
const factory = this.factory;
|
|
549
|
+
const objects: Node[] = [];
|
|
550
|
+
let chunk: Node[] = [];
|
|
551
|
+
for (let i = 0; i < elements.length; i++) {
|
|
552
|
+
const element = elements[i];
|
|
553
|
+
if (element instanceof SpreadAssignment) {
|
|
554
|
+
if (chunk.length > 0) {
|
|
555
|
+
objects.push(factory.createObjectLiteral(chunk, false));
|
|
556
|
+
chunk = [];
|
|
557
|
+
}
|
|
558
|
+
objects.push(this.visitNode(element.expression)!);
|
|
559
|
+
} else if (element instanceof PropertyAssignment)
|
|
560
|
+
chunk.push(factory.createPropertyAssignment(element.name, this.visitNode(element.initializer)!));
|
|
561
|
+
else {
|
|
562
|
+
const visited = this.visitNode(element);
|
|
563
|
+
if (visited !== undefined) chunk.push(visited);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (chunk.length > 0) objects.push(factory.createObjectLiteral(chunk, false));
|
|
567
|
+
return objects;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function isAssignmentPattern(node: Node): boolean {
|
|
572
|
+
return node.kind === SyntaxKind.ObjectLiteralExpression || node.kind === SyntaxKind.ArrayLiteralExpression;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function declarationsOf(node: Node): Node[] {
|
|
576
|
+
return node instanceof SyntaxList ? node.children : [node];
|
|
577
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Gives `catch` clauses without a binding a temporary one (ES2019).
|
|
2
|
+
import { Block, CatchClause, type Node } from '../ast.js';
|
|
3
|
+
import type { EmitContext } from '../printer/emit-context.js';
|
|
4
|
+
import { SubtreeFacts, type SyntaxFacts } from './syntax-facts.js';
|
|
5
|
+
import { Transformer } from './transformer.js';
|
|
6
|
+
|
|
7
|
+
export class OptionalCatchTransformer extends Transformer {
|
|
8
|
+
readonly facts: SyntaxFacts;
|
|
9
|
+
|
|
10
|
+
constructor(context: EmitContext, facts: SyntaxFacts) {
|
|
11
|
+
super(context);
|
|
12
|
+
this.facts = facts;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
visit(node: Node): Node | undefined {
|
|
16
|
+
if (!this.facts.has(node, SubtreeFacts.ContainsMissingCatchClauseVariable)) return node;
|
|
17
|
+
if (node instanceof CatchClause && node.variableDeclaration === undefined) {
|
|
18
|
+
const factory = this.factory;
|
|
19
|
+
const block = this.visitNode(node.block);
|
|
20
|
+
return factory.created(
|
|
21
|
+
new CatchClause(
|
|
22
|
+
factory.createVariableDeclaration(factory.createTempVariable(0), undefined, undefined, undefined),
|
|
23
|
+
block instanceof Block ? (block as Block) : node.block,
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return this.visitEachChild(node);
|
|
28
|
+
}
|
|
29
|
+
}
|