tsc-ts 0.0.9 → 0.1.0
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 +2 -2
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +22 -15
- package/dist/api/compiler/ast.js +1026 -995
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +178 -124
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +134 -90
- package/dist/api/compiler/checker-contextual.js +64 -61
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +244 -211
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +472 -440
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -107
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +105 -88
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +212 -75
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +145 -36
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +104 -31
- package/dist/api/compiler/checker.js +181 -33
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +42 -3
- package/dist/api/compiler/compile-program.js +139 -27
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.d.ts +22 -0
- package/dist/api/compiler/diagnostics.js +93 -11
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +21 -1
- package/dist/api/compiler/file-loader.js +201 -48
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +23 -23
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parallel-parse.d.ts +3 -2
- package/dist/api/compiler/parallel-parse.js +17 -5
- package/dist/api/compiler/parser.d.ts +40 -19
- package/dist/api/compiler/parser.js +308 -216
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +5 -1
- package/dist/api/compiler/printer/emit-context.js +20 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +3 -1
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +49 -2
- package/dist/api/compiler/printer/printer.js +539 -293
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +12 -2
- package/dist/api/compiler/program-checker.js +88 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +4 -6
- package/dist/api/compiler/program.js +74 -87
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +347 -180
- package/dist/api/compiler/reparser.js +60 -56
- package/dist/api/compiler/scanner.d.ts +19 -2
- package/dist/api/compiler/scanner.js +123 -108
- package/dist/api/compiler/shared-results.d.ts +463 -0
- package/dist/api/compiler/shared-results.js +2128 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +23 -14
- package/dist/api/compiler/symbol.js +23 -11
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +305 -238
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +58 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +79 -9
- package/src/compiler/checker-classes.ts +78 -24
- package/src/compiler/checker-contextual.ts +6 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +79 -46
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +136 -62
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -82
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +26 -4
- package/src/compiler/checker-members.ts +200 -56
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +124 -23
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +203 -39
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +167 -27
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/diagnostics.ts +84 -3
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +197 -38
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +165 -30
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +3 -1
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +326 -52
- package/src/compiler/parallel-emit.ts +320 -0
- package/src/compiler/parallel-parse.ts +16 -5
- package/src/compiler/parse-thread.ts +3 -0
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +21 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +4 -1
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +266 -30
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +57 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +18 -26
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +240 -77
- package/src/compiler/reparser.ts +7 -2
- package/src/compiler/scanner.ts +109 -79
- package/src/compiler/shared-results.ts +2414 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +46 -24
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +64 -4
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +134 -48
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +66 -9
- package/src/compiler/tsc-cli.ts +7 -0
- package/src/compiler/tsc-compile.ts +284 -4
- package/src/compiler/tsc-watch.ts +74 -45
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -39,6 +39,8 @@ export class PrinterOptions {
|
|
|
39
39
|
this.terminateUnterminatedLiterals = false;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
/** The saved emit flags of a node whose comments were not looked for (`Printer.inCommentFreeRange`). */
|
|
43
|
+
const commentFreeNode = -1;
|
|
42
44
|
export class Printer extends NameGeneratorHost {
|
|
43
45
|
options;
|
|
44
46
|
context;
|
|
@@ -50,6 +52,13 @@ export class Printer extends NameGeneratorHost {
|
|
|
50
52
|
currentSourceFile;
|
|
51
53
|
sourceText;
|
|
52
54
|
lineStarts;
|
|
55
|
+
/**
|
|
56
|
+
* The line of the last `lineOf` lookup, `lookupLine`, and the positions it spans, `[lookupLineStart, lookupLineEnd)`,
|
|
57
|
+
* with `lookupLineEnd` -1 after the last line: printing reads positions mostly in order, so most lookups fall on that line.
|
|
58
|
+
*/
|
|
59
|
+
lookupLine;
|
|
60
|
+
lookupLineStart;
|
|
61
|
+
lookupLineEnd;
|
|
53
62
|
writer;
|
|
54
63
|
ownWriter;
|
|
55
64
|
uniqueHelperNames;
|
|
@@ -63,8 +72,25 @@ export class Printer extends NameGeneratorHost {
|
|
|
63
72
|
commentsDisabled;
|
|
64
73
|
/** Emitting the `extends` clause of a conditional or infer type. */
|
|
65
74
|
inExtends;
|
|
66
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Saved comment state, 32-bit values: emit flags, comment pos, comment end, container pos, container end,
|
|
77
|
+
* declaration list end.
|
|
78
|
+
* Flags are `commentFreeNode` for a node that `emitCommentsBeforeNode` handled in a comment-free range.
|
|
79
|
+
*/
|
|
67
80
|
commentStack;
|
|
81
|
+
/** The used length of `commentStack`: entries are written in place and kept for reuse once popped. */
|
|
82
|
+
commentDepth;
|
|
83
|
+
/** Start positions of `//` and `/*` in `sourceText`, ascending; made on first use for each file. */
|
|
84
|
+
commentStarts;
|
|
85
|
+
/**
|
|
86
|
+
* A range of `sourceText`, `[freeStart, freeEnd)`, where no comment starts and the last character is not trivia,
|
|
87
|
+
* so no comment is found from any position in it; -1 when there is none. `freeOwner` is the node it was made for.
|
|
88
|
+
*/
|
|
89
|
+
freeStart;
|
|
90
|
+
freeEnd;
|
|
91
|
+
/** Whether no trailing comment follows `freeEnd`. */
|
|
92
|
+
freeEndTrailingNone;
|
|
93
|
+
freeOwner;
|
|
68
94
|
/** Saved source map state: emit flags, pos, end, has token range. */
|
|
69
95
|
sourceMapStack;
|
|
70
96
|
/** The token position after `enterToken` skipped trivia. */
|
|
@@ -94,6 +120,9 @@ export class Printer extends NameGeneratorHost {
|
|
|
94
120
|
this.currentSourceFile = undefined;
|
|
95
121
|
this.sourceText = '';
|
|
96
122
|
this.lineStarts = [];
|
|
123
|
+
this.lookupLine = -1;
|
|
124
|
+
this.lookupLineStart = 0;
|
|
125
|
+
this.lookupLineEnd = 0;
|
|
97
126
|
this.writer = new TextWriter(options.newLine, 4);
|
|
98
127
|
this.ownWriter = undefined;
|
|
99
128
|
this.uniqueHelperNames = undefined;
|
|
@@ -105,7 +134,13 @@ export class Printer extends NameGeneratorHost {
|
|
|
105
134
|
this.detachedComments = [];
|
|
106
135
|
this.commentsDisabled = options.removeComments;
|
|
107
136
|
this.inExtends = false;
|
|
108
|
-
this.commentStack =
|
|
137
|
+
this.commentStack = new Int32Array(96);
|
|
138
|
+
this.commentDepth = 0;
|
|
139
|
+
this.commentStarts = undefined;
|
|
140
|
+
this.freeStart = -1;
|
|
141
|
+
this.freeEnd = -1;
|
|
142
|
+
this.freeEndTrailingNone = false;
|
|
143
|
+
this.freeOwner = undefined;
|
|
109
144
|
this.sourceMapStack = [];
|
|
110
145
|
this.tokenPos = 0;
|
|
111
146
|
this.sourceMapsDisabled = true;
|
|
@@ -150,6 +185,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
150
185
|
this.currentSourceFile = sourceFile;
|
|
151
186
|
this.sourceText = sourceFile === undefined ? '' : sourceFile.text;
|
|
152
187
|
this.lineStarts = sourceFile === undefined ? [] : sourceFile.lineStarts();
|
|
188
|
+
this.lookupLine = -1;
|
|
189
|
+
this.lookupLineStart = 0;
|
|
190
|
+
this.lookupLineEnd = 0;
|
|
191
|
+
this.commentStarts = undefined;
|
|
192
|
+
this.endCommentFreeRange();
|
|
153
193
|
return true;
|
|
154
194
|
}
|
|
155
195
|
/** Prints `node` into `writer`, adding mappings to `sourceMapGenerator` if given. */
|
|
@@ -187,7 +227,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
187
227
|
// Text of nodes
|
|
188
228
|
isFileLevelUniqueName(name) {
|
|
189
229
|
const file = this.currentSourceFile;
|
|
190
|
-
|
|
230
|
+
// The names of the source file as parsed, not as transformed.
|
|
231
|
+
return file === undefined || isFileLevelUniqueName(this.context.mostOriginal(file), name);
|
|
191
232
|
}
|
|
192
233
|
getLiteralTextOfNode(node, sourceFile, flags) {
|
|
193
234
|
if (node instanceof StringLiteral) {
|
|
@@ -233,7 +274,10 @@ export class Printer extends NameGeneratorHost {
|
|
|
233
274
|
switch (node.kind) {
|
|
234
275
|
case 79 /* SyntaxKind.Identifier */:
|
|
235
276
|
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
236
|
-
case
|
|
277
|
+
case 297 /* SyntaxKind.JsxNamespacedName */:
|
|
278
|
+
// Its text either way: the source text, or the text of a node from elsewhere.
|
|
279
|
+
if (this.textIsSourceText(node))
|
|
280
|
+
return node.text;
|
|
237
281
|
if (!canUseSourceFile || !this.isInCurrentSourceFile(node)) {
|
|
238
282
|
if (node instanceof Identifier)
|
|
239
283
|
return node.text;
|
|
@@ -256,6 +300,39 @@ export class Printer extends NameGeneratorHost {
|
|
|
256
300
|
}
|
|
257
301
|
return getSourceTextOfNode(this.sourceText, node);
|
|
258
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Whether the source text of an identifier or private identifier of the current file, from the end of its leading
|
|
305
|
+
* trivia to its end, is its text: the text ends the node, and the character before it is not part of the token, as
|
|
306
|
+
* it would be in an identifier written with escapes. Nodes from JSDoc may span other text, so they are left to the
|
|
307
|
+
* general path.
|
|
308
|
+
*/
|
|
309
|
+
textIsSourceText(node) {
|
|
310
|
+
if (!(node instanceof Identifier) && !(node instanceof PrivateIdentifier))
|
|
311
|
+
return false;
|
|
312
|
+
if ((node.flags & (8 /* NodeFlags.Reparsed */ | 4194304 /* NodeFlags.JSDoc */ | 268435456 /* NodeFlags.ReparserTransformedLiteral */)) !== 0)
|
|
313
|
+
return false;
|
|
314
|
+
const text = node.text;
|
|
315
|
+
const source = this.sourceText;
|
|
316
|
+
const end = node.end;
|
|
317
|
+
const start = end - text.length;
|
|
318
|
+
if (text.length === 0 || start < node.pos || end > source.length)
|
|
319
|
+
return false;
|
|
320
|
+
if (!source.startsWith(text, start))
|
|
321
|
+
return false;
|
|
322
|
+
if (start === node.pos)
|
|
323
|
+
return true;
|
|
324
|
+
const before = source.charCodeAt(start - 1);
|
|
325
|
+
return !((before >= 97 /* CharacterCodes.a */ && before <= 122 /* CharacterCodes.z */) ||
|
|
326
|
+
(before >= 65 /* CharacterCodes.A */ && before <= 90 /* CharacterCodes.Z */) ||
|
|
327
|
+
(before >= 48 /* CharacterCodes._0 */ && before <= 57 /* CharacterCodes._9 */) ||
|
|
328
|
+
before === 95 /* CharacterCodes._ */ ||
|
|
329
|
+
before === 36 /* CharacterCodes.$ */ ||
|
|
330
|
+
before === 92 /* CharacterCodes.backslash */ ||
|
|
331
|
+
before === 123 /* CharacterCodes.openBrace */ ||
|
|
332
|
+
before === 125 /* CharacterCodes.closeBrace */ ||
|
|
333
|
+
before === 35 /* CharacterCodes.hash */ ||
|
|
334
|
+
before > 127 /* CharacterCodes.maxAsciiCharacter */);
|
|
335
|
+
}
|
|
259
336
|
isInCurrentSourceFile(node) {
|
|
260
337
|
const file = this.currentSourceFile;
|
|
261
338
|
if (file === undefined)
|
|
@@ -331,7 +408,28 @@ export class Printer extends NameGeneratorHost {
|
|
|
331
408
|
}
|
|
332
409
|
// Lines between nodes
|
|
333
410
|
positionsAreOnSameLine(pos1, pos2) {
|
|
334
|
-
|
|
411
|
+
if (pos1 === pos2)
|
|
412
|
+
return true;
|
|
413
|
+
const lower = pos1 < pos2 ? pos1 : pos2;
|
|
414
|
+
const upper = pos1 < pos2 ? pos2 : pos1;
|
|
415
|
+
// What getLinesBetweenPositions finds: no line starts in (lower, upper].
|
|
416
|
+
if (lower < 0) {
|
|
417
|
+
const first = this.lineStarts.length > 0 ? this.lineStarts[0] | 0 : -1;
|
|
418
|
+
return first < 0 || upper < first;
|
|
419
|
+
}
|
|
420
|
+
this.lineOf(lower);
|
|
421
|
+
return this.lookupLineEnd < 0 || upper < this.lookupLineEnd;
|
|
422
|
+
}
|
|
423
|
+
/** The zero-based line of `pos` (-1 before the first line), which becomes the line of the last lookup. */
|
|
424
|
+
lineOf(pos) {
|
|
425
|
+
if (pos >= this.lookupLineStart && (pos < this.lookupLineEnd || this.lookupLineEnd < 0) && this.lookupLine >= 0)
|
|
426
|
+
return this.lookupLine;
|
|
427
|
+
const starts = this.lineStarts;
|
|
428
|
+
const line = computeLineOfPosition(starts, pos);
|
|
429
|
+
this.lookupLine = line;
|
|
430
|
+
this.lookupLineStart = line >= 0 ? starts[line] | 0 : 0;
|
|
431
|
+
this.lookupLineEnd = line + 1 < starts.length ? starts[line + 1] | 0 : -1;
|
|
432
|
+
return line;
|
|
335
433
|
}
|
|
336
434
|
rangeStart(pos) {
|
|
337
435
|
return getStartPositionOfRange(this.sourceText, pos, false);
|
|
@@ -517,7 +615,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
517
615
|
}
|
|
518
616
|
// Emit flags
|
|
519
617
|
shouldEmitComments(node) {
|
|
520
|
-
return !this.commentsDisabled && this.currentSourceFile !== undefined && node.kind !==
|
|
618
|
+
return !this.commentsDisabled && this.currentSourceFile !== undefined && node.kind !== 308 /* SyntaxKind.SourceFile */;
|
|
521
619
|
}
|
|
522
620
|
shouldWriteComment(comment) {
|
|
523
621
|
return (!this.options.onlyPrintJSDocStyle ||
|
|
@@ -561,13 +659,13 @@ export class Printer extends NameGeneratorHost {
|
|
|
561
659
|
shouldEmitSourceMaps(node) {
|
|
562
660
|
return (!this.sourceMapsDisabled &&
|
|
563
661
|
this.sourceMapSource !== undefined &&
|
|
564
|
-
node.kind !==
|
|
662
|
+
node.kind !== 308 /* SyntaxKind.SourceFile */ &&
|
|
565
663
|
(node.flags & 33554432 /* NodeFlags.JsonFile */) === 0);
|
|
566
664
|
}
|
|
567
665
|
shouldAllowTrailingComma(node) {
|
|
568
666
|
return (this.currentSourceFile !== undefined &&
|
|
569
667
|
this.currentSourceFile.scriptKind !== 6 /* ScriptKind.JSON */ &&
|
|
570
|
-
node.kind ===
|
|
668
|
+
node.kind === 212 /* SyntaxKind.ObjectLiteralExpression */);
|
|
571
669
|
}
|
|
572
670
|
hasCommentsAtPosition(pos) {
|
|
573
671
|
if (this.currentSourceFile === undefined)
|
|
@@ -617,8 +715,13 @@ export class Printer extends NameGeneratorHost {
|
|
|
617
715
|
return true;
|
|
618
716
|
}
|
|
619
717
|
// Names
|
|
620
|
-
// Source text of names reparsed from JSDoc can span lines.
|
|
718
|
+
// Source text of names reparsed from JSDoc can span lines; an identifier's own source text has no line breaks.
|
|
621
719
|
emitIdentifierText(node) {
|
|
720
|
+
if (!this.context.autoGenerate.has(node) && this.textIsSourceText(node)) {
|
|
721
|
+
// writeText's answer for text without line breaks.
|
|
722
|
+
this.writer.write(node.text);
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
622
725
|
return this.writer.writeText(this.getTextOfNode(node));
|
|
623
726
|
}
|
|
624
727
|
emitIdentifierName(node) {
|
|
@@ -671,7 +774,10 @@ export class Printer extends NameGeneratorHost {
|
|
|
671
774
|
const state = this.enterNode(node);
|
|
672
775
|
this.emitEntityName(node.left);
|
|
673
776
|
this.write1('.');
|
|
674
|
-
|
|
777
|
+
if (node.right instanceof PrivateIdentifier)
|
|
778
|
+
this.emitPrivateIdentifier(node.right);
|
|
779
|
+
else
|
|
780
|
+
this.emitIdentifierName(node.right);
|
|
675
781
|
this.exitNode(node, state);
|
|
676
782
|
return true;
|
|
677
783
|
}
|
|
@@ -737,7 +843,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
737
843
|
let allModifiers = true;
|
|
738
844
|
let allDecorators = true;
|
|
739
845
|
for (const n of nodes) {
|
|
740
|
-
if (n.kind ===
|
|
846
|
+
if (n.kind === 172 /* SyntaxKind.Decorator */)
|
|
741
847
|
allModifiers = false;
|
|
742
848
|
else
|
|
743
849
|
allDecorators = false;
|
|
@@ -760,7 +866,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
760
866
|
let pos = 0;
|
|
761
867
|
while (start < nodes.length) {
|
|
762
868
|
while (pos < nodes.length) {
|
|
763
|
-
decorators = nodes[pos].kind ===
|
|
869
|
+
decorators = nodes[pos].kind === 172 /* SyntaxKind.Decorator */;
|
|
764
870
|
if (!haveMode) {
|
|
765
871
|
lastDecorators = decorators;
|
|
766
872
|
haveMode = true;
|
|
@@ -826,7 +932,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
826
932
|
emitTypeParameters(parent, nodes) {
|
|
827
933
|
if (nodes === undefined)
|
|
828
934
|
return false;
|
|
829
|
-
return this.emitList(2 /* ListItem.TypeParameter */, parent, nodes, 53776 /* ListFormat.TypeParameters */ | (parent.kind ===
|
|
935
|
+
return this.emitList(2 /* ListItem.TypeParameter */, parent, nodes, 53776 /* ListFormat.TypeParameters */ | (parent.kind === 221 /* SyntaxKind.ArrowFunction */ ? 64 /* ListFormat.AllowTrailingComma */ : 0));
|
|
830
936
|
}
|
|
831
937
|
emitTypeAnnotation(node) {
|
|
832
938
|
if (node === undefined)
|
|
@@ -1027,39 +1133,39 @@ export class Printer extends NameGeneratorHost {
|
|
|
1027
1133
|
}
|
|
1028
1134
|
emitClassElement(node) {
|
|
1029
1135
|
switch (node.kind) {
|
|
1030
|
-
case
|
|
1136
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
1031
1137
|
if (node instanceof PropertyDeclaration)
|
|
1032
1138
|
return this.emitPropertyDeclaration(node);
|
|
1033
1139
|
break;
|
|
1034
|
-
case
|
|
1140
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
1035
1141
|
if (node instanceof MethodDeclaration)
|
|
1036
1142
|
return this.emitMethodDeclaration(node);
|
|
1037
1143
|
break;
|
|
1038
|
-
case
|
|
1144
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
1039
1145
|
if (node instanceof ClassStaticBlockDeclaration)
|
|
1040
1146
|
return this.emitClassStaticBlockDeclaration(node);
|
|
1041
1147
|
break;
|
|
1042
|
-
case
|
|
1148
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
1043
1149
|
if (node instanceof ConstructorDeclaration)
|
|
1044
1150
|
return this.emitConstructor(node);
|
|
1045
1151
|
break;
|
|
1046
|
-
case
|
|
1152
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
1047
1153
|
if (node instanceof GetAccessorDeclaration)
|
|
1048
1154
|
return this.emitGetAccessor(node);
|
|
1049
1155
|
break;
|
|
1050
|
-
case
|
|
1156
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
1051
1157
|
if (node instanceof SetAccessorDeclaration)
|
|
1052
1158
|
return this.emitSetAccessor(node);
|
|
1053
1159
|
break;
|
|
1054
|
-
case
|
|
1160
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
1055
1161
|
if (node instanceof IndexSignatureDeclaration)
|
|
1056
1162
|
return this.emitIndexSignature(node);
|
|
1057
1163
|
break;
|
|
1058
|
-
case
|
|
1164
|
+
case 242 /* SyntaxKind.SemicolonClassElement */:
|
|
1059
1165
|
return this.emitSimpleNode(node, ';');
|
|
1060
|
-
case
|
|
1166
|
+
case 348 /* SyntaxKind.NotEmittedStatement */:
|
|
1061
1167
|
return this.emitSimpleNode(node, '');
|
|
1062
|
-
case
|
|
1168
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
1063
1169
|
if (node instanceof TypeAliasDeclaration)
|
|
1064
1170
|
return this.emitTypeAliasDeclaration(node);
|
|
1065
1171
|
break;
|
|
@@ -1068,62 +1174,62 @@ export class Printer extends NameGeneratorHost {
|
|
|
1068
1174
|
}
|
|
1069
1175
|
emitTypeElement(node) {
|
|
1070
1176
|
switch (node.kind) {
|
|
1071
|
-
case
|
|
1177
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
1072
1178
|
if (node instanceof PropertySignatureDeclaration)
|
|
1073
1179
|
return this.emitPropertySignature(node);
|
|
1074
1180
|
break;
|
|
1075
|
-
case
|
|
1181
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
1076
1182
|
if (node instanceof MethodSignatureDeclaration)
|
|
1077
1183
|
return this.emitMethodSignature(node);
|
|
1078
1184
|
break;
|
|
1079
|
-
case
|
|
1185
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
1080
1186
|
if (node instanceof CallSignatureDeclaration)
|
|
1081
1187
|
return this.emitCallSignature(node);
|
|
1082
1188
|
break;
|
|
1083
|
-
case
|
|
1189
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
1084
1190
|
if (node instanceof ConstructSignatureDeclaration)
|
|
1085
1191
|
return this.emitConstructSignature(node);
|
|
1086
1192
|
break;
|
|
1087
|
-
case
|
|
1193
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
1088
1194
|
if (node instanceof GetAccessorDeclaration)
|
|
1089
1195
|
return this.emitGetAccessor(node);
|
|
1090
1196
|
break;
|
|
1091
|
-
case
|
|
1197
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
1092
1198
|
if (node instanceof SetAccessorDeclaration)
|
|
1093
1199
|
return this.emitSetAccessor(node);
|
|
1094
1200
|
break;
|
|
1095
|
-
case
|
|
1201
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
1096
1202
|
if (node instanceof IndexSignatureDeclaration)
|
|
1097
1203
|
return this.emitIndexSignature(node);
|
|
1098
1204
|
break;
|
|
1099
|
-
case
|
|
1205
|
+
case 351 /* SyntaxKind.NotEmittedTypeElement */:
|
|
1100
1206
|
return this.emitSimpleNode(node, '');
|
|
1101
1207
|
}
|
|
1102
1208
|
throw new Error('Unexpected type element ' + node.kind);
|
|
1103
1209
|
}
|
|
1104
1210
|
emitObjectLiteralElement(node) {
|
|
1105
1211
|
switch (node.kind) {
|
|
1106
|
-
case
|
|
1212
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
1107
1213
|
if (node instanceof PropertyAssignment)
|
|
1108
1214
|
return this.emitPropertyAssignment(node);
|
|
1109
1215
|
break;
|
|
1110
|
-
case
|
|
1216
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
1111
1217
|
if (node instanceof ShorthandPropertyAssignment)
|
|
1112
1218
|
return this.emitShorthandPropertyAssignment(node);
|
|
1113
1219
|
break;
|
|
1114
|
-
case
|
|
1220
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
1115
1221
|
if (node instanceof SpreadAssignment)
|
|
1116
1222
|
return this.emitSpreadAssignment(node);
|
|
1117
1223
|
break;
|
|
1118
|
-
case
|
|
1224
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
1119
1225
|
if (node instanceof MethodDeclaration)
|
|
1120
1226
|
return this.emitMethodDeclaration(node);
|
|
1121
1227
|
break;
|
|
1122
|
-
case
|
|
1228
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
1123
1229
|
if (node instanceof GetAccessorDeclaration)
|
|
1124
1230
|
return this.emitGetAccessor(node);
|
|
1125
1231
|
break;
|
|
1126
|
-
case
|
|
1232
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
1127
1233
|
if (node instanceof SetAccessorDeclaration)
|
|
1128
1234
|
return this.emitSetAccessor(node);
|
|
1129
1235
|
break;
|
|
@@ -1214,7 +1320,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1214
1320
|
}
|
|
1215
1321
|
/** The operand of a postfix type; a parsed `typeof X` operand keeps no parentheses. */
|
|
1216
1322
|
emitPostfixTypeOperand(operand, parent) {
|
|
1217
|
-
if (isParseTreeNode(parent) && operand.kind ===
|
|
1323
|
+
if (isParseTreeNode(parent) && operand.kind === 188 /* SyntaxKind.TypeQuery */)
|
|
1218
1324
|
return this.emitTypeNode(operand, 5 /* TypePrecedence.TypeOperator */);
|
|
1219
1325
|
return this.emitTypeNode(operand, 6 /* TypePrecedence.Postfix */);
|
|
1220
1326
|
}
|
|
@@ -1312,11 +1418,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
1312
1418
|
if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */)
|
|
1313
1419
|
this.write1('?');
|
|
1314
1420
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1421
|
+
// A mapped type written without a type, `{ [K in keyof T] }`, prints without one.
|
|
1422
|
+
if (node.type !== undefined) {
|
|
1423
|
+
this.write1(': ');
|
|
1424
|
+
this.emitTypeNodeOutsideExtends(node.type);
|
|
1425
|
+
}
|
|
1320
1426
|
this.write1(';');
|
|
1321
1427
|
if (node.members !== undefined && node.members.nodes.length > 0) {
|
|
1322
1428
|
if (singleLine)
|
|
@@ -1419,15 +1525,15 @@ export class Printer extends NameGeneratorHost {
|
|
|
1419
1525
|
case 146 /* SyntaxKind.NeverKeyword */:
|
|
1420
1526
|
case 141 /* SyntaxKind.IntrinsicKeyword */:
|
|
1421
1527
|
return this.emitTokenNode(node);
|
|
1422
|
-
case
|
|
1528
|
+
case 311 /* SyntaxKind.JSDocAllType */:
|
|
1423
1529
|
return this.emitSimpleNode(node, tokenToString(node.kind));
|
|
1424
|
-
case
|
|
1530
|
+
case 199 /* SyntaxKind.ThisType */:
|
|
1425
1531
|
return this.emitSimpleNode(node, 'this');
|
|
1426
|
-
case
|
|
1532
|
+
case 184 /* SyntaxKind.TypePredicate */:
|
|
1427
1533
|
if (node instanceof TypePredicateNode)
|
|
1428
1534
|
return this.emitTypePredicate(node);
|
|
1429
1535
|
break;
|
|
1430
|
-
case
|
|
1536
|
+
case 185 /* SyntaxKind.TypeReference */:
|
|
1431
1537
|
if (node instanceof TypeReferenceNode) {
|
|
1432
1538
|
const state = this.enterNode(node);
|
|
1433
1539
|
this.emitEntityName(node.typeName);
|
|
@@ -1436,15 +1542,15 @@ export class Printer extends NameGeneratorHost {
|
|
|
1436
1542
|
return true;
|
|
1437
1543
|
}
|
|
1438
1544
|
break;
|
|
1439
|
-
case
|
|
1545
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
1440
1546
|
if (node instanceof FunctionTypeNode)
|
|
1441
1547
|
return this.emitFunctionType(node);
|
|
1442
1548
|
break;
|
|
1443
|
-
case
|
|
1549
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
1444
1550
|
if (node instanceof ConstructorTypeNode)
|
|
1445
1551
|
return this.emitConstructorType(node);
|
|
1446
1552
|
break;
|
|
1447
|
-
case
|
|
1553
|
+
case 188 /* SyntaxKind.TypeQuery */:
|
|
1448
1554
|
if (node instanceof TypeQueryNode) {
|
|
1449
1555
|
const state = this.enterNode(node);
|
|
1450
1556
|
this.write1('typeof ');
|
|
@@ -1454,11 +1560,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
1454
1560
|
return true;
|
|
1455
1561
|
}
|
|
1456
1562
|
break;
|
|
1457
|
-
case
|
|
1563
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
1458
1564
|
if (node instanceof TypeLiteralNode)
|
|
1459
1565
|
return this.emitTypeLiteral(node);
|
|
1460
1566
|
break;
|
|
1461
|
-
case
|
|
1567
|
+
case 190 /* SyntaxKind.ArrayType */:
|
|
1462
1568
|
if (node instanceof ArrayTypeNode) {
|
|
1463
1569
|
const state = this.enterNode(node);
|
|
1464
1570
|
this.emitPostfixTypeOperand(node.elementType, node);
|
|
@@ -1468,11 +1574,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
1468
1574
|
return true;
|
|
1469
1575
|
}
|
|
1470
1576
|
break;
|
|
1471
|
-
case
|
|
1577
|
+
case 191 /* SyntaxKind.TupleType */:
|
|
1472
1578
|
if (node instanceof TupleTypeNode)
|
|
1473
1579
|
return this.emitTupleType(node);
|
|
1474
1580
|
break;
|
|
1475
|
-
case
|
|
1581
|
+
case 192 /* SyntaxKind.OptionalType */:
|
|
1476
1582
|
if (node instanceof OptionalTypeNode) {
|
|
1477
1583
|
const state = this.enterNode(node);
|
|
1478
1584
|
this.emitPostfixTypeOperand(node.type, node);
|
|
@@ -1481,7 +1587,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1481
1587
|
return true;
|
|
1482
1588
|
}
|
|
1483
1589
|
break;
|
|
1484
|
-
case
|
|
1590
|
+
case 193 /* SyntaxKind.RestType */:
|
|
1485
1591
|
if (node instanceof RestTypeNode) {
|
|
1486
1592
|
const state = this.enterNode(node);
|
|
1487
1593
|
this.write1('...');
|
|
@@ -1490,7 +1596,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1490
1596
|
return true;
|
|
1491
1597
|
}
|
|
1492
1598
|
break;
|
|
1493
|
-
case
|
|
1599
|
+
case 194 /* SyntaxKind.UnionType */:
|
|
1494
1600
|
if (node instanceof UnionTypeNode) {
|
|
1495
1601
|
const state = this.enterNode(node);
|
|
1496
1602
|
this.emitList(8 /* ListItem.UnionConstituent */, node, node.types, 516 /* ListFormat.UnionTypeConstituents */);
|
|
@@ -1498,7 +1604,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1498
1604
|
return true;
|
|
1499
1605
|
}
|
|
1500
1606
|
break;
|
|
1501
|
-
case
|
|
1607
|
+
case 195 /* SyntaxKind.IntersectionType */:
|
|
1502
1608
|
if (node instanceof IntersectionTypeNode) {
|
|
1503
1609
|
const state = this.enterNode(node);
|
|
1504
1610
|
this.emitList(8 /* ListItem.UnionConstituent */, node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */);
|
|
@@ -1506,15 +1612,15 @@ export class Printer extends NameGeneratorHost {
|
|
|
1506
1612
|
return true;
|
|
1507
1613
|
}
|
|
1508
1614
|
break;
|
|
1509
|
-
case
|
|
1615
|
+
case 196 /* SyntaxKind.ConditionalType */:
|
|
1510
1616
|
if (node instanceof ConditionalTypeNode)
|
|
1511
1617
|
return this.emitConditionalType(node);
|
|
1512
1618
|
break;
|
|
1513
|
-
case
|
|
1619
|
+
case 197 /* SyntaxKind.InferType */:
|
|
1514
1620
|
if (node instanceof InferTypeNode)
|
|
1515
1621
|
return this.emitInferType(node);
|
|
1516
1622
|
break;
|
|
1517
|
-
case
|
|
1623
|
+
case 198 /* SyntaxKind.ParenthesizedType */:
|
|
1518
1624
|
if (node instanceof ParenthesizedTypeNode) {
|
|
1519
1625
|
const state = this.enterNode(node);
|
|
1520
1626
|
this.write1('(');
|
|
@@ -1524,11 +1630,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
1524
1630
|
return true;
|
|
1525
1631
|
}
|
|
1526
1632
|
break;
|
|
1527
|
-
case
|
|
1633
|
+
case 200 /* SyntaxKind.TypeOperator */:
|
|
1528
1634
|
if (node instanceof TypeOperatorNode)
|
|
1529
1635
|
return this.emitTypeOperator(node);
|
|
1530
1636
|
break;
|
|
1531
|
-
case
|
|
1637
|
+
case 201 /* SyntaxKind.IndexedAccessType */:
|
|
1532
1638
|
if (node instanceof IndexedAccessTypeNode) {
|
|
1533
1639
|
const state = this.enterNode(node);
|
|
1534
1640
|
this.emitPostfixTypeOperand(node.objectType, node);
|
|
@@ -1539,11 +1645,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
1539
1645
|
return true;
|
|
1540
1646
|
}
|
|
1541
1647
|
break;
|
|
1542
|
-
case
|
|
1648
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
1543
1649
|
if (node instanceof MappedTypeNode)
|
|
1544
1650
|
return this.emitMappedType(node);
|
|
1545
1651
|
break;
|
|
1546
|
-
case
|
|
1652
|
+
case 203 /* SyntaxKind.LiteralType */:
|
|
1547
1653
|
if (node instanceof LiteralTypeNode) {
|
|
1548
1654
|
const state = this.enterNode(node);
|
|
1549
1655
|
this.emitExpression(node.literal, 0 /* OperatorPrecedence.Comma */);
|
|
@@ -1551,39 +1657,39 @@ export class Printer extends NameGeneratorHost {
|
|
|
1551
1657
|
return true;
|
|
1552
1658
|
}
|
|
1553
1659
|
break;
|
|
1554
|
-
case
|
|
1660
|
+
case 204 /* SyntaxKind.NamedTupleMember */:
|
|
1555
1661
|
if (node instanceof NamedTupleMember)
|
|
1556
1662
|
return this.emitNamedTupleMember(node);
|
|
1557
1663
|
break;
|
|
1558
|
-
case
|
|
1664
|
+
case 205 /* SyntaxKind.TemplateLiteralType */:
|
|
1559
1665
|
if (node instanceof TemplateLiteralTypeNode)
|
|
1560
1666
|
return this.emitTemplateType(node);
|
|
1561
1667
|
break;
|
|
1562
|
-
case
|
|
1668
|
+
case 206 /* SyntaxKind.TemplateLiteralTypeSpan */:
|
|
1563
1669
|
if (node instanceof TemplateLiteralTypeSpan)
|
|
1564
1670
|
return this.emitTemplateTypeSpan(node);
|
|
1565
1671
|
break;
|
|
1566
|
-
case
|
|
1672
|
+
case 207 /* SyntaxKind.ImportType */:
|
|
1567
1673
|
if (node instanceof ImportTypeNode)
|
|
1568
1674
|
return this.emitImportType(node);
|
|
1569
1675
|
break;
|
|
1570
|
-
case
|
|
1676
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
1571
1677
|
if (node instanceof PropertyAccessExpression)
|
|
1572
1678
|
return this.emitPropertyAccessExpression(node);
|
|
1573
1679
|
break;
|
|
1574
|
-
case
|
|
1680
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
1575
1681
|
if (node instanceof ExpressionWithTypeArguments)
|
|
1576
1682
|
return this.emitExpressionWithTypeArguments(node);
|
|
1577
1683
|
break;
|
|
1578
|
-
case
|
|
1684
|
+
case 313 /* SyntaxKind.JSDocNonNullableType */:
|
|
1579
1685
|
if (node instanceof JSDocNonNullableType)
|
|
1580
1686
|
return this.emitJSDocPrefixType(node, '!', node.type);
|
|
1581
1687
|
break;
|
|
1582
|
-
case
|
|
1688
|
+
case 312 /* SyntaxKind.JSDocNullableType */:
|
|
1583
1689
|
if (node instanceof JSDocNullableType)
|
|
1584
1690
|
return this.emitJSDocPrefixType(node, '?', node.type);
|
|
1585
1691
|
break;
|
|
1586
|
-
case
|
|
1692
|
+
case 314 /* SyntaxKind.JSDocOptionalType */:
|
|
1587
1693
|
if (node instanceof JSDocOptionalType) {
|
|
1588
1694
|
const state = this.enterNode(node);
|
|
1589
1695
|
this.emitTypeNode(node.type, 1 /* TypePrecedence.JSDoc */);
|
|
@@ -1592,7 +1698,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1592
1698
|
return true;
|
|
1593
1699
|
}
|
|
1594
1700
|
break;
|
|
1595
|
-
case
|
|
1701
|
+
case 315 /* SyntaxKind.JSDocVariadicType */:
|
|
1596
1702
|
if (node instanceof JSDocVariadicType) {
|
|
1597
1703
|
const state = this.enterNode(node);
|
|
1598
1704
|
this.write1('...');
|
|
@@ -1614,7 +1720,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1614
1720
|
// Binding patterns
|
|
1615
1721
|
emitBindingPattern(node) {
|
|
1616
1722
|
const state = this.enterNode(node);
|
|
1617
|
-
const object = node.kind ===
|
|
1723
|
+
const object = node.kind === 208 /* SyntaxKind.ObjectBindingPattern */;
|
|
1618
1724
|
this.write1(object ? '{' : '[');
|
|
1619
1725
|
this.emitList(11 /* ListItem.BindingElement */, node, node.elements, object ? 525136 /* ListFormat.ObjectBindingPatternElements */ : 524880 /* ListFormat.ArrayBindingPatternElements */);
|
|
1620
1726
|
this.write1(object ? '}' : ']');
|
|
@@ -1720,7 +1826,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1720
1826
|
this.emitExpression(callee, 0 /* OperatorPrecedence.Comma */);
|
|
1721
1827
|
return this.write1(')');
|
|
1722
1828
|
}
|
|
1723
|
-
if (parent.kind ===
|
|
1829
|
+
if (parent.kind === 215 /* SyntaxKind.CallExpression */ &&
|
|
1724
1830
|
isNewExpressionWithoutArguments(skipPartiallyEmittedExpressions(callee)))
|
|
1725
1831
|
return this.emitExpression(callee, 22 /* OperatorPrecedence.Parentheses */);
|
|
1726
1832
|
return this.emitExpression(callee, isOptionalChain(parent) ? 19 /* OperatorPrecedence.OptionalChain */ : 20 /* OperatorPrecedence.Member */);
|
|
@@ -1738,7 +1844,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1738
1844
|
const state = this.enterNode(node);
|
|
1739
1845
|
this.emitToken(104 /* SyntaxKind.NewKeyword */, node.pos, node);
|
|
1740
1846
|
this.space();
|
|
1741
|
-
if (skipPartiallyEmittedExpressions(node.expression).kind ===
|
|
1847
|
+
if (skipPartiallyEmittedExpressions(node.expression).kind === 215 /* SyntaxKind.CallExpression */)
|
|
1742
1848
|
this.emitExpression(node.expression, 22 /* OperatorPrecedence.Parentheses */);
|
|
1743
1849
|
else
|
|
1744
1850
|
this.emitExpression(node.expression, 20 /* OperatorPrecedence.Member */);
|
|
@@ -1787,7 +1893,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
1787
1893
|
emitConciseBody(node) {
|
|
1788
1894
|
if (node instanceof Block)
|
|
1789
1895
|
return this.emitFunctionBody(node);
|
|
1790
|
-
if (getLeftmostExpression(node, false).kind ===
|
|
1896
|
+
if (getLeftmostExpression(node, false).kind === 212 /* SyntaxKind.ObjectLiteralExpression */) {
|
|
1791
1897
|
const paren = this.context.factory.createParenthesizedExpression(node);
|
|
1792
1898
|
paren.pos = node.pos;
|
|
1793
1899
|
paren.end = node.end;
|
|
@@ -2048,7 +2154,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2048
2154
|
const parseNode = this.context.parseNode(node);
|
|
2049
2155
|
if (parseNode !== undefined &&
|
|
2050
2156
|
parseNode.parent !== undefined &&
|
|
2051
|
-
parseNode.parent.kind ===
|
|
2157
|
+
parseNode.parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
2052
2158
|
return true;
|
|
2053
2159
|
}
|
|
2054
2160
|
if (hasNewLineComment)
|
|
@@ -2146,35 +2252,35 @@ export class Printer extends NameGeneratorHost {
|
|
|
2146
2252
|
if (node instanceof PrivateIdentifier)
|
|
2147
2253
|
return this.emitPrivateIdentifier(node);
|
|
2148
2254
|
break;
|
|
2149
|
-
case
|
|
2255
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
2150
2256
|
if (node instanceof ArrayLiteralExpression)
|
|
2151
2257
|
return this.emitArrayLiteralExpression(node);
|
|
2152
2258
|
break;
|
|
2153
|
-
case
|
|
2259
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
2154
2260
|
if (node instanceof ObjectLiteralExpression)
|
|
2155
2261
|
return this.emitObjectLiteralExpression(node);
|
|
2156
2262
|
break;
|
|
2157
|
-
case
|
|
2263
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
2158
2264
|
if (node instanceof PropertyAccessExpression)
|
|
2159
2265
|
return this.emitPropertyAccessExpression(node);
|
|
2160
2266
|
break;
|
|
2161
|
-
case
|
|
2267
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
2162
2268
|
if (node instanceof ElementAccessExpression)
|
|
2163
2269
|
return this.emitElementAccessExpression(node);
|
|
2164
2270
|
break;
|
|
2165
|
-
case
|
|
2271
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
2166
2272
|
if (node instanceof CallExpression)
|
|
2167
2273
|
return this.emitCallExpression(node);
|
|
2168
2274
|
break;
|
|
2169
|
-
case
|
|
2275
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
2170
2276
|
if (node instanceof NewExpression)
|
|
2171
2277
|
return this.emitNewExpression(node);
|
|
2172
2278
|
break;
|
|
2173
|
-
case
|
|
2279
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
2174
2280
|
if (node instanceof TaggedTemplateExpression)
|
|
2175
2281
|
return this.emitTaggedTemplateExpression(node);
|
|
2176
2282
|
break;
|
|
2177
|
-
case
|
|
2283
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
2178
2284
|
if (node instanceof TypeAssertion) {
|
|
2179
2285
|
const state = this.enterNode(node);
|
|
2180
2286
|
this.write1('<');
|
|
@@ -2185,77 +2291,77 @@ export class Printer extends NameGeneratorHost {
|
|
|
2185
2291
|
return true;
|
|
2186
2292
|
}
|
|
2187
2293
|
break;
|
|
2188
|
-
case
|
|
2294
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
2189
2295
|
if (node instanceof ParenthesizedExpression)
|
|
2190
2296
|
return this.emitParenthesizedExpression(node);
|
|
2191
2297
|
break;
|
|
2192
|
-
case
|
|
2298
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
2193
2299
|
if (node instanceof FunctionExpression)
|
|
2194
2300
|
return this.emitFunctionExpression(node);
|
|
2195
2301
|
break;
|
|
2196
|
-
case
|
|
2302
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
2197
2303
|
if (node instanceof ArrowFunction)
|
|
2198
2304
|
return this.emitArrowFunction(node);
|
|
2199
2305
|
break;
|
|
2200
|
-
case
|
|
2306
|
+
case 222 /* SyntaxKind.DeleteExpression */:
|
|
2201
2307
|
if (node instanceof DeleteExpression)
|
|
2202
2308
|
return this.emitKeywordUnary(node, 90 /* SyntaxKind.DeleteKeyword */, node.expression);
|
|
2203
2309
|
break;
|
|
2204
|
-
case
|
|
2310
|
+
case 223 /* SyntaxKind.TypeOfExpression */:
|
|
2205
2311
|
if (node instanceof TypeOfExpression)
|
|
2206
2312
|
return this.emitKeywordUnary(node, 113 /* SyntaxKind.TypeOfKeyword */, node.expression);
|
|
2207
2313
|
break;
|
|
2208
|
-
case
|
|
2314
|
+
case 224 /* SyntaxKind.VoidExpression */:
|
|
2209
2315
|
if (node instanceof VoidExpression)
|
|
2210
2316
|
return this.emitKeywordUnary(node, 115 /* SyntaxKind.VoidKeyword */, node.expression);
|
|
2211
2317
|
break;
|
|
2212
|
-
case
|
|
2318
|
+
case 225 /* SyntaxKind.AwaitExpression */:
|
|
2213
2319
|
if (node instanceof AwaitExpression)
|
|
2214
2320
|
return this.emitKeywordUnary(node, 134 /* SyntaxKind.AwaitKeyword */, node.expression);
|
|
2215
2321
|
break;
|
|
2216
|
-
case
|
|
2322
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
2217
2323
|
if (node instanceof PrefixUnaryExpression)
|
|
2218
2324
|
return this.emitPrefixUnaryExpression(node);
|
|
2219
2325
|
break;
|
|
2220
|
-
case
|
|
2326
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
2221
2327
|
if (node instanceof PostfixUnaryExpression)
|
|
2222
2328
|
return this.emitPostfixUnaryExpression(node);
|
|
2223
2329
|
break;
|
|
2224
|
-
case
|
|
2330
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
2225
2331
|
if (node instanceof BinaryExpression)
|
|
2226
2332
|
return this.emitBinaryExpression(node);
|
|
2227
2333
|
break;
|
|
2228
|
-
case
|
|
2334
|
+
case 229 /* SyntaxKind.ConditionalExpression */:
|
|
2229
2335
|
if (node instanceof ConditionalExpression)
|
|
2230
2336
|
return this.emitConditionalExpression(node);
|
|
2231
2337
|
break;
|
|
2232
|
-
case
|
|
2338
|
+
case 230 /* SyntaxKind.TemplateExpression */:
|
|
2233
2339
|
if (node instanceof TemplateExpression)
|
|
2234
2340
|
return this.emitTemplateExpression(node);
|
|
2235
2341
|
break;
|
|
2236
|
-
case
|
|
2342
|
+
case 231 /* SyntaxKind.YieldExpression */:
|
|
2237
2343
|
if (node instanceof YieldExpression)
|
|
2238
2344
|
return this.emitYieldExpression(node);
|
|
2239
2345
|
break;
|
|
2240
|
-
case
|
|
2346
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
2241
2347
|
if (node instanceof SpreadElement)
|
|
2242
2348
|
return this.emitSpreadElement(node);
|
|
2243
2349
|
break;
|
|
2244
|
-
case
|
|
2350
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
2245
2351
|
if (node instanceof ClassExpression)
|
|
2246
2352
|
return this.emitClassLike(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
|
|
2247
2353
|
break;
|
|
2248
|
-
case
|
|
2354
|
+
case 234 /* SyntaxKind.OmittedExpression */:
|
|
2249
2355
|
return this.emitSimpleNode(node, '');
|
|
2250
|
-
case
|
|
2356
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
2251
2357
|
if (node instanceof AsExpression)
|
|
2252
2358
|
return this.emitTypeRelation(node, node.expression, 'as', node.type);
|
|
2253
2359
|
break;
|
|
2254
|
-
case
|
|
2360
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
2255
2361
|
if (node instanceof SatisfiesExpression)
|
|
2256
2362
|
return this.emitTypeRelation(node, node.expression, 'satisfies', node.type);
|
|
2257
2363
|
break;
|
|
2258
|
-
case
|
|
2364
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
2259
2365
|
if (node instanceof NonNullExpression) {
|
|
2260
2366
|
const state = this.enterNode(node);
|
|
2261
2367
|
this.emitExpression(node.expression, 20 /* OperatorPrecedence.Member */);
|
|
@@ -2264,36 +2370,36 @@ export class Printer extends NameGeneratorHost {
|
|
|
2264
2370
|
return true;
|
|
2265
2371
|
}
|
|
2266
2372
|
break;
|
|
2267
|
-
case
|
|
2373
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
2268
2374
|
if (node instanceof ExpressionWithTypeArguments)
|
|
2269
2375
|
return this.emitExpressionWithTypeArguments(node);
|
|
2270
2376
|
break;
|
|
2271
|
-
case
|
|
2377
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
2272
2378
|
if (node instanceof MetaProperty) {
|
|
2273
2379
|
const state = this.enterNode(node);
|
|
2274
|
-
this.emitToken(node.keywordToken, node.pos, node);
|
|
2275
|
-
this.
|
|
2380
|
+
const pos = this.emitToken(node.keywordToken, node.pos, node);
|
|
2381
|
+
this.emitToken(24 /* SyntaxKind.DotToken */, pos, node);
|
|
2276
2382
|
this.emitIdentifierName(node.name);
|
|
2277
2383
|
this.exitNode(node, state);
|
|
2278
2384
|
return true;
|
|
2279
2385
|
}
|
|
2280
2386
|
break;
|
|
2281
|
-
case
|
|
2282
|
-
case
|
|
2387
|
+
case 284 /* SyntaxKind.MissingDeclaration */:
|
|
2388
|
+
case 348 /* SyntaxKind.NotEmittedStatement */:
|
|
2283
2389
|
return false;
|
|
2284
|
-
case
|
|
2390
|
+
case 286 /* SyntaxKind.JsxElement */:
|
|
2285
2391
|
if (node instanceof JsxElement)
|
|
2286
2392
|
return this.emitJsxElement(node);
|
|
2287
2393
|
break;
|
|
2288
|
-
case
|
|
2394
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
2289
2395
|
if (node instanceof JsxSelfClosingElement)
|
|
2290
2396
|
return this.emitJsxSelfClosingElement(node);
|
|
2291
2397
|
break;
|
|
2292
|
-
case
|
|
2398
|
+
case 290 /* SyntaxKind.JsxFragment */:
|
|
2293
2399
|
if (node instanceof JsxFragment)
|
|
2294
2400
|
return this.emitJsxFragment(node);
|
|
2295
2401
|
break;
|
|
2296
|
-
case
|
|
2402
|
+
case 349 /* SyntaxKind.PartiallyEmittedExpression */:
|
|
2297
2403
|
if (node instanceof PartiallyEmittedExpression)
|
|
2298
2404
|
return this.emitPartiallyEmittedExpression(node);
|
|
2299
2405
|
break;
|
|
@@ -2347,7 +2453,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2347
2453
|
}
|
|
2348
2454
|
else {
|
|
2349
2455
|
const leftmost = getLeftmostExpression(expression, false).kind;
|
|
2350
|
-
this.emitExpression(expression, leftmost ===
|
|
2456
|
+
this.emitExpression(expression, leftmost === 220 /* SyntaxKind.FunctionExpression */ || leftmost === 212 /* SyntaxKind.ObjectLiteralExpression */
|
|
2351
2457
|
? 22 /* OperatorPrecedence.Parentheses */
|
|
2352
2458
|
: 0 /* OperatorPrecedence.Comma */);
|
|
2353
2459
|
}
|
|
@@ -2431,14 +2537,14 @@ export class Printer extends NameGeneratorHost {
|
|
|
2431
2537
|
const state = this.enterNode(node);
|
|
2432
2538
|
const pos = this.emitToken(98 /* SyntaxKind.ForKeyword */, node.pos, node);
|
|
2433
2539
|
this.space();
|
|
2434
|
-
if (node.kind ===
|
|
2540
|
+
if (node.kind === 252 /* SyntaxKind.ForOfStatement */ && node.awaitModifier !== undefined) {
|
|
2435
2541
|
this.emitOptionalToken(node.awaitModifier);
|
|
2436
2542
|
this.space();
|
|
2437
2543
|
}
|
|
2438
2544
|
this.emitToken(20 /* SyntaxKind.OpenParenToken */, pos, node);
|
|
2439
2545
|
this.emitForInitializer(node.initializer);
|
|
2440
2546
|
this.space();
|
|
2441
|
-
this.emitToken(node.kind ===
|
|
2547
|
+
this.emitToken(node.kind === 252 /* SyntaxKind.ForOfStatement */ ? 165 /* SyntaxKind.OfKeyword */ : 102 /* SyntaxKind.InKeyword */, node.initializer.end, node);
|
|
2442
2548
|
this.space();
|
|
2443
2549
|
this.emitExpression(node.expression, 0 /* OperatorPrecedence.Lowest */);
|
|
2444
2550
|
this.emitToken(21 /* SyntaxKind.CloseParenToken */, node.expression.end, node);
|
|
@@ -2602,6 +2708,10 @@ export class Printer extends NameGeneratorHost {
|
|
|
2602
2708
|
this.emitIdentifierOrString(body.name, false);
|
|
2603
2709
|
body = body.body;
|
|
2604
2710
|
}
|
|
2711
|
+
if (node.attributes !== undefined) {
|
|
2712
|
+
this.write1(' with ');
|
|
2713
|
+
this.emitTypeNode(node.attributes, 7 /* TypePrecedence.NonArray */);
|
|
2714
|
+
}
|
|
2605
2715
|
if (body === undefined)
|
|
2606
2716
|
this.write1(';');
|
|
2607
2717
|
else if (body instanceof ModuleBlock) {
|
|
@@ -2709,15 +2819,19 @@ export class Printer extends NameGeneratorHost {
|
|
|
2709
2819
|
this.exitNode(bindings, bindingsState);
|
|
2710
2820
|
}
|
|
2711
2821
|
else if (bindings instanceof NamedImports) {
|
|
2712
|
-
|
|
2713
|
-
this.write1('{');
|
|
2714
|
-
this.emitList(20 /* ListItem.ImportSpecifier */, bindings, bindings.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */);
|
|
2715
|
-
this.write1('}');
|
|
2716
|
-
this.exitNode(bindings, bindingsState);
|
|
2822
|
+
this.emitNamedImports(bindings);
|
|
2717
2823
|
}
|
|
2718
2824
|
this.exitNode(node, state);
|
|
2719
2825
|
return true;
|
|
2720
2826
|
}
|
|
2827
|
+
emitNamedImports(node) {
|
|
2828
|
+
const state = this.enterNode(node);
|
|
2829
|
+
this.write1('{');
|
|
2830
|
+
this.emitList(20 /* ListItem.ImportSpecifier */, node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */);
|
|
2831
|
+
this.write1('}');
|
|
2832
|
+
this.exitNode(node, state);
|
|
2833
|
+
return true;
|
|
2834
|
+
}
|
|
2721
2835
|
/** Import and export specifiers. */
|
|
2722
2836
|
emitSpecifier(node, isTypeOnly, propertyName, name, binding) {
|
|
2723
2837
|
const state = this.enterNode(node);
|
|
@@ -2743,7 +2857,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2743
2857
|
this.emitExpression(node.expression, 3 /* OperatorPrecedence.Assignment */);
|
|
2744
2858
|
else {
|
|
2745
2859
|
const leftmost = getLeftmostExpression(node.expression, false).kind;
|
|
2746
|
-
this.emitExpression(node.expression, leftmost ===
|
|
2860
|
+
this.emitExpression(node.expression, leftmost === 233 /* SyntaxKind.ClassExpression */ || leftmost === 220 /* SyntaxKind.FunctionExpression */
|
|
2747
2861
|
? 22 /* OperatorPrecedence.Parentheses */
|
|
2748
2862
|
: 3 /* OperatorPrecedence.Assignment */);
|
|
2749
2863
|
}
|
|
@@ -2828,29 +2942,29 @@ export class Printer extends NameGeneratorHost {
|
|
|
2828
2942
|
}
|
|
2829
2943
|
emitStatement(node) {
|
|
2830
2944
|
switch (node.kind) {
|
|
2831
|
-
case
|
|
2945
|
+
case 243 /* SyntaxKind.Block */:
|
|
2832
2946
|
if (node instanceof Block)
|
|
2833
2947
|
return this.emitBlock(node);
|
|
2834
2948
|
break;
|
|
2835
|
-
case
|
|
2949
|
+
case 244 /* SyntaxKind.EmptyStatement */:
|
|
2836
2950
|
return this.emitSimpleNode(node, ';');
|
|
2837
|
-
case
|
|
2951
|
+
case 245 /* SyntaxKind.VariableStatement */:
|
|
2838
2952
|
if (node instanceof VariableStatement)
|
|
2839
2953
|
return this.emitVariableStatement(node);
|
|
2840
2954
|
break;
|
|
2841
|
-
case
|
|
2955
|
+
case 246 /* SyntaxKind.ExpressionStatement */:
|
|
2842
2956
|
if (node instanceof ExpressionStatement)
|
|
2843
2957
|
return this.emitExpressionStatement(node);
|
|
2844
2958
|
break;
|
|
2845
|
-
case
|
|
2959
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
2846
2960
|
if (node instanceof IfStatement)
|
|
2847
2961
|
return this.emitIfStatement(node);
|
|
2848
2962
|
break;
|
|
2849
|
-
case
|
|
2963
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
2850
2964
|
if (node instanceof DoStatement)
|
|
2851
2965
|
return this.emitDoStatement(node);
|
|
2852
2966
|
break;
|
|
2853
|
-
case
|
|
2967
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
2854
2968
|
if (node instanceof WhileStatement) {
|
|
2855
2969
|
const state = this.enterNode(node);
|
|
2856
2970
|
this.emitKeywordAndParenthesizedExpression(node, 116 /* SyntaxKind.WhileKeyword */, node.pos, node.expression);
|
|
@@ -2859,28 +2973,28 @@ export class Printer extends NameGeneratorHost {
|
|
|
2859
2973
|
return true;
|
|
2860
2974
|
}
|
|
2861
2975
|
break;
|
|
2862
|
-
case
|
|
2976
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
2863
2977
|
if (node instanceof ForStatement)
|
|
2864
2978
|
return this.emitForStatement(node);
|
|
2865
2979
|
break;
|
|
2866
|
-
case
|
|
2867
|
-
case
|
|
2980
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
2981
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
2868
2982
|
if (node instanceof ForInOrOfStatement)
|
|
2869
2983
|
return this.emitForInOrOfStatement(node);
|
|
2870
2984
|
break;
|
|
2871
|
-
case
|
|
2985
|
+
case 253 /* SyntaxKind.ContinueStatement */:
|
|
2872
2986
|
if (node instanceof ContinueStatement)
|
|
2873
2987
|
return this.emitJumpStatement(node, 87 /* SyntaxKind.ContinueKeyword */, node.label, undefined);
|
|
2874
2988
|
break;
|
|
2875
|
-
case
|
|
2989
|
+
case 254 /* SyntaxKind.BreakStatement */:
|
|
2876
2990
|
if (node instanceof BreakStatement)
|
|
2877
2991
|
return this.emitJumpStatement(node, 82 /* SyntaxKind.BreakKeyword */, node.label, undefined);
|
|
2878
2992
|
break;
|
|
2879
|
-
case
|
|
2993
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
2880
2994
|
if (node instanceof ReturnStatement)
|
|
2881
2995
|
return this.emitJumpStatement(node, 106 /* SyntaxKind.ReturnKeyword */, undefined, node.expression);
|
|
2882
2996
|
break;
|
|
2883
|
-
case
|
|
2997
|
+
case 256 /* SyntaxKind.WithStatement */:
|
|
2884
2998
|
if (node instanceof WithStatement) {
|
|
2885
2999
|
const state = this.enterNode(node);
|
|
2886
3000
|
this.emitKeywordAndParenthesizedExpression(node, 117 /* SyntaxKind.WithKeyword */, node.pos, node.expression);
|
|
@@ -2889,7 +3003,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2889
3003
|
return true;
|
|
2890
3004
|
}
|
|
2891
3005
|
break;
|
|
2892
|
-
case
|
|
3006
|
+
case 257 /* SyntaxKind.SwitchStatement */:
|
|
2893
3007
|
if (node instanceof SwitchStatement) {
|
|
2894
3008
|
const state = this.enterNode(node);
|
|
2895
3009
|
this.emitKeywordAndParenthesizedExpression(node, 108 /* SyntaxKind.SwitchKeyword */, node.pos, node.expression);
|
|
@@ -2899,7 +3013,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2899
3013
|
return true;
|
|
2900
3014
|
}
|
|
2901
3015
|
break;
|
|
2902
|
-
case
|
|
3016
|
+
case 258 /* SyntaxKind.LabeledStatement */:
|
|
2903
3017
|
if (node instanceof LabeledStatement) {
|
|
2904
3018
|
const state = this.enterNode(node);
|
|
2905
3019
|
this.emitIdentifierName(node.label);
|
|
@@ -2910,7 +3024,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2910
3024
|
return true;
|
|
2911
3025
|
}
|
|
2912
3026
|
break;
|
|
2913
|
-
case
|
|
3027
|
+
case 259 /* SyntaxKind.ThrowStatement */:
|
|
2914
3028
|
if (node instanceof ThrowStatement) {
|
|
2915
3029
|
const state = this.enterNode(node);
|
|
2916
3030
|
this.emitToken(110 /* SyntaxKind.ThrowKeyword */, node.pos, node);
|
|
@@ -2921,11 +3035,11 @@ export class Printer extends NameGeneratorHost {
|
|
|
2921
3035
|
return true;
|
|
2922
3036
|
}
|
|
2923
3037
|
break;
|
|
2924
|
-
case
|
|
3038
|
+
case 260 /* SyntaxKind.TryStatement */:
|
|
2925
3039
|
if (node instanceof TryStatement)
|
|
2926
3040
|
return this.emitTryStatement(node);
|
|
2927
3041
|
break;
|
|
2928
|
-
case
|
|
3042
|
+
case 261 /* SyntaxKind.DebuggerStatement */:
|
|
2929
3043
|
if (node instanceof DebuggerStatement) {
|
|
2930
3044
|
const state = this.enterNode(node);
|
|
2931
3045
|
this.emitToken(88 /* SyntaxKind.DebuggerKeyword */, node.pos, node);
|
|
@@ -2934,52 +3048,52 @@ export class Printer extends NameGeneratorHost {
|
|
|
2934
3048
|
return true;
|
|
2935
3049
|
}
|
|
2936
3050
|
break;
|
|
2937
|
-
case
|
|
3051
|
+
case 348 /* SyntaxKind.NotEmittedStatement */:
|
|
2938
3052
|
return this.emitSimpleNode(node, '');
|
|
2939
|
-
case
|
|
3053
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
2940
3054
|
if (node instanceof FunctionDeclaration)
|
|
2941
3055
|
return this.emitFunctionDeclaration(node);
|
|
2942
3056
|
break;
|
|
2943
|
-
case
|
|
3057
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
2944
3058
|
if (node instanceof ClassDeclaration)
|
|
2945
3059
|
return this.emitClassLike(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
|
|
2946
3060
|
break;
|
|
2947
|
-
case
|
|
3061
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
2948
3062
|
if (node instanceof InterfaceDeclaration)
|
|
2949
3063
|
return this.emitInterfaceDeclaration(node);
|
|
2950
3064
|
break;
|
|
2951
|
-
case
|
|
2952
|
-
case
|
|
3065
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
3066
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
2953
3067
|
if (node instanceof TypeAliasDeclaration)
|
|
2954
3068
|
return this.emitTypeAliasDeclaration(node);
|
|
2955
3069
|
break;
|
|
2956
|
-
case
|
|
3070
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
2957
3071
|
if (node instanceof EnumDeclaration)
|
|
2958
3072
|
return this.emitEnumDeclaration(node);
|
|
2959
3073
|
break;
|
|
2960
|
-
case
|
|
3074
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
2961
3075
|
if (node instanceof ModuleDeclaration)
|
|
2962
3076
|
return this.emitModuleDeclaration(node);
|
|
2963
3077
|
break;
|
|
2964
|
-
case
|
|
3078
|
+
case 284 /* SyntaxKind.MissingDeclaration */:
|
|
2965
3079
|
return false;
|
|
2966
|
-
case
|
|
3080
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
2967
3081
|
if (node instanceof NamespaceExportDeclaration)
|
|
2968
3082
|
return this.emitNamespaceExportDeclaration(node);
|
|
2969
3083
|
break;
|
|
2970
|
-
case
|
|
3084
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
2971
3085
|
if (node instanceof ImportEqualsDeclaration)
|
|
2972
3086
|
return this.emitImportEqualsDeclaration(node);
|
|
2973
3087
|
break;
|
|
2974
|
-
case
|
|
3088
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
2975
3089
|
if (node instanceof ImportDeclaration)
|
|
2976
3090
|
return this.emitImportDeclaration(node);
|
|
2977
3091
|
break;
|
|
2978
|
-
case
|
|
3092
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
2979
3093
|
if (node instanceof ExportAssignment)
|
|
2980
3094
|
return this.emitExportAssignment(node);
|
|
2981
3095
|
break;
|
|
2982
|
-
case
|
|
3096
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
2983
3097
|
if (node instanceof ExportDeclaration)
|
|
2984
3098
|
return this.emitExportDeclaration(node);
|
|
2985
3099
|
break;
|
|
@@ -2990,7 +3104,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
2990
3104
|
emitJsxElement(node) {
|
|
2991
3105
|
const state = this.enterNode(node);
|
|
2992
3106
|
this.emitJsxOpeningElement(node.openingElement);
|
|
2993
|
-
this.emitList(
|
|
3107
|
+
this.emitList(24 /* ListItem.JsxChild */, node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */);
|
|
2994
3108
|
this.emitJsxClosingElement(node.closingElement);
|
|
2995
3109
|
this.exitNode(node, state);
|
|
2996
3110
|
return true;
|
|
@@ -3009,7 +3123,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3009
3123
|
emitJsxFragment(node) {
|
|
3010
3124
|
const state = this.enterNode(node);
|
|
3011
3125
|
this.emitSimpleNode(node.openingFragment, '<>');
|
|
3012
|
-
this.emitList(
|
|
3126
|
+
this.emitList(24 /* ListItem.JsxChild */, node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */);
|
|
3013
3127
|
this.emitSimpleNode(node.closingFragment, '</>');
|
|
3014
3128
|
this.exitNode(node, state);
|
|
3015
3129
|
return true;
|
|
@@ -3039,7 +3153,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3039
3153
|
}
|
|
3040
3154
|
emitJsxAttributes(node) {
|
|
3041
3155
|
const state = this.enterNode(node);
|
|
3042
|
-
this.emitList(
|
|
3156
|
+
this.emitList(25 /* ListItem.JsxAttributeLike */, node, node.properties, 262656 /* ListFormat.JsxElementAttributes */);
|
|
3043
3157
|
this.exitNode(node, state);
|
|
3044
3158
|
return true;
|
|
3045
3159
|
}
|
|
@@ -3135,7 +3249,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3135
3249
|
emitCaseOrDefaultClause(node) {
|
|
3136
3250
|
const state = this.enterNode(node);
|
|
3137
3251
|
let colonPos;
|
|
3138
|
-
if (node.kind ===
|
|
3252
|
+
if (node.kind === 298 /* SyntaxKind.CaseClause */ && node.expression !== undefined) {
|
|
3139
3253
|
this.emitToken(83 /* SyntaxKind.CaseKeyword */, node.pos, node);
|
|
3140
3254
|
this.space();
|
|
3141
3255
|
this.emitExpression(node.expression, 0 /* OperatorPrecedence.Lowest */);
|
|
@@ -3167,7 +3281,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3167
3281
|
this.space();
|
|
3168
3282
|
this.emitToken(node.token, node.pos, node);
|
|
3169
3283
|
this.space();
|
|
3170
|
-
this.emitList(
|
|
3284
|
+
this.emitList(23 /* ListItem.HeritageClauseElement */, node, node.types, 528 /* ListFormat.HeritageClauseTypes */);
|
|
3171
3285
|
this.exitNode(node, state);
|
|
3172
3286
|
return true;
|
|
3173
3287
|
}
|
|
@@ -3392,9 +3506,15 @@ export class Printer extends NameGeneratorHost {
|
|
|
3392
3506
|
if (node instanceof ExpressionWithTypeArguments)
|
|
3393
3507
|
return this.emitExpressionWithTypeArguments(node);
|
|
3394
3508
|
break;
|
|
3395
|
-
case 23 /* ListItem.
|
|
3509
|
+
case 23 /* ListItem.HeritageClauseElement */:
|
|
3510
|
+
if (node instanceof ExpressionWithTypeArguments)
|
|
3511
|
+
return this.emitExpressionWithTypeArguments(node);
|
|
3512
|
+
if (node.kind === 185 /* SyntaxKind.TypeReference */)
|
|
3513
|
+
return this.emitTypeNodeWorker(node);
|
|
3514
|
+
break;
|
|
3515
|
+
case 24 /* ListItem.JsxChild */:
|
|
3396
3516
|
return this.emitJsxChild(node);
|
|
3397
|
-
case
|
|
3517
|
+
case 25 /* ListItem.JsxAttributeLike */:
|
|
3398
3518
|
if (node instanceof JsxAttribute)
|
|
3399
3519
|
return this.emitJsxAttribute(node);
|
|
3400
3520
|
if (node instanceof JsxSpreadAttribute) {
|
|
@@ -3455,48 +3575,48 @@ export class Printer extends NameGeneratorHost {
|
|
|
3455
3575
|
return false;
|
|
3456
3576
|
let originalList = children;
|
|
3457
3577
|
switch (original.kind) {
|
|
3458
|
-
case
|
|
3578
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
3459
3579
|
originalList = getProperties(original);
|
|
3460
3580
|
break;
|
|
3461
|
-
case
|
|
3462
|
-
case
|
|
3463
|
-
case
|
|
3464
|
-
case
|
|
3465
|
-
case
|
|
3581
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
3582
|
+
case 208 /* SyntaxKind.ObjectBindingPattern */:
|
|
3583
|
+
case 209 /* SyntaxKind.ArrayBindingPattern */:
|
|
3584
|
+
case 277 /* SyntaxKind.NamedImports */:
|
|
3585
|
+
case 281 /* SyntaxKind.NamedExports */:
|
|
3466
3586
|
originalList = getElements(original);
|
|
3467
3587
|
break;
|
|
3468
|
-
case
|
|
3469
|
-
case
|
|
3588
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
3589
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
3470
3590
|
if (children === getTypeArguments(parent))
|
|
3471
3591
|
originalList = getTypeArguments(original);
|
|
3472
3592
|
else if (children === getArguments(parent))
|
|
3473
3593
|
originalList = getArguments(original);
|
|
3474
3594
|
break;
|
|
3475
|
-
case
|
|
3476
|
-
case
|
|
3477
|
-
case
|
|
3478
|
-
case
|
|
3479
|
-
case
|
|
3480
|
-
case
|
|
3481
|
-
case
|
|
3482
|
-
case
|
|
3483
|
-
case
|
|
3484
|
-
case
|
|
3485
|
-
case
|
|
3595
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
3596
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
3597
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
3598
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
3599
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
3600
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
3601
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
3602
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
3603
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
3604
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
3605
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
3486
3606
|
if (children === getTypeParameters(parent))
|
|
3487
3607
|
originalList = getTypeParameters(original);
|
|
3488
3608
|
else if (children === getParameters(parent))
|
|
3489
3609
|
originalList = getParameters(original);
|
|
3490
3610
|
break;
|
|
3491
|
-
case
|
|
3492
|
-
case
|
|
3493
|
-
case
|
|
3494
|
-
case
|
|
3495
|
-
case
|
|
3611
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
3612
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
3613
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
3614
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
3615
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
3496
3616
|
if (children === getTypeParameters(parent))
|
|
3497
3617
|
originalList = getTypeParameters(original);
|
|
3498
3618
|
break;
|
|
3499
|
-
case
|
|
3619
|
+
case 302 /* SyntaxKind.ImportAttributes */:
|
|
3500
3620
|
if (original instanceof ImportAttributes)
|
|
3501
3621
|
originalList = original.attributes;
|
|
3502
3622
|
break;
|
|
@@ -3611,126 +3731,130 @@ export class Printer extends NameGeneratorHost {
|
|
|
3611
3731
|
if (node instanceof PrivateIdentifier)
|
|
3612
3732
|
return this.emitPrivateIdentifier(node);
|
|
3613
3733
|
break;
|
|
3614
|
-
case
|
|
3734
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
3615
3735
|
if (node instanceof QualifiedName)
|
|
3616
3736
|
return this.emitQualifiedName(node);
|
|
3617
3737
|
break;
|
|
3618
|
-
case
|
|
3738
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
3619
3739
|
if (node instanceof ComputedPropertyName)
|
|
3620
3740
|
return this.emitComputedPropertyName(node);
|
|
3621
3741
|
break;
|
|
3622
|
-
case
|
|
3742
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
3623
3743
|
if (node instanceof TypeParameterDeclaration)
|
|
3624
3744
|
return this.emitTypeParameter(node);
|
|
3625
3745
|
break;
|
|
3626
|
-
case
|
|
3746
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
3627
3747
|
if (node instanceof ParameterDeclaration)
|
|
3628
3748
|
return this.emitParameter(node);
|
|
3629
3749
|
break;
|
|
3630
|
-
case
|
|
3750
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
3631
3751
|
if (node instanceof Decorator)
|
|
3632
3752
|
return this.emitDecorator(node);
|
|
3633
3753
|
break;
|
|
3634
|
-
case
|
|
3635
|
-
case
|
|
3636
|
-
case
|
|
3637
|
-
case
|
|
3638
|
-
case
|
|
3754
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
3755
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
3756
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
3757
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
3758
|
+
case 351 /* SyntaxKind.NotEmittedTypeElement */:
|
|
3639
3759
|
return this.emitTypeElement(node);
|
|
3640
|
-
case
|
|
3641
|
-
case
|
|
3642
|
-
case
|
|
3643
|
-
case
|
|
3644
|
-
case
|
|
3645
|
-
case
|
|
3646
|
-
case
|
|
3647
|
-
case
|
|
3760
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
3761
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
3762
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
3763
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
3764
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
3765
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
3766
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
3767
|
+
case 242 /* SyntaxKind.SemicolonClassElement */:
|
|
3648
3768
|
return this.emitClassElement(node);
|
|
3649
|
-
case
|
|
3650
|
-
case
|
|
3769
|
+
case 208 /* SyntaxKind.ObjectBindingPattern */:
|
|
3770
|
+
case 209 /* SyntaxKind.ArrayBindingPattern */:
|
|
3651
3771
|
if (node instanceof BindingPattern)
|
|
3652
3772
|
return this.emitBindingPattern(node);
|
|
3653
3773
|
break;
|
|
3654
|
-
case
|
|
3774
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
3655
3775
|
if (node instanceof BindingElement)
|
|
3656
3776
|
return this.emitBindingElement(node);
|
|
3657
3777
|
break;
|
|
3658
|
-
case
|
|
3778
|
+
case 241 /* SyntaxKind.TemplateSpan */:
|
|
3659
3779
|
return this.emitListItem(14 /* ListItem.TemplateSpan */, node);
|
|
3660
|
-
case
|
|
3780
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
3661
3781
|
if (node instanceof VariableDeclaration)
|
|
3662
3782
|
return this.emitVariableDeclaration(node);
|
|
3663
3783
|
break;
|
|
3664
|
-
case
|
|
3784
|
+
case 263 /* SyntaxKind.VariableDeclarationList */:
|
|
3665
3785
|
if (node instanceof VariableDeclarationList)
|
|
3666
3786
|
return this.emitVariableDeclarationList(node);
|
|
3667
3787
|
break;
|
|
3668
|
-
case
|
|
3788
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
3669
3789
|
if (node instanceof ModuleBlock)
|
|
3670
3790
|
return this.emitBlockLike(node, node.statements, false);
|
|
3671
3791
|
break;
|
|
3672
|
-
case
|
|
3792
|
+
case 271 /* SyntaxKind.CaseBlock */:
|
|
3673
3793
|
if (node instanceof CaseBlock)
|
|
3674
3794
|
return this.emitBlockLike(node, node.clauses, true);
|
|
3675
3795
|
break;
|
|
3676
|
-
case
|
|
3796
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
3677
3797
|
if (node instanceof ImportClause)
|
|
3678
3798
|
return this.emitImportClause(node);
|
|
3679
3799
|
break;
|
|
3680
|
-
case 277 /* SyntaxKind.
|
|
3800
|
+
case 277 /* SyntaxKind.NamedImports */:
|
|
3801
|
+
if (node instanceof NamedImports)
|
|
3802
|
+
return this.emitNamedImports(node);
|
|
3803
|
+
break;
|
|
3804
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
3681
3805
|
return this.emitListItem(20 /* ListItem.ImportSpecifier */, node);
|
|
3682
|
-
case
|
|
3806
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
3683
3807
|
return this.emitListItem(21 /* ListItem.ExportSpecifier */, node);
|
|
3684
|
-
case
|
|
3808
|
+
case 302 /* SyntaxKind.ImportAttributes */:
|
|
3685
3809
|
if (node instanceof ImportAttributes)
|
|
3686
3810
|
return this.emitImportAttributes(node);
|
|
3687
3811
|
break;
|
|
3688
|
-
case
|
|
3812
|
+
case 303 /* SyntaxKind.ImportAttribute */:
|
|
3689
3813
|
if (node instanceof ImportAttribute)
|
|
3690
3814
|
return this.emitImportAttribute(node);
|
|
3691
3815
|
break;
|
|
3692
3816
|
case 11 /* SyntaxKind.JsxText */:
|
|
3693
|
-
case
|
|
3817
|
+
case 296 /* SyntaxKind.JsxExpression */:
|
|
3694
3818
|
return this.emitJsxChild(node);
|
|
3695
|
-
case
|
|
3819
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
3696
3820
|
if (node instanceof JsxOpeningElement)
|
|
3697
3821
|
return this.emitJsxOpeningElement(node);
|
|
3698
3822
|
break;
|
|
3699
|
-
case
|
|
3823
|
+
case 289 /* SyntaxKind.JsxClosingElement */:
|
|
3700
3824
|
if (node instanceof JsxClosingElement)
|
|
3701
3825
|
return this.emitJsxClosingElement(node);
|
|
3702
3826
|
break;
|
|
3703
|
-
case
|
|
3704
|
-
case
|
|
3705
|
-
return this.emitListItem(
|
|
3706
|
-
case
|
|
3827
|
+
case 293 /* SyntaxKind.JsxAttribute */:
|
|
3828
|
+
case 295 /* SyntaxKind.JsxSpreadAttribute */:
|
|
3829
|
+
return this.emitListItem(25 /* ListItem.JsxAttributeLike */, node);
|
|
3830
|
+
case 294 /* SyntaxKind.JsxAttributes */:
|
|
3707
3831
|
if (node instanceof JsxAttributes)
|
|
3708
3832
|
return this.emitJsxAttributes(node);
|
|
3709
3833
|
break;
|
|
3710
|
-
case
|
|
3834
|
+
case 297 /* SyntaxKind.JsxNamespacedName */:
|
|
3711
3835
|
return this.emitJsxName(node);
|
|
3712
|
-
case
|
|
3713
|
-
case
|
|
3836
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
3837
|
+
case 299 /* SyntaxKind.DefaultClause */:
|
|
3714
3838
|
if (node instanceof CaseOrDefaultClause)
|
|
3715
3839
|
return this.emitCaseOrDefaultClause(node);
|
|
3716
3840
|
break;
|
|
3717
|
-
case
|
|
3841
|
+
case 300 /* SyntaxKind.HeritageClause */:
|
|
3718
3842
|
if (node instanceof HeritageClause)
|
|
3719
3843
|
return this.emitHeritageClause(node);
|
|
3720
3844
|
break;
|
|
3721
|
-
case
|
|
3845
|
+
case 301 /* SyntaxKind.CatchClause */:
|
|
3722
3846
|
if (node instanceof CatchClause)
|
|
3723
3847
|
return this.emitCatchClause(node);
|
|
3724
3848
|
break;
|
|
3725
|
-
case
|
|
3726
|
-
case
|
|
3727
|
-
case
|
|
3849
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
3850
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
3851
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
3728
3852
|
return this.emitObjectLiteralElement(node);
|
|
3729
|
-
case
|
|
3853
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
3730
3854
|
if (node instanceof EnumMember)
|
|
3731
3855
|
return this.emitEnumMember(node);
|
|
3732
3856
|
break;
|
|
3733
|
-
case
|
|
3857
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
3734
3858
|
if (node instanceof SourceFile)
|
|
3735
3859
|
return this.emitSourceFileNode(node);
|
|
3736
3860
|
break;
|
|
@@ -3751,10 +3875,19 @@ export class Printer extends NameGeneratorHost {
|
|
|
3751
3875
|
emitCommentsBeforeNode(node) {
|
|
3752
3876
|
if (!this.shouldEmitComments(node))
|
|
3753
3877
|
return false;
|
|
3878
|
+
if (this.inCommentFreeRange(node)) {
|
|
3879
|
+
// What the general path does for a node without emit data and without comments.
|
|
3880
|
+
this.pushCommentState(commentFreeNode, node.pos, node.end);
|
|
3881
|
+
this.containerPos = node.pos;
|
|
3882
|
+
this.containerEnd = node.end;
|
|
3883
|
+
if (node.kind === 263 /* SyntaxKind.VariableDeclarationList */)
|
|
3884
|
+
this.declarationListContainerEnd = node.end;
|
|
3885
|
+
return true;
|
|
3886
|
+
}
|
|
3754
3887
|
const flags = this.context.getEmitFlags(node);
|
|
3755
3888
|
const pos = this.context.commentPos(node);
|
|
3756
3889
|
const end = this.context.commentEnd(node);
|
|
3757
|
-
this.
|
|
3890
|
+
this.pushCommentState(flags, pos, end);
|
|
3758
3891
|
this.emitLeadingCommentsOfNode(node, flags, pos, end);
|
|
3759
3892
|
if ((flags & 128 /* EmitFlags.NoLeadingComments */) === 0) {
|
|
3760
3893
|
const synthesized = this.context.getSyntheticLeadingComments(node);
|
|
@@ -3766,17 +3899,43 @@ export class Printer extends NameGeneratorHost {
|
|
|
3766
3899
|
this.commentsDisabled = true;
|
|
3767
3900
|
return true;
|
|
3768
3901
|
}
|
|
3902
|
+
/** Saves the comment state of a node: its emit flags (or `commentFreeNode`), comment range and the containers. */
|
|
3903
|
+
pushCommentState(flags, pos, end) {
|
|
3904
|
+
let stack = this.commentStack;
|
|
3905
|
+
const at = this.commentDepth;
|
|
3906
|
+
if (at + 6 > stack.length) {
|
|
3907
|
+
const grown = new Int32Array(stack.length * 2);
|
|
3908
|
+
grown.set(stack);
|
|
3909
|
+
this.commentStack = grown;
|
|
3910
|
+
stack = grown;
|
|
3911
|
+
}
|
|
3912
|
+
stack[at] = flags;
|
|
3913
|
+
stack[at + 1] = pos;
|
|
3914
|
+
stack[at + 2] = end;
|
|
3915
|
+
stack[at + 3] = this.containerPos;
|
|
3916
|
+
stack[at + 4] = this.containerEnd;
|
|
3917
|
+
stack[at + 5] = this.declarationListContainerEnd;
|
|
3918
|
+
this.commentDepth = at + 6;
|
|
3919
|
+
return true;
|
|
3920
|
+
}
|
|
3769
3921
|
emitCommentsAfterNode(node) {
|
|
3770
3922
|
const stack = this.commentStack;
|
|
3771
|
-
const base =
|
|
3772
|
-
|
|
3773
|
-
const
|
|
3774
|
-
const
|
|
3775
|
-
const
|
|
3776
|
-
const
|
|
3777
|
-
const
|
|
3778
|
-
|
|
3779
|
-
|
|
3923
|
+
const base = this.commentDepth - 6;
|
|
3924
|
+
const flags = stack[base];
|
|
3925
|
+
const pos = stack[base + 1];
|
|
3926
|
+
const end = stack[base + 2];
|
|
3927
|
+
const containerPos = stack[base + 3];
|
|
3928
|
+
const containerEnd = stack[base + 4];
|
|
3929
|
+
const declarationListContainerEnd = stack[base + 5];
|
|
3930
|
+
this.commentDepth = base;
|
|
3931
|
+
if (node === this.freeOwner)
|
|
3932
|
+
this.endCommentFreeRange();
|
|
3933
|
+
if (flags === commentFreeNode) {
|
|
3934
|
+
this.containerPos = containerPos;
|
|
3935
|
+
this.containerEnd = containerEnd;
|
|
3936
|
+
this.declarationListContainerEnd = declarationListContainerEnd;
|
|
3937
|
+
return true;
|
|
3938
|
+
}
|
|
3780
3939
|
if ((flags & 512 /* EmitFlags.NoNestedComments */) !== 0)
|
|
3781
3940
|
this.commentsDisabled = false;
|
|
3782
3941
|
if ((flags & 256 /* EmitFlags.NoTrailingComments */) === 0) {
|
|
@@ -3792,6 +3951,87 @@ export class Printer extends NameGeneratorHost {
|
|
|
3792
3951
|
this.emitTrailingCommentsOfNode(node, flags, typeNode.pos, typeNode.end, containerPos, containerEnd, declarationListContainerEnd);
|
|
3793
3952
|
return true;
|
|
3794
3953
|
}
|
|
3954
|
+
/**
|
|
3955
|
+
* Whether `node` has no emit data and lies in a range of the source text where no comment is found, so that its
|
|
3956
|
+
* comments need not be looked for. Outside such a range, a node whose own range is one starts it (`freeOwner`).
|
|
3957
|
+
*/
|
|
3958
|
+
inCommentFreeRange(node) {
|
|
3959
|
+
const pos = node.pos;
|
|
3960
|
+
const end = node.end;
|
|
3961
|
+
if (pos < 0 || end <= pos || node.kind === 11 /* SyntaxKind.JsxText */ || node.kind === 348 /* SyntaxKind.NotEmittedStatement */)
|
|
3962
|
+
return false;
|
|
3963
|
+
if (this.freeEnd < 0) {
|
|
3964
|
+
if (!this.startCommentFreeRange(pos, end))
|
|
3965
|
+
return false;
|
|
3966
|
+
this.freeOwner = node;
|
|
3967
|
+
}
|
|
3968
|
+
else if (pos < this.freeStart)
|
|
3969
|
+
return false;
|
|
3970
|
+
if (this.context.hasEmitNode(node))
|
|
3971
|
+
return false;
|
|
3972
|
+
return end < this.freeEnd || (end === this.freeEnd && this.freeEndTrailingNone);
|
|
3973
|
+
}
|
|
3974
|
+
endCommentFreeRange() {
|
|
3975
|
+
this.freeStart = -1;
|
|
3976
|
+
this.freeEnd = -1;
|
|
3977
|
+
this.freeEndTrailingNone = false;
|
|
3978
|
+
this.freeOwner = undefined;
|
|
3979
|
+
return true;
|
|
3980
|
+
}
|
|
3981
|
+
/** Whether the comment-free range shows that no trailing comment follows `pos`. */
|
|
3982
|
+
noCommentsAfter(pos) {
|
|
3983
|
+
return pos >= this.freeStart && (pos < this.freeEnd || (pos === this.freeEnd && this.freeEndTrailingNone));
|
|
3984
|
+
}
|
|
3985
|
+
/** Makes `[pos, end)` the comment-free range if no comment starts in it and its last character is not trivia. */
|
|
3986
|
+
startCommentFreeRange(pos, end) {
|
|
3987
|
+
const text = this.sourceText;
|
|
3988
|
+
if (end > text.length)
|
|
3989
|
+
return false;
|
|
3990
|
+
const last = text.charCodeAt(end - 1);
|
|
3991
|
+
if (last === 32 /* CharacterCodes.space */ ||
|
|
3992
|
+
last === 9 /* CharacterCodes.tab */ ||
|
|
3993
|
+
last === 10 /* CharacterCodes.lineFeed */ ||
|
|
3994
|
+
last === 13 /* CharacterCodes.carriageReturn */ ||
|
|
3995
|
+
last === 11 /* CharacterCodes.verticalTab */ ||
|
|
3996
|
+
last === 12 /* CharacterCodes.formFeed */ ||
|
|
3997
|
+
last > 127 /* CharacterCodes.maxAsciiCharacter */)
|
|
3998
|
+
return false;
|
|
3999
|
+
const starts = this.commentStartsOfFile();
|
|
4000
|
+
// The first comment start at or after `pos`.
|
|
4001
|
+
let low = 0;
|
|
4002
|
+
let high = starts.length;
|
|
4003
|
+
while (low < high) {
|
|
4004
|
+
const middle = (low + high) >>> 1;
|
|
4005
|
+
if (starts[middle] < pos)
|
|
4006
|
+
low = middle + 1;
|
|
4007
|
+
else
|
|
4008
|
+
high = middle;
|
|
4009
|
+
}
|
|
4010
|
+
if (low < starts.length && starts[low] < end)
|
|
4011
|
+
return false;
|
|
4012
|
+
this.freeStart = pos;
|
|
4013
|
+
this.freeEnd = end;
|
|
4014
|
+
this.freeEndTrailingNone = getTrailingCommentRanges(text, end) === undefined;
|
|
4015
|
+
return true;
|
|
4016
|
+
}
|
|
4017
|
+
commentStartsOfFile() {
|
|
4018
|
+
const cached = this.commentStarts;
|
|
4019
|
+
if (cached !== undefined)
|
|
4020
|
+
return cached;
|
|
4021
|
+
const text = this.sourceText;
|
|
4022
|
+
const length = text.length;
|
|
4023
|
+
const list = [];
|
|
4024
|
+
for (let i = text.indexOf('/'); i >= 0 && i + 1 < length; i = text.indexOf('/', i + 1)) {
|
|
4025
|
+
const next = text.charCodeAt(i + 1);
|
|
4026
|
+
if (next === 47 /* CharacterCodes.slash */ || next === 42 /* CharacterCodes.asterisk */)
|
|
4027
|
+
list.push(i);
|
|
4028
|
+
}
|
|
4029
|
+
const starts = new Int32Array(list.length);
|
|
4030
|
+
for (let i = 0; i < list.length; i++)
|
|
4031
|
+
starts[i] = list[i];
|
|
4032
|
+
this.commentStarts = starts;
|
|
4033
|
+
return starts;
|
|
4034
|
+
}
|
|
3795
4035
|
/** Emits comments before a token; returns whether `emitCommentsAfterToken` applies, with the token's position in `tokenPos`. */
|
|
3796
4036
|
emitCommentsBeforeToken(pos, contextNode, flags) {
|
|
3797
4037
|
if ((flags & 1 /* TokenEmitFlags.NoComments */) !== 0 || this.commentsDisabled) {
|
|
@@ -3817,7 +4057,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3817
4057
|
}
|
|
3818
4058
|
emitCommentsAfterToken(pos, contextNode) {
|
|
3819
4059
|
if (contextNode.end !== pos)
|
|
3820
|
-
this.emitTrailingComments(pos, contextNode.kind ===
|
|
4060
|
+
this.emitTrailingComments(pos, contextNode.kind === 296 /* SyntaxKind.JsxExpression */ ? 0 /* CommentSeparator.None */ : 1 /* CommentSeparator.Before */);
|
|
3821
4061
|
return true;
|
|
3822
4062
|
}
|
|
3823
4063
|
emitDetachedCommentsBeforeStatementList(node, pos) {
|
|
@@ -3850,12 +4090,12 @@ export class Printer extends NameGeneratorHost {
|
|
|
3850
4090
|
const skipLeading = positionIsSynthesized(pos) || (flags & 128 /* EmitFlags.NoLeadingComments */) !== 0 || jsxText;
|
|
3851
4091
|
const skipTrailing = positionIsSynthesized(end) || (flags & 256 /* EmitFlags.NoTrailingComments */) !== 0 || jsxText;
|
|
3852
4092
|
if (!skipLeading)
|
|
3853
|
-
this.emitLeadingComments(pos, node.kind ===
|
|
4093
|
+
this.emitLeadingComments(pos, node.kind === 348 /* SyntaxKind.NotEmittedStatement */);
|
|
3854
4094
|
if (!skipLeading || (pos >= 0 && (flags & 128 /* EmitFlags.NoLeadingComments */) !== 0))
|
|
3855
4095
|
this.containerPos = pos;
|
|
3856
4096
|
if (!skipTrailing || (end >= 0 && (flags & 256 /* EmitFlags.NoTrailingComments */) !== 0)) {
|
|
3857
4097
|
this.containerEnd = end;
|
|
3858
|
-
if (node.kind ===
|
|
4098
|
+
if (node.kind === 263 /* SyntaxKind.VariableDeclarationList */)
|
|
3859
4099
|
this.declarationListContainerEnd = end;
|
|
3860
4100
|
}
|
|
3861
4101
|
return true;
|
|
@@ -3867,7 +4107,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
3867
4107
|
this.containerPos = containerPos;
|
|
3868
4108
|
this.containerEnd = containerEnd;
|
|
3869
4109
|
this.declarationListContainerEnd = declarationListContainerEnd;
|
|
3870
|
-
if (!skipTrailing && node.kind !==
|
|
4110
|
+
if (!skipTrailing && node.kind !== 348 /* SyntaxKind.NotEmittedStatement */)
|
|
3871
4111
|
this.emitTrailingComments(end, 1 /* CommentSeparator.Before */);
|
|
3872
4112
|
return true;
|
|
3873
4113
|
}
|
|
@@ -3897,6 +4137,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
3897
4137
|
emitLeadingComments(pos, elided) {
|
|
3898
4138
|
if (this.commentsDisabled || this.currentSourceFile === undefined || pos < 0 || pos === this.containerPos)
|
|
3899
4139
|
return false;
|
|
4140
|
+
if (pos >= this.freeStart && pos < this.freeEnd)
|
|
4141
|
+
return false;
|
|
3900
4142
|
// 1: only triple-slash comments, 2: all but triple-slash comments, 0: all.
|
|
3901
4143
|
let tripleSlash = 0;
|
|
3902
4144
|
if (!elided) {
|
|
@@ -3947,6 +4189,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
3947
4189
|
this.currentSourceFile === undefined ||
|
|
3948
4190
|
(this.containerEnd !== -1 && (pos === this.containerEnd || pos === this.declarationListContainerEnd)))
|
|
3949
4191
|
return false;
|
|
4192
|
+
if (this.noCommentsAfter(pos))
|
|
4193
|
+
return false;
|
|
3950
4194
|
const ranges = getTrailingCommentRanges(this.sourceText, pos);
|
|
3951
4195
|
if (ranges === undefined)
|
|
3952
4196
|
return false;
|
|
@@ -3965,6 +4209,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
3965
4209
|
return false;
|
|
3966
4210
|
if (this.containerEnd !== -1 && (pos === this.containerEnd || pos === this.declarationListContainerEnd))
|
|
3967
4211
|
return false;
|
|
4212
|
+
if (this.noCommentsAfter(pos))
|
|
4213
|
+
return false;
|
|
3968
4214
|
const comments = getTrailingCommentRanges(this.sourceText, pos);
|
|
3969
4215
|
if (comments === undefined)
|
|
3970
4216
|
return false;
|
|
@@ -4141,7 +4387,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
4141
4387
|
const flags = this.context.getEmitFlags(node);
|
|
4142
4388
|
const pos = this.context.sourceMapPos(node);
|
|
4143
4389
|
const end = this.context.sourceMapEnd(node);
|
|
4144
|
-
if (node.kind !==
|
|
4390
|
+
if (node.kind !== 348 /* SyntaxKind.NotEmittedStatement */ &&
|
|
4145
4391
|
(flags & 4 /* EmitFlags.NoLeadingSourceMap */) === 0 &&
|
|
4146
4392
|
this.currentSourceFile !== undefined &&
|
|
4147
4393
|
pos >= 0)
|
|
@@ -4159,7 +4405,7 @@ export class Printer extends NameGeneratorHost {
|
|
|
4159
4405
|
stack.length = base;
|
|
4160
4406
|
if ((flags & 16 /* EmitFlags.NoNestedSourceMaps */) !== 0)
|
|
4161
4407
|
this.sourceMapsDisabled = false;
|
|
4162
|
-
if (node.kind !==
|
|
4408
|
+
if (node.kind !== 348 /* SyntaxKind.NotEmittedStatement */ && (flags & 8 /* EmitFlags.NoTrailingSourceMap */) === 0 && end >= 0)
|
|
4163
4409
|
this.emitPos(end);
|
|
4164
4410
|
return true;
|
|
4165
4411
|
}
|
|
@@ -4295,14 +4541,14 @@ export class Printer extends NameGeneratorHost {
|
|
|
4295
4541
|
return false;
|
|
4296
4542
|
for (const node of nodes.nodes) {
|
|
4297
4543
|
switch (node.kind) {
|
|
4298
|
-
case
|
|
4299
|
-
case
|
|
4300
|
-
case
|
|
4301
|
-
case
|
|
4302
|
-
case
|
|
4303
|
-
case
|
|
4304
|
-
case
|
|
4305
|
-
case
|
|
4544
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
4545
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
4546
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
4547
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
4548
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
4549
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
4550
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
4551
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
4306
4552
|
this.generateNameIfNeeded(getName(node));
|
|
4307
4553
|
}
|
|
4308
4554
|
}
|
|
@@ -4426,17 +4672,17 @@ function getContainingNodeArray(node) {
|
|
|
4426
4672
|
if (parent === undefined)
|
|
4427
4673
|
return undefined;
|
|
4428
4674
|
switch (node.kind) {
|
|
4429
|
-
case
|
|
4675
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
4430
4676
|
return getTypeParameters(parent);
|
|
4431
|
-
case
|
|
4677
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
4432
4678
|
return getParameters(parent);
|
|
4433
|
-
case
|
|
4679
|
+
case 206 /* SyntaxKind.TemplateLiteralTypeSpan */:
|
|
4434
4680
|
return parent instanceof TemplateLiteralTypeNode ? parent.templateSpans : undefined;
|
|
4435
|
-
case
|
|
4681
|
+
case 241 /* SyntaxKind.TemplateSpan */:
|
|
4436
4682
|
return parent instanceof TemplateExpression ? parent.templateSpans : undefined;
|
|
4437
|
-
case
|
|
4683
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
4438
4684
|
return getModifiers(parent);
|
|
4439
|
-
case
|
|
4685
|
+
case 300 /* SyntaxKind.HeritageClause */:
|
|
4440
4686
|
if (parent instanceof ClassDeclaration)
|
|
4441
4687
|
return parent.heritageClauses;
|
|
4442
4688
|
if (parent instanceof ClassExpression)
|
|
@@ -4446,11 +4692,11 @@ function getContainingNodeArray(node) {
|
|
|
4446
4692
|
return undefined;
|
|
4447
4693
|
}
|
|
4448
4694
|
switch (parent.kind) {
|
|
4449
|
-
case
|
|
4450
|
-
case
|
|
4451
|
-
case
|
|
4452
|
-
case
|
|
4453
|
-
case
|
|
4695
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
4696
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
4697
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
4698
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
4699
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
4454
4700
|
if (parent instanceof TypeLiteralNode)
|
|
4455
4701
|
return parent.members;
|
|
4456
4702
|
if (parent instanceof InterfaceDeclaration)
|
|
@@ -4462,24 +4708,24 @@ function getContainingNodeArray(node) {
|
|
|
4462
4708
|
if (parent instanceof EnumDeclaration)
|
|
4463
4709
|
return parent.members;
|
|
4464
4710
|
break;
|
|
4465
|
-
case
|
|
4711
|
+
case 194 /* SyntaxKind.UnionType */:
|
|
4466
4712
|
if (parent instanceof UnionTypeNode)
|
|
4467
4713
|
return parent.types;
|
|
4468
4714
|
break;
|
|
4469
|
-
case
|
|
4715
|
+
case 195 /* SyntaxKind.IntersectionType */:
|
|
4470
4716
|
if (parent instanceof IntersectionTypeNode)
|
|
4471
4717
|
return parent.types;
|
|
4472
4718
|
break;
|
|
4473
|
-
case
|
|
4474
|
-
case
|
|
4475
|
-
case
|
|
4476
|
-
case
|
|
4719
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
4720
|
+
case 191 /* SyntaxKind.TupleType */:
|
|
4721
|
+
case 277 /* SyntaxKind.NamedImports */:
|
|
4722
|
+
case 281 /* SyntaxKind.NamedExports */:
|
|
4477
4723
|
return getElements(parent);
|
|
4478
|
-
case
|
|
4479
|
-
case
|
|
4724
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
4725
|
+
case 294 /* SyntaxKind.JsxAttributes */:
|
|
4480
4726
|
return getProperties(parent);
|
|
4481
|
-
case
|
|
4482
|
-
case
|
|
4727
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
4728
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
4483
4729
|
if (isTypeNodeKind(node.kind))
|
|
4484
4730
|
return getTypeArguments(parent);
|
|
4485
4731
|
if (parent instanceof CallExpression && node !== parent.expression)
|
|
@@ -4487,26 +4733,26 @@ function getContainingNodeArray(node) {
|
|
|
4487
4733
|
if (parent instanceof NewExpression && node !== parent.expression)
|
|
4488
4734
|
return parent.arguments;
|
|
4489
4735
|
break;
|
|
4490
|
-
case
|
|
4736
|
+
case 286 /* SyntaxKind.JsxElement */:
|
|
4491
4737
|
if (parent instanceof JsxElement)
|
|
4492
4738
|
return parent.children;
|
|
4493
4739
|
break;
|
|
4494
|
-
case
|
|
4740
|
+
case 290 /* SyntaxKind.JsxFragment */:
|
|
4495
4741
|
if (parent instanceof JsxFragment)
|
|
4496
4742
|
return parent.children;
|
|
4497
4743
|
break;
|
|
4498
|
-
case
|
|
4499
|
-
case
|
|
4744
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
4745
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
4500
4746
|
if (isTypeNodeKind(node.kind))
|
|
4501
4747
|
return getTypeArguments(parent);
|
|
4502
4748
|
break;
|
|
4503
|
-
case
|
|
4504
|
-
case
|
|
4505
|
-
case
|
|
4506
|
-
case
|
|
4507
|
-
case
|
|
4749
|
+
case 243 /* SyntaxKind.Block */:
|
|
4750
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
4751
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
4752
|
+
case 299 /* SyntaxKind.DefaultClause */:
|
|
4753
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
4508
4754
|
return getStatements(parent);
|
|
4509
|
-
case
|
|
4755
|
+
case 271 /* SyntaxKind.CaseBlock */:
|
|
4510
4756
|
if (parent instanceof CaseBlock)
|
|
4511
4757
|
return parent.clauses;
|
|
4512
4758
|
break;
|