tsc-ts 0.0.10 → 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 +1 -1
- 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 +20 -15
- package/dist/api/compiler/ast.js +1023 -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 +173 -123
- 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 +469 -438
- 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 -113
- 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 +210 -74
- 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 +137 -34
- 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 +93 -31
- package/dist/api/compiler/checker.js +143 -35
- 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 +19 -4
- package/dist/api/compiler/compile-program.js +45 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- 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 +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- 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/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 +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -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 +1 -0
- package/dist/api/compiler/printer/printer.js +303 -281
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -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 +2 -0
- package/dist/api/compiler/program.js +69 -57
- 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 +337 -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 +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- 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 +55 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- 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 +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- 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 +197 -55
- 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 +120 -21
- 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 +168 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +51 -25
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- 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 +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +86 -18
- 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 +197 -8
- package/src/compiler/parallel-emit.ts +1 -1
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -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 +35 -14
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -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 +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +19 -2
- 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 +3 -0
- package/src/compiler/tsc-cli.ts +2 -0
- package/src/compiler/tsc-compile.ts +7 -2
- 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
|
@@ -222,7 +222,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
222
222
|
/** Whether an auto-accessor, a `#x in` check or a private access needs WeakMaps and WeakSets. */
|
|
223
223
|
requiresBlockScopedVar() {
|
|
224
224
|
const container = this.currentClassContainer;
|
|
225
|
-
return this.inIterationStatement && container !== undefined && container.kind ===
|
|
225
|
+
return this.inIterationStatement && container !== undefined && container.kind === 233 /* SyntaxKind.ClassExpression */;
|
|
226
226
|
}
|
|
227
227
|
/** Whether a class expression's temporary is block scoped: it's in a loop and has an instance field with a computed name. */
|
|
228
228
|
classExpressionNeedsBlockScopedTemp() {
|
|
@@ -272,7 +272,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
272
272
|
if (node instanceof Identifier)
|
|
273
273
|
return this.visitIdentifier(node);
|
|
274
274
|
if (node instanceof PropertyAccessExpression && node.name instanceof Identifier)
|
|
275
|
-
return this.visitPropertyAccessExpressionForSubstitution(node);
|
|
275
|
+
return this.visitPropertyAccessExpressionForSubstitution(node, this.substitutionMode);
|
|
276
276
|
return this.substitutionMode.visitEachChild(node);
|
|
277
277
|
}
|
|
278
278
|
visit(node) {
|
|
@@ -291,58 +291,58 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
291
291
|
return node;
|
|
292
292
|
}
|
|
293
293
|
switch (node.kind) {
|
|
294
|
-
case
|
|
294
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
295
295
|
return this.visitSourceFile(node);
|
|
296
|
-
case
|
|
297
|
-
case
|
|
296
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
297
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
298
298
|
return this.visitClassLike(node);
|
|
299
|
-
case
|
|
300
|
-
case
|
|
299
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
300
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
301
301
|
throw new Error('Class elements are visited in class element mode');
|
|
302
|
-
case
|
|
303
|
-
case
|
|
304
|
-
case
|
|
305
|
-
case
|
|
302
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
303
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
304
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
305
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
306
306
|
return this.visitEachChild(this.transformNamedEvaluationIfNeeded(node, ''));
|
|
307
|
-
case
|
|
307
|
+
case 245 /* SyntaxKind.VariableStatement */:
|
|
308
308
|
return this.visitVariableStatement(node);
|
|
309
|
-
case
|
|
309
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
310
310
|
return this.visitExportAssignment(node);
|
|
311
311
|
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
312
312
|
return this.visitPrivateIdentifier(node);
|
|
313
|
-
case
|
|
313
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
314
314
|
return this.visitPropertyAccessExpression(node);
|
|
315
|
-
case
|
|
315
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
316
316
|
return this.visitElementAccessExpression(node);
|
|
317
|
-
case
|
|
318
|
-
case
|
|
317
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
318
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
319
319
|
return this.visitPreOrPostfixUnaryExpression(node, false);
|
|
320
|
-
case
|
|
320
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
321
321
|
return this.visitBinaryExpression(node, false);
|
|
322
|
-
case
|
|
322
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
323
323
|
return this.factory.updateParenthesizedExpression(node, this.visitNode(node.expression));
|
|
324
|
-
case
|
|
324
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
325
325
|
return this.visitCallExpression(node);
|
|
326
|
-
case
|
|
326
|
+
case 246 /* SyntaxKind.ExpressionStatement */:
|
|
327
327
|
return this.visitExpressionStatement(node);
|
|
328
|
-
case
|
|
328
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
329
329
|
return this.visitTaggedTemplateExpression(node);
|
|
330
|
-
case
|
|
330
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
331
331
|
return this.visitForStatement(node);
|
|
332
|
-
case
|
|
333
|
-
case
|
|
334
|
-
case
|
|
335
|
-
case
|
|
332
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
333
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
334
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
335
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
336
336
|
return this.visitInIteration(node, true);
|
|
337
337
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
338
338
|
return this.visitThisExpression(node);
|
|
339
|
-
case
|
|
340
|
-
case
|
|
339
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
340
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
341
341
|
return this.visitFunctionExpressionOrDeclaration(node);
|
|
342
|
-
case
|
|
343
|
-
case
|
|
344
|
-
case
|
|
345
|
-
case
|
|
342
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
343
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
344
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
345
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
346
346
|
return this.visitInClassElement(node);
|
|
347
347
|
}
|
|
348
348
|
return this.visitEachChild(node);
|
|
@@ -393,12 +393,12 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
393
393
|
}
|
|
394
394
|
visitDiscardedValue(node) {
|
|
395
395
|
switch (node.kind) {
|
|
396
|
-
case
|
|
397
|
-
case
|
|
396
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
397
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
398
398
|
return this.visitPreOrPostfixUnaryExpression(node, true);
|
|
399
|
-
case
|
|
399
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
400
400
|
return this.visitBinaryExpression(node, true);
|
|
401
|
-
case
|
|
401
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
402
402
|
return this.factory.updateParenthesizedExpression(node, this.discarded.visitNode(node.expression));
|
|
403
403
|
}
|
|
404
404
|
return this.visit(node);
|
|
@@ -412,7 +412,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
412
412
|
}
|
|
413
413
|
visitClassElement(node) {
|
|
414
414
|
switch (node.kind) {
|
|
415
|
-
case
|
|
415
|
+
case 178 /* SyntaxKind.Constructor */: {
|
|
416
416
|
const saved = this.currentClassElement;
|
|
417
417
|
this.currentClassElement = node;
|
|
418
418
|
const container = this.currentClassContainer;
|
|
@@ -422,35 +422,35 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
422
422
|
this.currentClassElement = saved;
|
|
423
423
|
return result;
|
|
424
424
|
}
|
|
425
|
-
case
|
|
426
|
-
case
|
|
427
|
-
case
|
|
425
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
426
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
427
|
+
case 176 /* SyntaxKind.MethodDeclaration */: {
|
|
428
428
|
const saved = this.currentClassElement;
|
|
429
429
|
this.currentClassElement = node;
|
|
430
430
|
const result = this.visitMethodOrAccessorDeclaration(node);
|
|
431
431
|
this.currentClassElement = saved;
|
|
432
432
|
return result;
|
|
433
433
|
}
|
|
434
|
-
case
|
|
434
|
+
case 174 /* SyntaxKind.PropertyDeclaration */: {
|
|
435
435
|
const saved = this.currentClassElement;
|
|
436
436
|
this.currentClassElement = node;
|
|
437
437
|
const result = this.visitPropertyDeclaration(node);
|
|
438
438
|
this.currentClassElement = saved;
|
|
439
439
|
return result;
|
|
440
440
|
}
|
|
441
|
-
case
|
|
441
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */: {
|
|
442
442
|
const saved = this.currentClassElement;
|
|
443
443
|
this.currentClassElement = node;
|
|
444
444
|
const result = this.shouldTransformPrivateElementsOrClassStaticBlocks ? undefined : this.visitEachChild(node);
|
|
445
445
|
this.currentClassElement = saved;
|
|
446
446
|
return result;
|
|
447
447
|
}
|
|
448
|
-
case
|
|
448
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
449
449
|
return this.visitComputedPropertyName(node);
|
|
450
|
-
case
|
|
450
|
+
case 242 /* SyntaxKind.SemicolonClassElement */:
|
|
451
451
|
return node;
|
|
452
452
|
}
|
|
453
|
-
if (isModifier(node) || node.kind ===
|
|
453
|
+
if (isModifier(node) || node.kind === 172 /* SyntaxKind.Decorator */)
|
|
454
454
|
return this.visitModifier(node);
|
|
455
455
|
return this.visit(node);
|
|
456
456
|
}
|
|
@@ -520,7 +520,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
520
520
|
return false;
|
|
521
521
|
for (let i = 0; i < statics.length; i++) {
|
|
522
522
|
const member = statics[i];
|
|
523
|
-
if (member.kind ===
|
|
523
|
+
if (member.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */ ||
|
|
524
524
|
isPrivateIdentifierClassElementDeclaration(member) ||
|
|
525
525
|
(this.shouldTransformInitializers && isInitializedProperty(member)))
|
|
526
526
|
return true;
|
|
@@ -594,10 +594,11 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
594
594
|
visitMethodOrAccessorDeclaration(node) {
|
|
595
595
|
if (!isPrivateIdentifierClassElementDeclaration(node) || !this.shouldTransformClassElementToWeakMap(node))
|
|
596
596
|
return this.classElementMode.visitEachChild(node);
|
|
597
|
-
|
|
597
|
+
// The member's own class declares it; an untransformed or duplicate name leaves the member as written.
|
|
598
|
+
const info = this.getPrivateIdentifier(this.getPrivateEnvironment(), getName(node));
|
|
598
599
|
if (info === undefined)
|
|
599
600
|
throw new Error('Undeclared private name for property declaration.');
|
|
600
|
-
if (!info.isValid)
|
|
601
|
+
if (info.kind === 3 /* PrivateKind.Untransformed */ || !info.isValid)
|
|
601
602
|
return node;
|
|
602
603
|
const functionName = this.getHoistedFunctionName(node, info);
|
|
603
604
|
if (functionName !== undefined) {
|
|
@@ -619,9 +620,9 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
619
620
|
if (info.kind === 1 /* PrivateKind.Method */)
|
|
620
621
|
return info.methodName;
|
|
621
622
|
if (info.kind === 2 /* PrivateKind.Accessor */) {
|
|
622
|
-
if (node.kind ===
|
|
623
|
+
if (node.kind === 179 /* SyntaxKind.GetAccessor */)
|
|
623
624
|
return info.getterName;
|
|
624
|
-
if (node.kind ===
|
|
625
|
+
if (node.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
625
626
|
return info.setterName;
|
|
626
627
|
}
|
|
627
628
|
return undefined;
|
|
@@ -692,10 +693,10 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
692
693
|
const factory = this.factory;
|
|
693
694
|
if (this.shouldTransformClassElementToWeakMap(node)) {
|
|
694
695
|
// Fields become WeakMaps: the declaration goes.
|
|
695
|
-
const info = this.
|
|
696
|
+
const info = this.getPrivateIdentifier(this.getPrivateEnvironment(), node.name);
|
|
696
697
|
if (info === undefined)
|
|
697
698
|
throw new Error('Undeclared private name for property declaration.');
|
|
698
|
-
if (!info.isValid)
|
|
699
|
+
if (info.kind === 3 /* PrivateKind.Untransformed */ || !info.isValid)
|
|
699
700
|
return node;
|
|
700
701
|
// A static field of a class whose static blocks stay becomes a static block.
|
|
701
702
|
if (info.isStatic && !this.shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
@@ -810,11 +811,12 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
810
811
|
}
|
|
811
812
|
// Property names are not references and are never substituted.
|
|
812
813
|
if (node.name instanceof Identifier)
|
|
813
|
-
return this.visitPropertyAccessExpressionForSubstitution(node);
|
|
814
|
+
return this.visitPropertyAccessExpressionForSubstitution(node, this);
|
|
814
815
|
return this.visitEachChild(node);
|
|
815
816
|
}
|
|
816
|
-
|
|
817
|
-
|
|
817
|
+
/** Visits only the expression of a property access, with `visitor`, so that its name is never substituted. */
|
|
818
|
+
visitPropertyAccessExpressionForSubstitution(node, visitor) {
|
|
819
|
+
const expression = visitor.visitNode(node.expression);
|
|
818
820
|
if (expression === node.expression)
|
|
819
821
|
return node;
|
|
820
822
|
return this.factory.updatePropertyAccessExpression(node, expression, node.questionDotToken, node.name, node.flags);
|
|
@@ -1379,12 +1381,11 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1379
1381
|
}
|
|
1380
1382
|
const statics = staticPropertiesAndClassStaticBlocks(node);
|
|
1381
1383
|
// Aliases must be known before visiting members, so predict whether a temporary will wrap the class.
|
|
1384
|
+
const hasTransformableStatics = this.hasTransformableStatics(node, statics);
|
|
1382
1385
|
let isClassWithConstructorReference = false;
|
|
1383
|
-
let hasTransformableStatics = false;
|
|
1384
1386
|
let deferTempDeclaration = false;
|
|
1385
1387
|
if (!isDecoratedClassDeclaration) {
|
|
1386
1388
|
isClassWithConstructorReference = this.classContainsConstructorReference(node);
|
|
1387
|
-
hasTransformableStatics = this.hasTransformableStatics(node, statics);
|
|
1388
1389
|
let willHavePrivatePendingExpressions = false;
|
|
1389
1390
|
if (this.shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
1390
1391
|
const members = node.members.nodes;
|
|
@@ -1441,7 +1442,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1441
1442
|
else
|
|
1442
1443
|
expressions.push(classExpression);
|
|
1443
1444
|
}
|
|
1444
|
-
else {
|
|
1445
|
+
else if (hasTransformableStatics || this.pendingExpressions.length > 0) {
|
|
1445
1446
|
for (let i = 0; i < this.pendingExpressions.length; i++)
|
|
1446
1447
|
this.pendingStatements.push(factory.createExpressionStatement(this.pendingExpressions[i]));
|
|
1447
1448
|
if (statics.length > 0) {
|
|
@@ -1455,6 +1456,8 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1455
1456
|
else
|
|
1456
1457
|
expressions.push(classExpression);
|
|
1457
1458
|
}
|
|
1459
|
+
else
|
|
1460
|
+
expressions.push(classExpression);
|
|
1458
1461
|
if (expressions.length > 1) {
|
|
1459
1462
|
context.addEmitFlags(classExpression, 8192 /* EmitFlags.Indented */);
|
|
1460
1463
|
for (let i = 0; i < expressions.length; i++)
|
|
@@ -1527,7 +1530,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1527
1530
|
let syntheticConstructor = undefined;
|
|
1528
1531
|
let hasConstructor = false;
|
|
1529
1532
|
for (let i = 0; i < members.nodes.length; i++)
|
|
1530
|
-
if (members.nodes[i].kind ===
|
|
1533
|
+
if (members.nodes[i].kind === 178 /* SyntaxKind.Constructor */)
|
|
1531
1534
|
hasConstructor = true;
|
|
1532
1535
|
if (!hasConstructor)
|
|
1533
1536
|
syntheticConstructor = this.transformConstructor(undefined, node);
|
|
@@ -1948,14 +1951,14 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1948
1951
|
info.setterName = this.createHoistedVariableForPrivateName(name, '_set');
|
|
1949
1952
|
this.setPrivateIdentifier(environment, name, info);
|
|
1950
1953
|
}
|
|
1951
|
-
else if (node.kind ===
|
|
1954
|
+
else if (node.kind === 176 /* SyntaxKind.MethodDeclaration */) {
|
|
1952
1955
|
const methodName = this.createHoistedVariableForPrivateName(name, '');
|
|
1953
1956
|
const info = new PrivateIdentifierInfo(1 /* PrivateKind.Method */, brandCheck, isStaticMember, isValid);
|
|
1954
1957
|
info.methodName = methodName;
|
|
1955
1958
|
this.setPrivateIdentifier(environment, name, info);
|
|
1956
1959
|
}
|
|
1957
1960
|
else {
|
|
1958
|
-
const getter = node.kind ===
|
|
1961
|
+
const getter = node.kind === 179 /* SyntaxKind.GetAccessor */;
|
|
1959
1962
|
const accessorName = this.createHoistedVariableForPrivateName(name, getter ? '_get' : '_set');
|
|
1960
1963
|
// A get and set accessor pair shares one entry.
|
|
1961
1964
|
if (previous !== undefined &&
|
|
@@ -2083,7 +2086,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
2083
2086
|
return this.factory.updateSpreadElement(node, this.visitDestructuringAssignmentTarget(node.expression));
|
|
2084
2087
|
return this.visitEachChild(node);
|
|
2085
2088
|
}
|
|
2086
|
-
if (node.kind !==
|
|
2089
|
+
if (node.kind !== 234 /* SyntaxKind.OmittedExpression */)
|
|
2087
2090
|
return this.visitAssignmentElement(node);
|
|
2088
2091
|
}
|
|
2089
2092
|
return this.visitEachChild(node);
|
|
@@ -2203,8 +2206,8 @@ function isSuperProperty(node) {
|
|
|
2203
2206
|
return false;
|
|
2204
2207
|
}
|
|
2205
2208
|
function isStaticPropertyDeclarationOrClassStaticBlock(node) {
|
|
2206
|
-
return (node.kind ===
|
|
2207
|
-
(node.kind ===
|
|
2209
|
+
return (node.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */ ||
|
|
2210
|
+
(node.kind === 174 /* SyntaxKind.PropertyDeclaration */ && hasStaticModifier(node)));
|
|
2208
2211
|
}
|
|
2209
2212
|
function isCompoundAssignment(kind) {
|
|
2210
2213
|
return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ && kind <= 78 /* SyntaxKind.LastCompoundAssignment */;
|
|
@@ -2252,7 +2255,7 @@ function isSimpleCopiableExpression(node) {
|
|
|
2252
2255
|
case 79 /* SyntaxKind.Identifier */:
|
|
2253
2256
|
return true;
|
|
2254
2257
|
}
|
|
2255
|
-
return node.kind >= 82 /* SyntaxKind.FirstKeyword */ && node.kind <=
|
|
2258
|
+
return node.kind >= 82 /* SyntaxKind.FirstKeyword */ && node.kind <= 167 /* SyntaxKind.LastKeyword */;
|
|
2256
2259
|
}
|
|
2257
2260
|
/** A literal or keyword that can be repeated; identifiers may be reassigned in between. */
|
|
2258
2261
|
function isSimpleInlineableExpression(node) {
|
|
@@ -2271,14 +2274,14 @@ function shouldBeCapturedInTempVariable(node) {
|
|
|
2271
2274
|
}
|
|
2272
2275
|
function isArrayBindingOrAssignmentElement(node) {
|
|
2273
2276
|
switch (node.kind) {
|
|
2274
|
-
case
|
|
2275
|
-
case
|
|
2276
|
-
case
|
|
2277
|
-
case
|
|
2278
|
-
case
|
|
2277
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
2278
|
+
case 234 /* SyntaxKind.OmittedExpression */:
|
|
2279
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
2280
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
2281
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
2279
2282
|
case 79 /* SyntaxKind.Identifier */:
|
|
2280
|
-
case
|
|
2281
|
-
case
|
|
2283
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
2284
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
2282
2285
|
return true;
|
|
2283
2286
|
}
|
|
2284
2287
|
return isAssignmentExpression(node, true);
|
|
@@ -2288,8 +2291,8 @@ function staticPropertiesAndClassStaticBlocks(node) {
|
|
|
2288
2291
|
const members = membersOf(node);
|
|
2289
2292
|
for (let i = 0; i < members.length; i++) {
|
|
2290
2293
|
const member = members[i];
|
|
2291
|
-
if (member.kind ===
|
|
2292
|
-
(member.kind ===
|
|
2294
|
+
if (member.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */ ||
|
|
2295
|
+
(member.kind === 174 /* SyntaxKind.PropertyDeclaration */ && hasStaticModifier(member)))
|
|
2293
2296
|
result.push(member);
|
|
2294
2297
|
}
|
|
2295
2298
|
return result;
|
|
@@ -2333,7 +2336,7 @@ function getClassExtendsHeritageElement(node) {
|
|
|
2333
2336
|
}
|
|
2334
2337
|
/** Whether a class or its constructor's parameters have decorators that apply. */
|
|
2335
2338
|
function classOrConstructorParameterIsDecorated(legacy, node) {
|
|
2336
|
-
if (hasDecorators(node) && (node.kind ===
|
|
2339
|
+
if (hasDecorators(node) && (node.kind === 265 /* SyntaxKind.ClassDeclaration */ || !legacy))
|
|
2337
2340
|
return true;
|
|
2338
2341
|
if (!legacy)
|
|
2339
2342
|
return false;
|
|
@@ -2381,7 +2384,7 @@ function posPastModifiers(node) {
|
|
|
2381
2384
|
return node.name.pos;
|
|
2382
2385
|
if (node instanceof MethodDeclaration)
|
|
2383
2386
|
return node.name.pos;
|
|
2384
|
-
if (node.kind ===
|
|
2387
|
+
if (node.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */)
|
|
2385
2388
|
return node.pos;
|
|
2386
2389
|
const modifiers = getModifiers(node);
|
|
2387
2390
|
if (modifiers === undefined || modifiers.nodes.length === 0)
|
|
@@ -2390,7 +2393,7 @@ function posPastModifiers(node) {
|
|
|
2390
2393
|
if (last.end >= 0)
|
|
2391
2394
|
return last.end;
|
|
2392
2395
|
for (let i = modifiers.nodes.length - 1; i >= 0; i--)
|
|
2393
|
-
if (modifiers.nodes[i].kind ===
|
|
2396
|
+
if (modifiers.nodes[i].kind === 172 /* SyntaxKind.Decorator */)
|
|
2394
2397
|
return modifiers.nodes[i].end >= 0 ? modifiers.nodes[i].end : node.pos;
|
|
2395
2398
|
return node.pos;
|
|
2396
2399
|
}
|
|
@@ -135,8 +135,10 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
135
135
|
const statement = nested.visitStatement(node.statement);
|
|
136
136
|
return factory.updateLabeledStatement(node, node.label, statement !== undefined ? statement : factory.created(new EmptyStatement()));
|
|
137
137
|
}
|
|
138
|
-
if (node instanceof WithStatement)
|
|
139
|
-
|
|
138
|
+
if (node instanceof WithStatement) {
|
|
139
|
+
const statement = nested.visitStatement(node.statement);
|
|
140
|
+
return factory.updateWithStatement(node, this.visitNode(node.expression), statement !== undefined ? statement : factory.created(new EmptyStatement()));
|
|
141
|
+
}
|
|
140
142
|
if (node instanceof IfStatement) {
|
|
141
143
|
const thenStatement = nested.visitStatement(node.thenStatement);
|
|
142
144
|
return factory.updateIfStatement(node, this.visitNode(node.expression), thenStatement !== undefined ? thenStatement : factory.createBlock([], false), nested.visitStatement(node.elseStatement));
|
|
@@ -160,9 +162,9 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
160
162
|
if (node instanceof SourceFile)
|
|
161
163
|
return this.visitSourceFile(node);
|
|
162
164
|
if (node instanceof ForStatement)
|
|
163
|
-
return this.factory.updateForStatement(node, this.discarded.visitNode(node.initializer), this.visitNode(node.condition), this.discarded.visitNode(node.incrementor), this.
|
|
165
|
+
return this.factory.updateForStatement(node, this.discarded.visitNode(node.initializer), this.visitNode(node.condition), this.discarded.visitNode(node.incrementor), this.visitIterationBody(node.statement));
|
|
164
166
|
if (node instanceof ForInOrOfStatement)
|
|
165
|
-
return this.factory.updateForInOrOfStatement(node, node.awaitModifier, this.discarded.visitNode(node.initializer), this.visitNode(node.expression), this.
|
|
167
|
+
return this.factory.updateForInOrOfStatement(node, node.awaitModifier, this.discarded.visitNode(node.initializer), this.visitNode(node.expression), this.visitIterationBody(node.statement));
|
|
166
168
|
if (node instanceof ExpressionStatement || node instanceof VoidExpression)
|
|
167
169
|
return this.discarded.visitEachChild(node);
|
|
168
170
|
if (node instanceof ParenthesizedExpression)
|
|
@@ -199,7 +201,7 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
199
201
|
shouldEmitUnderscoreUnderscoreESModule(file) {
|
|
200
202
|
if (fileExtensionIsOneOf(file.fileName, supportedJSExtensions) &&
|
|
201
203
|
file.commonJSModuleIndicator !== undefined &&
|
|
202
|
-
(file.externalModuleIndicator === undefined || file.externalModuleIndicator.kind ===
|
|
204
|
+
(file.externalModuleIndicator === undefined || file.externalModuleIndicator.kind === 308 /* SyntaxKind.SourceFile */))
|
|
203
205
|
return false;
|
|
204
206
|
return this.moduleInfo().exportEquals === undefined && isExternalModule(file);
|
|
205
207
|
}
|
|
@@ -312,9 +314,9 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
312
314
|
if (clause.name !== undefined)
|
|
313
315
|
this.appendExportsOfDeclaration(statements, clause, seen, false);
|
|
314
316
|
const bindings = clause.namedBindings;
|
|
315
|
-
if (bindings !== undefined && bindings.kind ===
|
|
317
|
+
if (bindings !== undefined && bindings.kind === 276 /* SyntaxKind.NamespaceImport */)
|
|
316
318
|
this.appendExportsOfDeclaration(statements, bindings, seen, false);
|
|
317
|
-
else if (bindings !== undefined && bindings.kind ===
|
|
319
|
+
else if (bindings !== undefined && bindings.kind === 277 /* SyntaxKind.NamedImports */) {
|
|
318
320
|
const elements = bindingElementsOf(bindings);
|
|
319
321
|
for (let i = 0; i < elements.length; i++)
|
|
320
322
|
this.appendExportsOfDeclaration(statements, elements[i], seen, true);
|
|
@@ -338,7 +340,7 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
338
340
|
if (name instanceof BindingPattern) {
|
|
339
341
|
const elements = name.elements.nodes;
|
|
340
342
|
for (let i = 0; i < elements.length; i++)
|
|
341
|
-
if (elements[i].kind !==
|
|
343
|
+
if (elements[i].kind !== 234 /* SyntaxKind.OmittedExpression */)
|
|
342
344
|
this.appendExportsOfBindingElement(statements, elements[i], isForInOrOfInitializer);
|
|
343
345
|
return true;
|
|
344
346
|
}
|
|
@@ -737,9 +739,9 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
737
739
|
if (this.destructuringNeedsFlattening(element.expression))
|
|
738
740
|
return true;
|
|
739
741
|
}
|
|
740
|
-
else if (element.kind ===
|
|
741
|
-
element.kind ===
|
|
742
|
-
element.kind ===
|
|
742
|
+
else if (element.kind === 176 /* SyntaxKind.MethodDeclaration */ ||
|
|
743
|
+
element.kind === 179 /* SyntaxKind.GetAccessor */ ||
|
|
744
|
+
element.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
743
745
|
return false;
|
|
744
746
|
}
|
|
745
747
|
return false;
|
|
@@ -862,7 +864,8 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
862
864
|
visitCallExpression(node) {
|
|
863
865
|
const rewrite = this.options.rewriteRelativeImportExtensions === true &&
|
|
864
866
|
((isImportCall(node) && node.arguments.nodes.length > 0) || (isInJSFile(node) && isRequireCall(node, false)));
|
|
865
|
-
|
|
867
|
+
// `import.source()` and the other phase imports stay as written.
|
|
868
|
+
if (node.expression.kind === 101 /* SyntaxKind.ImportKeyword */ && this.shouldTransformImportCall())
|
|
866
869
|
return this.visitImportCallExpression(node, rewrite);
|
|
867
870
|
if (rewrite)
|
|
868
871
|
return this.rewriteImportOrRequireCall(node);
|
|
@@ -929,13 +932,13 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
929
932
|
let args = node.arguments;
|
|
930
933
|
const nodes = args.nodes;
|
|
931
934
|
if (nodes.length > 0) {
|
|
932
|
-
const first = nodes[0];
|
|
935
|
+
const first = this.visitNode(nodes[0]);
|
|
933
936
|
const rewritten = first instanceof StringLiteral || first.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */
|
|
934
937
|
? rewriteModuleSpecifier(this.context, first, this.options)
|
|
935
938
|
: factory.createRewriteRelativeImportExtensionsHelper(first, this.options.jsx === JsxEmit.Preserve);
|
|
936
939
|
const rest = nodes.slice(1);
|
|
937
940
|
const visitedRest = this.visitArray(rest);
|
|
938
|
-
if (rewritten !==
|
|
941
|
+
if (rewritten !== nodes[0] || visitedRest !== rest)
|
|
939
942
|
args = new NodeList(args.pos, args.end, [rewritten].concat(visitedRest));
|
|
940
943
|
}
|
|
941
944
|
return factory.updateCallExpression(node, expression, callQuestionDotToken(node), undefined, args, node.flags);
|
|
@@ -1157,7 +1160,7 @@ function isDeclarationNameOfEnumOrNamespace(original) {
|
|
|
1157
1160
|
const parent = original.parent;
|
|
1158
1161
|
if (parent === undefined)
|
|
1159
1162
|
return false;
|
|
1160
|
-
if (parent.kind !==
|
|
1163
|
+
if (parent.kind !== 268 /* SyntaxKind.EnumDeclaration */ && parent.kind !== 269 /* SyntaxKind.ModuleDeclaration */)
|
|
1161
1164
|
return false;
|
|
1162
1165
|
return getName(parent) === original;
|
|
1163
1166
|
}
|
|
@@ -11,7 +11,7 @@ export class ConstEnumInliner extends Transformer {
|
|
|
11
11
|
this.resolver = resolver;
|
|
12
12
|
}
|
|
13
13
|
visit(node) {
|
|
14
|
-
if (node.kind !==
|
|
14
|
+
if (node.kind !== 213 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 214 /* SyntaxKind.ElementAccessExpression */)
|
|
15
15
|
return this.visitEachChild(node);
|
|
16
16
|
const parseNode = this.context.parseNode(node);
|
|
17
17
|
if (parseNode === undefined)
|