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,817 @@
|
|
|
1
|
+
// Node predicates, literal text and line helpers shared by the printer and transforms.
|
|
2
|
+
import { BigIntLiteral, BinaryExpression, CallExpression, ConditionalExpression, ElementAccessExpression, InferTypeNode, NewExpression, NoSubstitutionTemplateLiteral, NonNullExpression, NumericLiteral, ParenthesizedExpression, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAccessExpression, RegularExpressionLiteral, AsExpression, SatisfiesExpression, SourceFile, StringLiteral, TaggedTemplateExpression, TemplateHead, TemplateMiddle, TemplateTail, ExpressionStatement, Identifier, PrivateIdentifier, getExpression, } from '../ast.js';
|
|
3
|
+
import { getBinaryOperatorPrecedence } from '../ast-utilities.js';
|
|
4
|
+
import { isDigit, isLineBreak, isUnicodeWhiteSpace, isWhiteSpaceLike, isWhiteSpaceSingleLine, } from '../character-codes.js';
|
|
5
|
+
import { computeLineOfPosition, skipTrivia } from '../scanner.js';
|
|
6
|
+
import { getBaseFileName } from '../path.js';
|
|
7
|
+
// Nodes
|
|
8
|
+
export function positionIsSynthesized(pos) {
|
|
9
|
+
return pos < 0;
|
|
10
|
+
}
|
|
11
|
+
export function nodeIsSynthesized(node) {
|
|
12
|
+
return node.pos < 0 || node.end < 0;
|
|
13
|
+
}
|
|
14
|
+
/** Whether the parser (not a transform) created the node. */
|
|
15
|
+
export function isParseTreeNode(node) {
|
|
16
|
+
return (node.flags & 16 /* NodeFlags.Synthesized */) === 0;
|
|
17
|
+
}
|
|
18
|
+
export function getSourceFileOfNode(node) {
|
|
19
|
+
while (node !== undefined) {
|
|
20
|
+
if (node instanceof SourceFile)
|
|
21
|
+
return node;
|
|
22
|
+
node = node.parent;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export function isPrologueDirective(node) {
|
|
27
|
+
return (node instanceof ExpressionStatement && node.expression.kind === 10 /* SyntaxKind.StringLiteral */);
|
|
28
|
+
}
|
|
29
|
+
export function isKeywordKind(kind) {
|
|
30
|
+
return kind >= 82 /* SyntaxKind.FirstKeyword */ && kind <= 166 /* SyntaxKind.LastKeyword */;
|
|
31
|
+
}
|
|
32
|
+
export function isPunctuationKind(kind) {
|
|
33
|
+
return kind >= 18 /* SyntaxKind.FirstPunctuation */ && kind <= 78 /* SyntaxKind.LastPunctuation */;
|
|
34
|
+
}
|
|
35
|
+
export function isLiteralKind(kind) {
|
|
36
|
+
return kind >= 8 /* SyntaxKind.FirstLiteralToken */ && kind <= 14 /* SyntaxKind.LastLiteralToken */;
|
|
37
|
+
}
|
|
38
|
+
export function isJSDocKind(kind) {
|
|
39
|
+
return kind >= 308 /* SyntaxKind.JSDocTypeExpression */ && kind <= 343 /* SyntaxKind.JSDocImportTag */;
|
|
40
|
+
}
|
|
41
|
+
export function isMemberName(node) {
|
|
42
|
+
return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */;
|
|
43
|
+
}
|
|
44
|
+
export function isModifier(node) {
|
|
45
|
+
switch (node.kind) {
|
|
46
|
+
case 127 /* SyntaxKind.AbstractKeyword */:
|
|
47
|
+
case 128 /* SyntaxKind.AccessorKeyword */:
|
|
48
|
+
case 133 /* SyntaxKind.AsyncKeyword */:
|
|
49
|
+
case 86 /* SyntaxKind.ConstKeyword */:
|
|
50
|
+
case 137 /* SyntaxKind.DeclareKeyword */:
|
|
51
|
+
case 89 /* SyntaxKind.DefaultKeyword */:
|
|
52
|
+
case 94 /* SyntaxKind.ExportKeyword */:
|
|
53
|
+
case 102 /* SyntaxKind.InKeyword */:
|
|
54
|
+
case 122 /* SyntaxKind.PrivateKeyword */:
|
|
55
|
+
case 123 /* SyntaxKind.ProtectedKeyword */:
|
|
56
|
+
case 124 /* SyntaxKind.PublicKeyword */:
|
|
57
|
+
case 148 /* SyntaxKind.ReadonlyKeyword */:
|
|
58
|
+
case 147 /* SyntaxKind.OutKeyword */:
|
|
59
|
+
case 164 /* SyntaxKind.OverrideKeyword */:
|
|
60
|
+
case 125 /* SyntaxKind.StaticKeyword */:
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
export function isOptionalChain(node) {
|
|
66
|
+
if ((node.flags & 32 /* NodeFlags.OptionalChain */) === 0)
|
|
67
|
+
return false;
|
|
68
|
+
switch (node.kind) {
|
|
69
|
+
case 212 /* SyntaxKind.PropertyAccessExpression */:
|
|
70
|
+
case 213 /* SyntaxKind.ElementAccessExpression */:
|
|
71
|
+
case 214 /* SyntaxKind.CallExpression */:
|
|
72
|
+
case 236 /* SyntaxKind.NonNullExpression */:
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
export function isUnterminatedLiteral(node) {
|
|
78
|
+
if (node instanceof StringLiteral)
|
|
79
|
+
return (node.tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
80
|
+
if (node instanceof NumericLiteral)
|
|
81
|
+
return (node.tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
82
|
+
if (node instanceof BigIntLiteral)
|
|
83
|
+
return (node.tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
84
|
+
if (node instanceof RegularExpressionLiteral)
|
|
85
|
+
return (node.tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
86
|
+
if (node instanceof NoSubstitutionTemplateLiteral)
|
|
87
|
+
return (node.templateFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
88
|
+
if (node instanceof TemplateHead)
|
|
89
|
+
return (node.templateFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
90
|
+
if (node instanceof TemplateMiddle)
|
|
91
|
+
return (node.templateFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
92
|
+
if (node instanceof TemplateTail)
|
|
93
|
+
return (node.templateFlags & 4 /* TokenFlags.Unterminated */) !== 0;
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
export function skipPartiallyEmittedExpressions(node) {
|
|
97
|
+
while (node instanceof PartiallyEmittedExpression)
|
|
98
|
+
node = node.expression;
|
|
99
|
+
return node;
|
|
100
|
+
}
|
|
101
|
+
/** Whether a variable declaration list declares `let`, `const`, `using` or `await using`, as `NodeFlags.BlockScoped`. */
|
|
102
|
+
export function blockScopeFlags(node) {
|
|
103
|
+
let flags = node.flags;
|
|
104
|
+
const parent = node.parent;
|
|
105
|
+
if (parent !== undefined && parent.kind === 244 /* SyntaxKind.VariableStatement */)
|
|
106
|
+
flags |= parent.flags;
|
|
107
|
+
return flags & 7 /* NodeFlags.BlockScoped */;
|
|
108
|
+
}
|
|
109
|
+
function isLeftHandSideExpressionKind(kind) {
|
|
110
|
+
switch (kind) {
|
|
111
|
+
case 212 /* SyntaxKind.PropertyAccessExpression */:
|
|
112
|
+
case 213 /* SyntaxKind.ElementAccessExpression */:
|
|
113
|
+
case 215 /* SyntaxKind.NewExpression */:
|
|
114
|
+
case 214 /* SyntaxKind.CallExpression */:
|
|
115
|
+
case 285 /* SyntaxKind.JsxElement */:
|
|
116
|
+
case 286 /* SyntaxKind.JsxSelfClosingElement */:
|
|
117
|
+
case 289 /* SyntaxKind.JsxFragment */:
|
|
118
|
+
case 216 /* SyntaxKind.TaggedTemplateExpression */:
|
|
119
|
+
case 210 /* SyntaxKind.ArrayLiteralExpression */:
|
|
120
|
+
case 218 /* SyntaxKind.ParenthesizedExpression */:
|
|
121
|
+
case 211 /* SyntaxKind.ObjectLiteralExpression */:
|
|
122
|
+
case 232 /* SyntaxKind.ClassExpression */:
|
|
123
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
124
|
+
case 79 /* SyntaxKind.Identifier */:
|
|
125
|
+
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
126
|
+
case 13 /* SyntaxKind.RegularExpressionLiteral */:
|
|
127
|
+
case 8 /* SyntaxKind.NumericLiteral */:
|
|
128
|
+
case 9 /* SyntaxKind.BigIntLiteral */:
|
|
129
|
+
case 10 /* SyntaxKind.StringLiteral */:
|
|
130
|
+
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
|
|
131
|
+
case 229 /* SyntaxKind.TemplateExpression */:
|
|
132
|
+
case 96 /* SyntaxKind.FalseKeyword */:
|
|
133
|
+
case 105 /* SyntaxKind.NullKeyword */:
|
|
134
|
+
case 109 /* SyntaxKind.ThisKeyword */:
|
|
135
|
+
case 111 /* SyntaxKind.TrueKeyword */:
|
|
136
|
+
case 107 /* SyntaxKind.SuperKeyword */:
|
|
137
|
+
case 236 /* SyntaxKind.NonNullExpression */:
|
|
138
|
+
case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
139
|
+
case 237 /* SyntaxKind.MetaProperty */:
|
|
140
|
+
case 101 /* SyntaxKind.ImportKeyword */:
|
|
141
|
+
case 283 /* SyntaxKind.MissingDeclaration */:
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
function isUnaryExpressionKind(kind) {
|
|
147
|
+
switch (kind) {
|
|
148
|
+
case 225 /* SyntaxKind.PrefixUnaryExpression */:
|
|
149
|
+
case 226 /* SyntaxKind.PostfixUnaryExpression */:
|
|
150
|
+
case 221 /* SyntaxKind.DeleteExpression */:
|
|
151
|
+
case 222 /* SyntaxKind.TypeOfExpression */:
|
|
152
|
+
case 223 /* SyntaxKind.VoidExpression */:
|
|
153
|
+
case 224 /* SyntaxKind.AwaitExpression */:
|
|
154
|
+
case 217 /* SyntaxKind.TypeAssertionExpression */:
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return isLeftHandSideExpressionKind(kind);
|
|
158
|
+
}
|
|
159
|
+
export function isExpressionKind(kind) {
|
|
160
|
+
switch (kind) {
|
|
161
|
+
case 228 /* SyntaxKind.ConditionalExpression */:
|
|
162
|
+
case 230 /* SyntaxKind.YieldExpression */:
|
|
163
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
164
|
+
case 227 /* SyntaxKind.BinaryExpression */:
|
|
165
|
+
case 231 /* SyntaxKind.SpreadElement */:
|
|
166
|
+
case 235 /* SyntaxKind.AsExpression */:
|
|
167
|
+
case 233 /* SyntaxKind.OmittedExpression */:
|
|
168
|
+
case 348 /* SyntaxKind.PartiallyEmittedExpression */:
|
|
169
|
+
case 239 /* SyntaxKind.SatisfiesExpression */:
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
return isUnaryExpressionKind(kind);
|
|
173
|
+
}
|
|
174
|
+
export function isExpression(node) {
|
|
175
|
+
return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
|
|
176
|
+
}
|
|
177
|
+
export function isTypeNodeKind(kind) {
|
|
178
|
+
switch (kind) {
|
|
179
|
+
case 132 /* SyntaxKind.AnyKeyword */:
|
|
180
|
+
case 159 /* SyntaxKind.UnknownKeyword */:
|
|
181
|
+
case 150 /* SyntaxKind.NumberKeyword */:
|
|
182
|
+
case 163 /* SyntaxKind.BigIntKeyword */:
|
|
183
|
+
case 151 /* SyntaxKind.ObjectKeyword */:
|
|
184
|
+
case 135 /* SyntaxKind.BooleanKeyword */:
|
|
185
|
+
case 154 /* SyntaxKind.StringKeyword */:
|
|
186
|
+
case 155 /* SyntaxKind.SymbolKeyword */:
|
|
187
|
+
case 115 /* SyntaxKind.VoidKeyword */:
|
|
188
|
+
case 157 /* SyntaxKind.UndefinedKeyword */:
|
|
189
|
+
case 146 /* SyntaxKind.NeverKeyword */:
|
|
190
|
+
case 141 /* SyntaxKind.IntrinsicKeyword */:
|
|
191
|
+
case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
192
|
+
case 310 /* SyntaxKind.JSDocAllType */:
|
|
193
|
+
case 311 /* SyntaxKind.JSDocNullableType */:
|
|
194
|
+
case 312 /* SyntaxKind.JSDocNonNullableType */:
|
|
195
|
+
case 313 /* SyntaxKind.JSDocOptionalType */:
|
|
196
|
+
case 314 /* SyntaxKind.JSDocVariadicType */:
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return kind >= 183 /* SyntaxKind.FirstTypeNode */ && kind <= 206 /* SyntaxKind.LastTypeNode */;
|
|
200
|
+
}
|
|
201
|
+
function isDeclarationStatementKind(kind) {
|
|
202
|
+
switch (kind) {
|
|
203
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
204
|
+
case 283 /* SyntaxKind.MissingDeclaration */:
|
|
205
|
+
case 264 /* SyntaxKind.ClassDeclaration */:
|
|
206
|
+
case 265 /* SyntaxKind.InterfaceDeclaration */:
|
|
207
|
+
case 266 /* SyntaxKind.TypeAliasDeclaration */:
|
|
208
|
+
case 345 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
209
|
+
case 267 /* SyntaxKind.EnumDeclaration */:
|
|
210
|
+
case 268 /* SyntaxKind.ModuleDeclaration */:
|
|
211
|
+
case 273 /* SyntaxKind.ImportDeclaration */:
|
|
212
|
+
case 346 /* SyntaxKind.JSImportDeclaration */:
|
|
213
|
+
case 272 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
214
|
+
case 279 /* SyntaxKind.ExportDeclaration */:
|
|
215
|
+
case 278 /* SyntaxKind.ExportAssignment */:
|
|
216
|
+
case 271 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
function isStatementKindButNotDeclarationKind(kind) {
|
|
222
|
+
switch (kind) {
|
|
223
|
+
case 253 /* SyntaxKind.BreakStatement */:
|
|
224
|
+
case 252 /* SyntaxKind.ContinueStatement */:
|
|
225
|
+
case 260 /* SyntaxKind.DebuggerStatement */:
|
|
226
|
+
case 247 /* SyntaxKind.DoStatement */:
|
|
227
|
+
case 245 /* SyntaxKind.ExpressionStatement */:
|
|
228
|
+
case 243 /* SyntaxKind.EmptyStatement */:
|
|
229
|
+
case 250 /* SyntaxKind.ForInStatement */:
|
|
230
|
+
case 251 /* SyntaxKind.ForOfStatement */:
|
|
231
|
+
case 249 /* SyntaxKind.ForStatement */:
|
|
232
|
+
case 246 /* SyntaxKind.IfStatement */:
|
|
233
|
+
case 257 /* SyntaxKind.LabeledStatement */:
|
|
234
|
+
case 254 /* SyntaxKind.ReturnStatement */:
|
|
235
|
+
case 256 /* SyntaxKind.SwitchStatement */:
|
|
236
|
+
case 258 /* SyntaxKind.ThrowStatement */:
|
|
237
|
+
case 259 /* SyntaxKind.TryStatement */:
|
|
238
|
+
case 244 /* SyntaxKind.VariableStatement */:
|
|
239
|
+
case 248 /* SyntaxKind.WhileStatement */:
|
|
240
|
+
case 255 /* SyntaxKind.WithStatement */:
|
|
241
|
+
case 347 /* SyntaxKind.NotEmittedStatement */:
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
export function isFunctionLikeKind(kind) {
|
|
247
|
+
switch (kind) {
|
|
248
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
249
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
250
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
251
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
252
|
+
case 179 /* SyntaxKind.SetAccessor */:
|
|
253
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
254
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
255
|
+
case 174 /* SyntaxKind.MethodSignature */:
|
|
256
|
+
case 180 /* SyntaxKind.CallSignature */:
|
|
257
|
+
case 318 /* SyntaxKind.JSDocSignature */:
|
|
258
|
+
case 181 /* SyntaxKind.ConstructSignature */:
|
|
259
|
+
case 182 /* SyntaxKind.IndexSignature */:
|
|
260
|
+
case 185 /* SyntaxKind.FunctionType */:
|
|
261
|
+
case 186 /* SyntaxKind.ConstructorType */:
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
export function isStatement(node) {
|
|
267
|
+
const kind = node.kind;
|
|
268
|
+
if (isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind))
|
|
269
|
+
return true;
|
|
270
|
+
if (kind !== 242 /* SyntaxKind.Block */)
|
|
271
|
+
return false;
|
|
272
|
+
const parent = node.parent;
|
|
273
|
+
if (parent === undefined)
|
|
274
|
+
return true;
|
|
275
|
+
return (parent.kind !== 259 /* SyntaxKind.TryStatement */ &&
|
|
276
|
+
parent.kind !== 300 /* SyntaxKind.CatchClause */ &&
|
|
277
|
+
!isFunctionLikeKind(parent.kind));
|
|
278
|
+
}
|
|
279
|
+
// Precedence
|
|
280
|
+
export function getExpressionPrecedence(expression) {
|
|
281
|
+
switch (expression.kind) {
|
|
282
|
+
case 231 /* SyntaxKind.SpreadElement */:
|
|
283
|
+
return 1 /* OperatorPrecedence.Spread */;
|
|
284
|
+
case 230 /* SyntaxKind.YieldExpression */:
|
|
285
|
+
return 2 /* OperatorPrecedence.Yield */;
|
|
286
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
287
|
+
return 3 /* OperatorPrecedence.Assignment */;
|
|
288
|
+
case 228 /* SyntaxKind.ConditionalExpression */:
|
|
289
|
+
return 4 /* OperatorPrecedence.Conditional */;
|
|
290
|
+
case 227 /* SyntaxKind.BinaryExpression */:
|
|
291
|
+
if (expression instanceof BinaryExpression) {
|
|
292
|
+
const operator = expression.operatorToken.kind;
|
|
293
|
+
if (operator === 27 /* SyntaxKind.CommaToken */)
|
|
294
|
+
return 0 /* OperatorPrecedence.Comma */;
|
|
295
|
+
if (operator >= 63 /* SyntaxKind.FirstAssignment */ && operator <= 78 /* SyntaxKind.LastAssignment */)
|
|
296
|
+
return 3 /* OperatorPrecedence.Assignment */;
|
|
297
|
+
return getBinaryOperatorPrecedence(operator);
|
|
298
|
+
}
|
|
299
|
+
return -1 /* OperatorPrecedence.Invalid */;
|
|
300
|
+
case 217 /* SyntaxKind.TypeAssertionExpression */:
|
|
301
|
+
case 236 /* SyntaxKind.NonNullExpression */:
|
|
302
|
+
case 225 /* SyntaxKind.PrefixUnaryExpression */:
|
|
303
|
+
case 222 /* SyntaxKind.TypeOfExpression */:
|
|
304
|
+
case 223 /* SyntaxKind.VoidExpression */:
|
|
305
|
+
case 221 /* SyntaxKind.DeleteExpression */:
|
|
306
|
+
case 224 /* SyntaxKind.AwaitExpression */:
|
|
307
|
+
return 16 /* OperatorPrecedence.Unary */;
|
|
308
|
+
case 226 /* SyntaxKind.PostfixUnaryExpression */:
|
|
309
|
+
return 17 /* OperatorPrecedence.Update */;
|
|
310
|
+
case 212 /* SyntaxKind.PropertyAccessExpression */:
|
|
311
|
+
case 213 /* SyntaxKind.ElementAccessExpression */:
|
|
312
|
+
case 214 /* SyntaxKind.CallExpression */:
|
|
313
|
+
return isOptionalChain(expression) ? 19 /* OperatorPrecedence.OptionalChain */ : 20 /* OperatorPrecedence.Member */;
|
|
314
|
+
case 215 /* SyntaxKind.NewExpression */:
|
|
315
|
+
return expression instanceof NewExpression && expression.arguments === undefined
|
|
316
|
+
? 18 /* OperatorPrecedence.LeftHandSide */
|
|
317
|
+
: 20 /* OperatorPrecedence.Member */;
|
|
318
|
+
case 216 /* SyntaxKind.TaggedTemplateExpression */:
|
|
319
|
+
case 237 /* SyntaxKind.MetaProperty */:
|
|
320
|
+
case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
321
|
+
return 20 /* OperatorPrecedence.Member */;
|
|
322
|
+
case 235 /* SyntaxKind.AsExpression */:
|
|
323
|
+
case 239 /* SyntaxKind.SatisfiesExpression */:
|
|
324
|
+
return 11 /* OperatorPrecedence.Relational */;
|
|
325
|
+
case 109 /* SyntaxKind.ThisKeyword */:
|
|
326
|
+
case 107 /* SyntaxKind.SuperKeyword */:
|
|
327
|
+
case 101 /* SyntaxKind.ImportKeyword */:
|
|
328
|
+
case 79 /* SyntaxKind.Identifier */:
|
|
329
|
+
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
330
|
+
case 105 /* SyntaxKind.NullKeyword */:
|
|
331
|
+
case 111 /* SyntaxKind.TrueKeyword */:
|
|
332
|
+
case 96 /* SyntaxKind.FalseKeyword */:
|
|
333
|
+
case 8 /* SyntaxKind.NumericLiteral */:
|
|
334
|
+
case 9 /* SyntaxKind.BigIntLiteral */:
|
|
335
|
+
case 10 /* SyntaxKind.StringLiteral */:
|
|
336
|
+
case 210 /* SyntaxKind.ArrayLiteralExpression */:
|
|
337
|
+
case 211 /* SyntaxKind.ObjectLiteralExpression */:
|
|
338
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
339
|
+
case 232 /* SyntaxKind.ClassExpression */:
|
|
340
|
+
case 13 /* SyntaxKind.RegularExpressionLiteral */:
|
|
341
|
+
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
|
|
342
|
+
case 229 /* SyntaxKind.TemplateExpression */:
|
|
343
|
+
case 233 /* SyntaxKind.OmittedExpression */:
|
|
344
|
+
case 285 /* SyntaxKind.JsxElement */:
|
|
345
|
+
case 286 /* SyntaxKind.JsxSelfClosingElement */:
|
|
346
|
+
case 289 /* SyntaxKind.JsxFragment */:
|
|
347
|
+
case 283 /* SyntaxKind.MissingDeclaration */:
|
|
348
|
+
return 21 /* OperatorPrecedence.Primary */;
|
|
349
|
+
case 218 /* SyntaxKind.ParenthesizedExpression */:
|
|
350
|
+
return 22 /* OperatorPrecedence.Parentheses */;
|
|
351
|
+
}
|
|
352
|
+
return -1 /* OperatorPrecedence.Invalid */;
|
|
353
|
+
}
|
|
354
|
+
export function getTypeNodePrecedence(node) {
|
|
355
|
+
switch (node.kind) {
|
|
356
|
+
case 195 /* SyntaxKind.ConditionalType */:
|
|
357
|
+
return 0 /* TypePrecedence.Conditional */;
|
|
358
|
+
case 313 /* SyntaxKind.JSDocOptionalType */:
|
|
359
|
+
case 314 /* SyntaxKind.JSDocVariadicType */:
|
|
360
|
+
return 1 /* TypePrecedence.JSDoc */;
|
|
361
|
+
case 185 /* SyntaxKind.FunctionType */:
|
|
362
|
+
case 186 /* SyntaxKind.ConstructorType */:
|
|
363
|
+
return 2 /* TypePrecedence.Function */;
|
|
364
|
+
case 193 /* SyntaxKind.UnionType */:
|
|
365
|
+
return 3 /* TypePrecedence.Union */;
|
|
366
|
+
case 194 /* SyntaxKind.IntersectionType */:
|
|
367
|
+
return 4 /* TypePrecedence.Intersection */;
|
|
368
|
+
case 199 /* SyntaxKind.TypeOperator */:
|
|
369
|
+
case 187 /* SyntaxKind.TypeQuery */:
|
|
370
|
+
return 5 /* TypePrecedence.TypeOperator */;
|
|
371
|
+
case 196 /* SyntaxKind.InferType */:
|
|
372
|
+
return node instanceof InferTypeNode && node.typeParameter.constraint !== undefined
|
|
373
|
+
? 2 /* TypePrecedence.Function */
|
|
374
|
+
: 5 /* TypePrecedence.TypeOperator */;
|
|
375
|
+
case 200 /* SyntaxKind.IndexedAccessType */:
|
|
376
|
+
case 189 /* SyntaxKind.ArrayType */:
|
|
377
|
+
case 191 /* SyntaxKind.OptionalType */:
|
|
378
|
+
return 6 /* TypePrecedence.Postfix */;
|
|
379
|
+
}
|
|
380
|
+
return 7 /* TypePrecedence.NonArray */;
|
|
381
|
+
}
|
|
382
|
+
/** The leftmost operand of an expression, e.g. `a` in `a.b + c`. */
|
|
383
|
+
export function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
384
|
+
for (;;) {
|
|
385
|
+
if (node instanceof PostfixUnaryExpression)
|
|
386
|
+
node = node.operand;
|
|
387
|
+
else if (node instanceof BinaryExpression)
|
|
388
|
+
node = node.left;
|
|
389
|
+
else if (node instanceof ConditionalExpression)
|
|
390
|
+
node = node.condition;
|
|
391
|
+
else if (node instanceof TaggedTemplateExpression)
|
|
392
|
+
node = node.tag;
|
|
393
|
+
else if (node instanceof PartiallyEmittedExpression)
|
|
394
|
+
node = node.expression;
|
|
395
|
+
else if (node instanceof CallExpression) {
|
|
396
|
+
if (stopAtCallExpressions)
|
|
397
|
+
return node;
|
|
398
|
+
node = node.expression;
|
|
399
|
+
}
|
|
400
|
+
else if (node instanceof AsExpression ||
|
|
401
|
+
node instanceof ElementAccessExpression ||
|
|
402
|
+
node instanceof PropertyAccessExpression ||
|
|
403
|
+
node instanceof NonNullExpression ||
|
|
404
|
+
node instanceof PartiallyEmittedExpression ||
|
|
405
|
+
node instanceof SatisfiesExpression) {
|
|
406
|
+
const expression = getExpression(node);
|
|
407
|
+
if (expression === undefined)
|
|
408
|
+
return node;
|
|
409
|
+
node = expression;
|
|
410
|
+
}
|
|
411
|
+
else
|
|
412
|
+
return node;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
export function skipSynthesizedParentheses(node) {
|
|
416
|
+
while (node instanceof ParenthesizedExpression && nodeIsSynthesized(node))
|
|
417
|
+
node = node.expression;
|
|
418
|
+
return node;
|
|
419
|
+
}
|
|
420
|
+
export function isNewExpressionWithoutArguments(node) {
|
|
421
|
+
return node instanceof NewExpression && node.arguments === undefined;
|
|
422
|
+
}
|
|
423
|
+
export function isBinaryOperation(node, token) {
|
|
424
|
+
node = skipPartiallyEmittedExpressions(node);
|
|
425
|
+
return node instanceof BinaryExpression && node.operatorToken.kind === token;
|
|
426
|
+
}
|
|
427
|
+
export function mixingBinaryOperatorsRequiresParentheses(a, b) {
|
|
428
|
+
if (a === 60 /* SyntaxKind.QuestionQuestionToken */)
|
|
429
|
+
return b === 55 /* SyntaxKind.AmpersandAmpersandToken */ || b === 56 /* SyntaxKind.BarBarToken */;
|
|
430
|
+
if (b === 60 /* SyntaxKind.QuestionQuestionToken */)
|
|
431
|
+
return a === 55 /* SyntaxKind.AmpersandAmpersandToken */ || a === 56 /* SyntaxKind.BarBarToken */;
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
export function isImmediatelyInvokedFunctionExpressionOrArrowFunction(node) {
|
|
435
|
+
node = skipPartiallyEmittedExpressions(node);
|
|
436
|
+
if (!(node instanceof CallExpression))
|
|
437
|
+
return false;
|
|
438
|
+
const callee = skipPartiallyEmittedExpressions(node.expression);
|
|
439
|
+
return callee.kind === 219 /* SyntaxKind.FunctionExpression */ || callee.kind === 220 /* SyntaxKind.ArrowFunction */;
|
|
440
|
+
}
|
|
441
|
+
export function getOperatorOfPrefixOperand(node) {
|
|
442
|
+
return node instanceof PrefixUnaryExpression ? node.operator : 0 /* SyntaxKind.Unknown */;
|
|
443
|
+
}
|
|
444
|
+
const hexDigits = '0123456789ABCDEF';
|
|
445
|
+
function hex(code) {
|
|
446
|
+
let s = '';
|
|
447
|
+
do {
|
|
448
|
+
s = hexDigits.charAt(code & 15) + s;
|
|
449
|
+
code = code >>> 4;
|
|
450
|
+
} while (code > 0);
|
|
451
|
+
return s;
|
|
452
|
+
}
|
|
453
|
+
function utf16Escape(code) {
|
|
454
|
+
const digits = hex(code);
|
|
455
|
+
return '\\u' + '0000'.substring(digits.length) + digits;
|
|
456
|
+
}
|
|
457
|
+
function escapedChar(ch) {
|
|
458
|
+
switch (ch) {
|
|
459
|
+
case 9 /* CharacterCodes.tab */:
|
|
460
|
+
return '\\t';
|
|
461
|
+
case 11 /* CharacterCodes.verticalTab */:
|
|
462
|
+
return '\\v';
|
|
463
|
+
case 12 /* CharacterCodes.formFeed */:
|
|
464
|
+
return '\\f';
|
|
465
|
+
case 8 /* CharacterCodes.backspace */:
|
|
466
|
+
return '\\b';
|
|
467
|
+
case 13 /* CharacterCodes.carriageReturn */:
|
|
468
|
+
return '\\r';
|
|
469
|
+
case 10 /* CharacterCodes.lineFeed */:
|
|
470
|
+
return '\\n';
|
|
471
|
+
case 92 /* CharacterCodes.backslash */:
|
|
472
|
+
return '\\\\';
|
|
473
|
+
case 34 /* CharacterCodes.doubleQuote */:
|
|
474
|
+
return '\\"';
|
|
475
|
+
case 39 /* CharacterCodes.singleQuote */:
|
|
476
|
+
return "\\'";
|
|
477
|
+
case 96 /* CharacterCodes.backtick */:
|
|
478
|
+
return '\\`';
|
|
479
|
+
case 36 /* CharacterCodes.$ */:
|
|
480
|
+
return '\\$';
|
|
481
|
+
case 8232 /* CharacterCodes.lineSeparator */:
|
|
482
|
+
return '\\u2028';
|
|
483
|
+
case 8233 /* CharacterCodes.paragraphSeparator */:
|
|
484
|
+
return '\\u2029';
|
|
485
|
+
case 133 /* CharacterCodes.nextLine */:
|
|
486
|
+
return '\\u0085';
|
|
487
|
+
}
|
|
488
|
+
return utf16Escape(ch);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Escapes `s` for a literal quoted with `quote`, as ECMA-262's QuoteJSONString plus LS, PS
|
|
492
|
+
* and NEL; non-ASCII characters too unless `NeverAsciiEscape` is set. Doesn't add quotes.
|
|
493
|
+
*/
|
|
494
|
+
export function escapeString(s, quote, flags) {
|
|
495
|
+
let out = '';
|
|
496
|
+
let start = 0;
|
|
497
|
+
const length = s.length;
|
|
498
|
+
for (let i = 0; i < length;) {
|
|
499
|
+
let ch = s.charCodeAt(i);
|
|
500
|
+
let size = 1;
|
|
501
|
+
if (ch >= 0xd800 && ch <= 0xdbff && i + 1 < length) {
|
|
502
|
+
const low = s.charCodeAt(i + 1);
|
|
503
|
+
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
504
|
+
ch = (ch - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
|
|
505
|
+
size = 2;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
let escape = ch >= 0xd800 && ch <= 0xdfff;
|
|
509
|
+
switch (ch) {
|
|
510
|
+
case 92 /* CharacterCodes.backslash */:
|
|
511
|
+
if ((flags & 2 /* LiteralTextFlags.JsxAttributeEscape */) === 0)
|
|
512
|
+
escape = true;
|
|
513
|
+
break;
|
|
514
|
+
case 36 /* CharacterCodes.$ */:
|
|
515
|
+
if (quote === 96 /* CharacterCodes.backtick */ && i + 1 < length && s.charCodeAt(i + 1) === 123 /* CharacterCodes.openBrace */)
|
|
516
|
+
escape = true;
|
|
517
|
+
break;
|
|
518
|
+
case 8232 /* CharacterCodes.lineSeparator */:
|
|
519
|
+
case 8233 /* CharacterCodes.paragraphSeparator */:
|
|
520
|
+
case 133 /* CharacterCodes.nextLine */:
|
|
521
|
+
case 13 /* CharacterCodes.carriageReturn */:
|
|
522
|
+
escape = true;
|
|
523
|
+
break;
|
|
524
|
+
case 10 /* CharacterCodes.lineFeed */:
|
|
525
|
+
if (quote !== 96 /* CharacterCodes.backtick */)
|
|
526
|
+
escape = true;
|
|
527
|
+
break;
|
|
528
|
+
default:
|
|
529
|
+
if (ch === quote || ch <= 0x1f || ((flags & 1 /* LiteralTextFlags.NeverAsciiEscape */) === 0 && ch > 0x7f))
|
|
530
|
+
escape = true;
|
|
531
|
+
}
|
|
532
|
+
if (escape) {
|
|
533
|
+
if (start < i)
|
|
534
|
+
out += s.substring(start, i);
|
|
535
|
+
if ((flags & 2 /* LiteralTextFlags.JsxAttributeEscape */) !== 0) {
|
|
536
|
+
if (ch === 0)
|
|
537
|
+
out += '�';
|
|
538
|
+
else if (ch === 34 /* CharacterCodes.doubleQuote */)
|
|
539
|
+
out += '"';
|
|
540
|
+
else if (ch === 39 /* CharacterCodes.singleQuote */)
|
|
541
|
+
out += ''';
|
|
542
|
+
else
|
|
543
|
+
out += '&#x' + hex(ch) + ';';
|
|
544
|
+
}
|
|
545
|
+
else if (ch === 13 /* CharacterCodes.carriageReturn */ &&
|
|
546
|
+
quote === 96 /* CharacterCodes.backtick */ &&
|
|
547
|
+
i + 1 < length &&
|
|
548
|
+
s.charCodeAt(i + 1) === 10 /* CharacterCodes.lineFeed */) {
|
|
549
|
+
size++;
|
|
550
|
+
out += '\\r\\n';
|
|
551
|
+
}
|
|
552
|
+
else if (ch > 0xffff) {
|
|
553
|
+
const c = ch - 0x10000;
|
|
554
|
+
out += utf16Escape((c >> 10) + 0xd800) + utf16Escape((c & 0x3ff) + 0xdc00);
|
|
555
|
+
}
|
|
556
|
+
else if (ch === 0) {
|
|
557
|
+
out += i + 1 < length && isDigit(s.charCodeAt(i + 1)) ? '\\x00' : '\\0';
|
|
558
|
+
}
|
|
559
|
+
else
|
|
560
|
+
out += escapedChar(ch);
|
|
561
|
+
start = i + size;
|
|
562
|
+
}
|
|
563
|
+
i += size;
|
|
564
|
+
}
|
|
565
|
+
if (start === 0)
|
|
566
|
+
return s;
|
|
567
|
+
if (start < length)
|
|
568
|
+
out += s.substring(start);
|
|
569
|
+
return out;
|
|
570
|
+
}
|
|
571
|
+
function canUseOriginalText(node, flags) {
|
|
572
|
+
if (nodeIsSynthesized(node) ||
|
|
573
|
+
node.parent === undefined ||
|
|
574
|
+
((flags & 4 /* LiteralTextFlags.TerminateUnterminatedLiterals */) !== 0 && isUnterminatedLiteral(node)))
|
|
575
|
+
return false;
|
|
576
|
+
if (node instanceof NumericLiteral) {
|
|
577
|
+
if ((node.tokenFlags & 26656 /* TokenFlags.IsInvalid */) !== 0)
|
|
578
|
+
return false;
|
|
579
|
+
if ((node.tokenFlags & 512 /* TokenFlags.ContainsSeparator */) !== 0)
|
|
580
|
+
return (flags & 8 /* LiteralTextFlags.AllowNumericSeparator */) !== 0;
|
|
581
|
+
}
|
|
582
|
+
return node.kind !== 9 /* SyntaxKind.BigIntLiteral */;
|
|
583
|
+
}
|
|
584
|
+
function templateText(open, text, rawText, close, flags) {
|
|
585
|
+
if (rawText.length > 0 || text.length === 0)
|
|
586
|
+
return open + rawText + close;
|
|
587
|
+
return open + escapeString(text, 96 /* CharacterCodes.backtick */, flags) + close;
|
|
588
|
+
}
|
|
589
|
+
/** The text of a literal as written, or its canonical (escaped, quoted) form for synthesized literals. */
|
|
590
|
+
export function getLiteralText(node, sourceText, flags) {
|
|
591
|
+
if (sourceText !== undefined && canUseOriginalText(node, flags))
|
|
592
|
+
return getSourceTextOfNode(sourceText, node);
|
|
593
|
+
if (node instanceof StringLiteral) {
|
|
594
|
+
const quote = (node.tokenFlags & 65536 /* TokenFlags.SingleQuote */) !== 0 ? 39 /* CharacterCodes.singleQuote */ : 34 /* CharacterCodes.doubleQuote */;
|
|
595
|
+
const q = quote === 39 /* CharacterCodes.singleQuote */ ? "'" : '"';
|
|
596
|
+
return q + escapeString(node.text, quote, flags) + q;
|
|
597
|
+
}
|
|
598
|
+
if (node instanceof NoSubstitutionTemplateLiteral)
|
|
599
|
+
return templateText('`', node.text, '', '`', flags);
|
|
600
|
+
if (node instanceof TemplateHead)
|
|
601
|
+
return templateText('`', node.text, node.rawText, '${', flags);
|
|
602
|
+
if (node instanceof TemplateMiddle)
|
|
603
|
+
return templateText('}', node.text, node.rawText, '${', flags);
|
|
604
|
+
if (node instanceof TemplateTail)
|
|
605
|
+
return templateText('}', node.text, node.rawText, '`', flags);
|
|
606
|
+
if (node instanceof NumericLiteral)
|
|
607
|
+
return node.text;
|
|
608
|
+
if (node instanceof BigIntLiteral)
|
|
609
|
+
return node.text;
|
|
610
|
+
if (node instanceof RegularExpressionLiteral) {
|
|
611
|
+
const text = node.text;
|
|
612
|
+
if ((flags & 4 /* LiteralTextFlags.TerminateUnterminatedLiterals */) !== 0 && isUnterminatedLiteral(node))
|
|
613
|
+
return text.length > 0 && text.charCodeAt(text.length - 1) === 92 /* CharacterCodes.backslash */
|
|
614
|
+
? text + ' /'
|
|
615
|
+
: text + '/';
|
|
616
|
+
return text;
|
|
617
|
+
}
|
|
618
|
+
throw new Error('Unsupported literal');
|
|
619
|
+
}
|
|
620
|
+
/** The source text of a node without leading trivia, as tsgo's GetSourceTextOfNodeFromSourceFile. */
|
|
621
|
+
export function getSourceTextOfNode(sourceText, node) {
|
|
622
|
+
if (node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFile */)
|
|
623
|
+
return '';
|
|
624
|
+
const text = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
|
625
|
+
if ((node.flags & 268435456 /* NodeFlags.ReparserTransformedLiteral */) !== 0) {
|
|
626
|
+
if (node instanceof StringLiteral)
|
|
627
|
+
return (node.tokenFlags & 65536 /* TokenFlags.SingleQuote */) !== 0 ? "'" + text + "'" : '"' + text + '"';
|
|
628
|
+
return getTextOfIdentifierLike(node);
|
|
629
|
+
}
|
|
630
|
+
return text;
|
|
631
|
+
}
|
|
632
|
+
function getTextOfIdentifierLike(node) {
|
|
633
|
+
if (node instanceof Identifier)
|
|
634
|
+
return node.text;
|
|
635
|
+
if (node instanceof PrivateIdentifier)
|
|
636
|
+
return node.text;
|
|
637
|
+
throw new Error('Unexpected reparser-transformed node kind');
|
|
638
|
+
}
|
|
639
|
+
// Lines
|
|
640
|
+
/** Go's `strings.TrimSpace`: trims Unicode White_Space. */
|
|
641
|
+
export function trimUnicodeSpace(text, start, end) {
|
|
642
|
+
while (start < end && isUnicodeWhiteSpace(text.charCodeAt(start)))
|
|
643
|
+
start++;
|
|
644
|
+
while (end > start && isUnicodeWhiteSpace(text.charCodeAt(end - 1)))
|
|
645
|
+
end--;
|
|
646
|
+
return text.substring(start, end);
|
|
647
|
+
}
|
|
648
|
+
/** The zero-based line of `pos`, searching from line `low`. */
|
|
649
|
+
function lineOfPosition(lineStarts, pos, low) {
|
|
650
|
+
let high = lineStarts.length - 1;
|
|
651
|
+
while (low <= high) {
|
|
652
|
+
const middle = low + ((high - low) >> 1);
|
|
653
|
+
const value = lineStarts[middle] | 0;
|
|
654
|
+
if (value < pos)
|
|
655
|
+
low = middle + 1;
|
|
656
|
+
else if (value > pos)
|
|
657
|
+
high = middle - 1;
|
|
658
|
+
else
|
|
659
|
+
return middle;
|
|
660
|
+
}
|
|
661
|
+
return low - 1;
|
|
662
|
+
}
|
|
663
|
+
export function getLinesBetweenPositions(lineStarts, pos1, pos2) {
|
|
664
|
+
if (pos1 === pos2)
|
|
665
|
+
return 0;
|
|
666
|
+
const negative = pos2 < pos1;
|
|
667
|
+
const lower = negative ? pos2 : pos1;
|
|
668
|
+
const upper = negative ? pos1 : pos2;
|
|
669
|
+
const lowerLine = computeLineOfPosition(lineStarts, lower);
|
|
670
|
+
const upperLine = lineOfPosition(lineStarts, upper, lowerLine < 0 ? 0 : lowerLine);
|
|
671
|
+
return negative ? lowerLine - upperLine : upperLine - lowerLine;
|
|
672
|
+
}
|
|
673
|
+
export function getStartPositionOfRange(text, pos, includeComments) {
|
|
674
|
+
if (pos < 0)
|
|
675
|
+
return -1;
|
|
676
|
+
return skipTrivia(text, pos, false, includeComments);
|
|
677
|
+
}
|
|
678
|
+
export function getPreviousNonWhitespacePosition(text, pos, stopPos) {
|
|
679
|
+
for (; pos >= stopPos; pos--)
|
|
680
|
+
if (!isWhiteSpaceLike(text.charCodeAt(pos)))
|
|
681
|
+
return pos;
|
|
682
|
+
return -1;
|
|
683
|
+
}
|
|
684
|
+
/** Columns of leading whitespace in `text[pos:end]`, with tabs to the next multiple of 4. */
|
|
685
|
+
export function calculateIndent(text, pos, end) {
|
|
686
|
+
let indent = 0;
|
|
687
|
+
for (; pos < end; pos++) {
|
|
688
|
+
const ch = text.charCodeAt(pos);
|
|
689
|
+
if (!isWhiteSpaceSingleLine(ch))
|
|
690
|
+
break;
|
|
691
|
+
if (ch === 9 /* CharacterCodes.tab */)
|
|
692
|
+
indent += 4 - (indent & 3);
|
|
693
|
+
else
|
|
694
|
+
indent++;
|
|
695
|
+
}
|
|
696
|
+
return indent;
|
|
697
|
+
}
|
|
698
|
+
export function isLineBreakChar(ch) {
|
|
699
|
+
return isLineBreak(ch);
|
|
700
|
+
}
|
|
701
|
+
// Comments
|
|
702
|
+
export function isJSDocLikeText(text, comment) {
|
|
703
|
+
return (comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ &&
|
|
704
|
+
comment.end - comment.pos >= 5 &&
|
|
705
|
+
text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ &&
|
|
706
|
+
text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */);
|
|
707
|
+
}
|
|
708
|
+
export function isPinnedComment(text, comment) {
|
|
709
|
+
return (comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ &&
|
|
710
|
+
comment.end - comment.pos > 5 &&
|
|
711
|
+
text.charCodeAt(comment.pos + 2) === 33 /* CharacterCodes.exclamation */);
|
|
712
|
+
}
|
|
713
|
+
function skipWhiteSpaceSingleLine(text, pos) {
|
|
714
|
+
while (pos < text.length && isWhiteSpaceSingleLine(text.charCodeAt(pos)))
|
|
715
|
+
pos++;
|
|
716
|
+
return pos;
|
|
717
|
+
}
|
|
718
|
+
function skipQuotedString(text, pos) {
|
|
719
|
+
const quote = text.charCodeAt(pos);
|
|
720
|
+
if (quote !== 39 /* CharacterCodes.singleQuote */ && quote !== 34 /* CharacterCodes.doubleQuote */)
|
|
721
|
+
return -1;
|
|
722
|
+
const close = text.indexOf(quote === 39 /* CharacterCodes.singleQuote */ ? "'" : '"', pos + 1);
|
|
723
|
+
return close < 0 ? -1 : close + 1;
|
|
724
|
+
}
|
|
725
|
+
function skipAttribute(text, pos, names) {
|
|
726
|
+
const next = skipWhiteSpaceSingleLine(text, pos);
|
|
727
|
+
if (next === pos)
|
|
728
|
+
return -1;
|
|
729
|
+
pos = next;
|
|
730
|
+
let matched = false;
|
|
731
|
+
for (const name of names) {
|
|
732
|
+
if (text.startsWith(name, pos)) {
|
|
733
|
+
pos += name.length;
|
|
734
|
+
matched = true;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (!matched)
|
|
739
|
+
return -1;
|
|
740
|
+
pos = skipWhiteSpaceSingleLine(text, pos);
|
|
741
|
+
if (text.charCodeAt(pos) !== 61 /* CharacterCodes.equals */)
|
|
742
|
+
return -1;
|
|
743
|
+
return skipQuotedString(text, skipWhiteSpaceSingleLine(text, pos + 1));
|
|
744
|
+
}
|
|
745
|
+
const referenceAttributes = ['path', 'types', 'lib', 'no-default-lib'];
|
|
746
|
+
const amdDependencyAttributes = ['path'];
|
|
747
|
+
/** `/// <reference …/>`, `/// <amd-dependency path="…"/>` and `/// <amd-module/>` comments. */
|
|
748
|
+
export function isRecognizedTripleSlashComment(sourceText, comment) {
|
|
749
|
+
if (comment.kind !== 2 /* SyntaxKind.SingleLineCommentTrivia */ ||
|
|
750
|
+
comment.end - comment.pos <= 2 ||
|
|
751
|
+
sourceText.charCodeAt(comment.pos + 1) !== 47 /* CharacterCodes.slash */ ||
|
|
752
|
+
sourceText.charCodeAt(comment.pos + 2) !== 47 /* CharacterCodes.slash */)
|
|
753
|
+
return false;
|
|
754
|
+
const text = sourceText.substring(comment.pos + 3, comment.end);
|
|
755
|
+
let pos = skipWhiteSpaceSingleLine(text, 0);
|
|
756
|
+
if (text.charCodeAt(pos) !== 60 /* CharacterCodes.lessThan */)
|
|
757
|
+
return false;
|
|
758
|
+
pos++;
|
|
759
|
+
if (text.startsWith('reference', pos))
|
|
760
|
+
pos = skipAttribute(text, pos + 9, referenceAttributes);
|
|
761
|
+
else if (text.startsWith('amd-dependency', pos))
|
|
762
|
+
pos = skipAttribute(text, pos + 14, amdDependencyAttributes);
|
|
763
|
+
else if (text.startsWith('amd-module', pos))
|
|
764
|
+
pos = skipWhiteSpaceSingleLine(text, pos + 10);
|
|
765
|
+
else
|
|
766
|
+
return false;
|
|
767
|
+
return pos >= 0 && text.indexOf('/>', pos) >= 0;
|
|
768
|
+
}
|
|
769
|
+
// Names
|
|
770
|
+
export function formatGeneratedName(privateName, prefix, base, suffix) {
|
|
771
|
+
const name = removeLeadingHash(prefix) + removeLeadingHash(base) + removeLeadingHash(suffix);
|
|
772
|
+
return privateName ? ensureLeadingHash(name) : name;
|
|
773
|
+
}
|
|
774
|
+
export function removeLeadingHash(text) {
|
|
775
|
+
return text.length > 0 && text.charCodeAt(0) === 35 /* CharacterCodes.hash */ ? text.substring(1) : text;
|
|
776
|
+
}
|
|
777
|
+
export function ensureLeadingHash(text) {
|
|
778
|
+
return text.length > 0 && text.charCodeAt(0) === 35 /* CharacterCodes.hash */ ? text : '#' + text;
|
|
779
|
+
}
|
|
780
|
+
function isASCIIWordCharacter(ch) {
|
|
781
|
+
return ((ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) ||
|
|
782
|
+
(ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) ||
|
|
783
|
+
isDigit(ch) ||
|
|
784
|
+
ch === 95 /* CharacterCodes._ */);
|
|
785
|
+
}
|
|
786
|
+
/** An identifier for a module's base name, e.g. `foo_bar` for `./foo-bar`; one `_` per UTF-8 byte of other characters. */
|
|
787
|
+
export function makeIdentifierFromModuleName(moduleName) {
|
|
788
|
+
moduleName = getBaseFileName(moduleName);
|
|
789
|
+
let out = '';
|
|
790
|
+
let start = 0;
|
|
791
|
+
for (let pos = 0; pos < moduleName.length; pos++) {
|
|
792
|
+
const ch = moduleName.charCodeAt(pos);
|
|
793
|
+
if (pos === 0 && isDigit(ch))
|
|
794
|
+
out += '_';
|
|
795
|
+
else if (!isASCIIWordCharacter(ch)) {
|
|
796
|
+
if (start < pos)
|
|
797
|
+
out += moduleName.substring(start, pos);
|
|
798
|
+
if (ch < 0x80)
|
|
799
|
+
out += '_';
|
|
800
|
+
else if (ch < 0x800)
|
|
801
|
+
out += '__';
|
|
802
|
+
else if (ch >= 0xd800 && ch <= 0xdbff && pos + 1 < moduleName.length) {
|
|
803
|
+
out += '____';
|
|
804
|
+
pos++;
|
|
805
|
+
}
|
|
806
|
+
else
|
|
807
|
+
out += '___';
|
|
808
|
+
start = pos + 1;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (start < moduleName.length)
|
|
812
|
+
out += moduleName.substring(start);
|
|
813
|
+
return out;
|
|
814
|
+
}
|
|
815
|
+
export function lineOf(lineStarts, pos) {
|
|
816
|
+
return computeLineOfPosition(lineStarts, pos);
|
|
817
|
+
}
|