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
|
@@ -22,7 +22,7 @@ export function hasStaticModifier(node) {
|
|
|
22
22
|
/** The declaration a binding element belongs to. */
|
|
23
23
|
export function getRootDeclaration(node) {
|
|
24
24
|
let current = node;
|
|
25
|
-
while (current.kind ===
|
|
25
|
+
while (current.kind === 210 /* SyntaxKind.BindingElement */)
|
|
26
26
|
current = current.parent.parent;
|
|
27
27
|
return current;
|
|
28
28
|
}
|
|
@@ -31,20 +31,20 @@ export function getCombinedModifierFlags(node) {
|
|
|
31
31
|
// Locals stay non-optional: native builds box a `Node | undefined` local at every assignment.
|
|
32
32
|
let current = getRootDeclaration(node);
|
|
33
33
|
let flags = getModifierFlags(current);
|
|
34
|
-
if (current.kind ===
|
|
34
|
+
if (current.kind === 262 /* SyntaxKind.VariableDeclaration */) {
|
|
35
35
|
const parent = current.parent;
|
|
36
36
|
if (parent === undefined)
|
|
37
37
|
return flags;
|
|
38
38
|
current = parent;
|
|
39
39
|
}
|
|
40
|
-
if (current.kind ===
|
|
40
|
+
if (current.kind === 263 /* SyntaxKind.VariableDeclarationList */) {
|
|
41
41
|
flags |= getModifierFlags(current);
|
|
42
42
|
const parent = current.parent;
|
|
43
43
|
if (parent === undefined)
|
|
44
44
|
return flags;
|
|
45
45
|
current = parent;
|
|
46
46
|
}
|
|
47
|
-
if (current.kind ===
|
|
47
|
+
if (current.kind === 245 /* SyntaxKind.VariableStatement */)
|
|
48
48
|
flags |= getModifierFlags(current);
|
|
49
49
|
return flags;
|
|
50
50
|
}
|
|
@@ -53,20 +53,20 @@ export function getCombinedNodeFlags(node) {
|
|
|
53
53
|
// Locals stay non-optional, as in getCombinedModifierFlags.
|
|
54
54
|
let current = getRootDeclaration(node);
|
|
55
55
|
let flags = current.flags;
|
|
56
|
-
if (current.kind ===
|
|
56
|
+
if (current.kind === 262 /* SyntaxKind.VariableDeclaration */) {
|
|
57
57
|
const parent = current.parent;
|
|
58
58
|
if (parent === undefined)
|
|
59
59
|
return flags;
|
|
60
60
|
current = parent;
|
|
61
61
|
}
|
|
62
|
-
if (current.kind ===
|
|
62
|
+
if (current.kind === 263 /* SyntaxKind.VariableDeclarationList */) {
|
|
63
63
|
flags |= current.flags;
|
|
64
64
|
const parent = current.parent;
|
|
65
65
|
if (parent === undefined)
|
|
66
66
|
return flags;
|
|
67
67
|
current = parent;
|
|
68
68
|
}
|
|
69
|
-
if (current.kind ===
|
|
69
|
+
if (current.kind === 245 /* SyntaxKind.VariableStatement */)
|
|
70
70
|
flags |= current.flags;
|
|
71
71
|
return flags;
|
|
72
72
|
}
|
|
@@ -85,7 +85,7 @@ export function isJsonSourceFile(file) {
|
|
|
85
85
|
}
|
|
86
86
|
/** A source file whose declarations are global. */
|
|
87
87
|
export function isGlobalSourceFile(node) {
|
|
88
|
-
return node.kind ===
|
|
88
|
+
return node.kind === 308 /* SyntaxKind.SourceFile */ && !isExternalOrCommonJSModule(node);
|
|
89
89
|
}
|
|
90
90
|
export function getSourceFileOfNode(node) {
|
|
91
91
|
// Walks parents without rebinding `node`, which native builds would box at every step.
|
|
@@ -101,42 +101,42 @@ export function getSourceFileOfNode(node) {
|
|
|
101
101
|
}
|
|
102
102
|
// Kinds
|
|
103
103
|
export function isClassLike(node) {
|
|
104
|
-
return node.kind ===
|
|
104
|
+
return node.kind === 265 /* SyntaxKind.ClassDeclaration */ || node.kind === 233 /* SyntaxKind.ClassExpression */;
|
|
105
105
|
}
|
|
106
106
|
export function isClassElement(node) {
|
|
107
107
|
switch (node.kind) {
|
|
108
|
-
case
|
|
109
|
-
case
|
|
110
|
-
case
|
|
111
|
-
case
|
|
112
|
-
case
|
|
113
|
-
case
|
|
114
|
-
case
|
|
115
|
-
case
|
|
108
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
109
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
110
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
111
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
112
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
113
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
114
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
115
|
+
case 242 /* SyntaxKind.SemicolonClassElement */:
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
118
|
return false;
|
|
119
119
|
}
|
|
120
120
|
/** As the spec's IsStatic: a static class element or a static block. */
|
|
121
121
|
export function isStatic(node) {
|
|
122
|
-
return (isClassElement(node) && hasStaticModifier(node)) || node.kind ===
|
|
122
|
+
return (isClassElement(node) && hasStaticModifier(node)) || node.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */;
|
|
123
123
|
}
|
|
124
124
|
export function isDeclarationStatementKind(kind) {
|
|
125
125
|
switch (kind) {
|
|
126
|
-
case
|
|
127
|
-
case
|
|
128
|
-
case
|
|
129
|
-
case
|
|
130
|
-
case
|
|
131
|
-
case
|
|
132
|
-
case
|
|
133
|
-
case
|
|
134
|
-
case
|
|
135
|
-
case
|
|
136
|
-
case
|
|
137
|
-
case
|
|
138
|
-
case
|
|
139
|
-
case
|
|
126
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
127
|
+
case 284 /* SyntaxKind.MissingDeclaration */:
|
|
128
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
129
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
130
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
131
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
132
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
133
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
134
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
135
|
+
case 347 /* SyntaxKind.JSImportDeclaration */:
|
|
136
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
137
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
138
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
139
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
140
140
|
return true;
|
|
141
141
|
}
|
|
142
142
|
return false;
|
|
@@ -155,24 +155,24 @@ export function isTypeNodeKind(kind) {
|
|
|
155
155
|
case 157 /* SyntaxKind.UndefinedKeyword */:
|
|
156
156
|
case 146 /* SyntaxKind.NeverKeyword */:
|
|
157
157
|
case 141 /* SyntaxKind.IntrinsicKeyword */:
|
|
158
|
-
case
|
|
159
|
-
case
|
|
160
|
-
case
|
|
161
|
-
case
|
|
162
|
-
case
|
|
163
|
-
case
|
|
158
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
159
|
+
case 311 /* SyntaxKind.JSDocAllType */:
|
|
160
|
+
case 312 /* SyntaxKind.JSDocNullableType */:
|
|
161
|
+
case 313 /* SyntaxKind.JSDocNonNullableType */:
|
|
162
|
+
case 314 /* SyntaxKind.JSDocOptionalType */:
|
|
163
|
+
case 315 /* SyntaxKind.JSDocVariadicType */:
|
|
164
164
|
return true;
|
|
165
165
|
}
|
|
166
|
-
return kind >=
|
|
166
|
+
return kind >= 184 /* SyntaxKind.FirstTypeNode */ && kind <= 207 /* SyntaxKind.LastTypeNode */;
|
|
167
167
|
}
|
|
168
168
|
export function isFunctionExpressionOrArrowFunction(node) {
|
|
169
|
-
return node.kind ===
|
|
169
|
+
return node.kind === 220 /* SyntaxKind.FunctionExpression */ || node.kind === 221 /* SyntaxKind.ArrowFunction */;
|
|
170
170
|
}
|
|
171
171
|
export function isMethodOrAccessor(node) {
|
|
172
172
|
switch (node.kind) {
|
|
173
|
-
case
|
|
174
|
-
case
|
|
175
|
-
case
|
|
173
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
174
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
175
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
176
176
|
return true;
|
|
177
177
|
}
|
|
178
178
|
return false;
|
|
@@ -181,33 +181,33 @@ export function isObjectLiteralOrClassExpressionMethodOrAccessor(node) {
|
|
|
181
181
|
if (!isMethodOrAccessor(node))
|
|
182
182
|
return false;
|
|
183
183
|
const parentKind = node.parent.kind;
|
|
184
|
-
return parentKind ===
|
|
184
|
+
return parentKind === 212 /* SyntaxKind.ObjectLiteralExpression */ || parentKind === 233 /* SyntaxKind.ClassExpression */;
|
|
185
185
|
}
|
|
186
186
|
export function isObjectLiteralMethod(node) {
|
|
187
187
|
return (node !== undefined &&
|
|
188
|
-
node.kind ===
|
|
189
|
-
node.parent.kind ===
|
|
188
|
+
node.kind === 176 /* SyntaxKind.MethodDeclaration */ &&
|
|
189
|
+
node.parent.kind === 212 /* SyntaxKind.ObjectLiteralExpression */);
|
|
190
190
|
}
|
|
191
191
|
export function isAutoAccessorPropertyDeclaration(node) {
|
|
192
|
-
return node.kind ===
|
|
192
|
+
return node.kind === 174 /* SyntaxKind.PropertyDeclaration */ && hasSyntacticModifier(node, 512 /* ModifierFlags.Accessor */);
|
|
193
193
|
}
|
|
194
194
|
export function isParameterPropertyDeclaration(node, parent) {
|
|
195
|
-
return (node.kind ===
|
|
195
|
+
return (node.kind === 171 /* SyntaxKind.Parameter */ &&
|
|
196
196
|
hasSyntacticModifier(node, 31 /* ModifierFlags.ParameterPropertyModifier */) &&
|
|
197
|
-
parent.kind ===
|
|
197
|
+
parent.kind === 178 /* SyntaxKind.Constructor */);
|
|
198
198
|
}
|
|
199
199
|
export function isPrivateIdentifierClassElementDeclaration(node) {
|
|
200
|
-
if (node.kind !==
|
|
200
|
+
if (node.kind !== 174 /* SyntaxKind.PropertyDeclaration */ && !isMethodOrAccessor(node))
|
|
201
201
|
return false;
|
|
202
202
|
const name = getName(node);
|
|
203
203
|
return name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */;
|
|
204
204
|
}
|
|
205
205
|
export function isAsyncFunction(node) {
|
|
206
206
|
switch (node.kind) {
|
|
207
|
-
case
|
|
208
|
-
case
|
|
209
|
-
case
|
|
210
|
-
case
|
|
207
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
208
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
209
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
210
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
211
211
|
return (getBody(node) !== undefined &&
|
|
212
212
|
getAsteriskToken(node) === undefined &&
|
|
213
213
|
hasSyntacticModifier(node, 1024 /* ModifierFlags.Async */));
|
|
@@ -275,17 +275,17 @@ export function isOptionalChain(node) {
|
|
|
275
275
|
if ((node.flags & 32 /* NodeFlags.OptionalChain */) === 0)
|
|
276
276
|
return false;
|
|
277
277
|
switch (node.kind) {
|
|
278
|
-
case
|
|
279
|
-
case
|
|
280
|
-
case
|
|
281
|
-
case
|
|
278
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
279
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
280
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
281
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
282
282
|
return true;
|
|
283
283
|
}
|
|
284
284
|
return false;
|
|
285
285
|
}
|
|
286
286
|
/** The link of an optional chain with the `?.`. */
|
|
287
287
|
export function isOptionalChainRoot(node) {
|
|
288
|
-
return isOptionalChain(node) && node.kind !==
|
|
288
|
+
return isOptionalChain(node) && node.kind !== 237 /* SyntaxKind.NonNullExpression */ && getQuestionDotToken(node) !== undefined;
|
|
289
289
|
}
|
|
290
290
|
/** Whether `node` is the whole optional chain, not a link in a longer one. */
|
|
291
291
|
export function isOutermostOptionalChain(node) {
|
|
@@ -349,7 +349,7 @@ export function isDestructuringAssignment(node) {
|
|
|
349
349
|
if (!isAssignmentExpression(node, true))
|
|
350
350
|
return false;
|
|
351
351
|
const kind = node.left.kind;
|
|
352
|
-
return kind ===
|
|
352
|
+
return kind === 212 /* SyntaxKind.ObjectLiteralExpression */ || kind === 211 /* SyntaxKind.ArrayLiteralExpression */;
|
|
353
353
|
}
|
|
354
354
|
/** The assignment, update or `for…in`/`for…of` that writes to `node`, if any. */
|
|
355
355
|
export function getAssignmentTarget(node) {
|
|
@@ -357,36 +357,36 @@ export function getAssignmentTarget(node) {
|
|
|
357
357
|
for (;;) {
|
|
358
358
|
const parent = current.parent;
|
|
359
359
|
switch (parent.kind) {
|
|
360
|
-
case
|
|
360
|
+
case 228 /* SyntaxKind.BinaryExpression */: {
|
|
361
361
|
const binary = parent;
|
|
362
362
|
return isAssignmentOperator(binary.operatorToken.kind) && binary.left === current ? parent : undefined;
|
|
363
363
|
}
|
|
364
|
-
case
|
|
364
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */: {
|
|
365
365
|
const operator = parent.operator;
|
|
366
366
|
return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? parent : undefined;
|
|
367
367
|
}
|
|
368
|
-
case
|
|
368
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */: {
|
|
369
369
|
const operator = parent.operator;
|
|
370
370
|
return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? parent : undefined;
|
|
371
371
|
}
|
|
372
|
-
case
|
|
373
|
-
case
|
|
372
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
373
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
374
374
|
return getInitializer(parent) === current ? parent : undefined;
|
|
375
|
-
case
|
|
376
|
-
case
|
|
377
|
-
case
|
|
378
|
-
case
|
|
375
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
376
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
377
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
378
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
379
379
|
current = parent;
|
|
380
380
|
break;
|
|
381
|
-
case
|
|
381
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
382
382
|
current = parent.parent;
|
|
383
383
|
break;
|
|
384
|
-
case
|
|
384
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
385
385
|
if (getName(parent) !== current)
|
|
386
386
|
return undefined;
|
|
387
387
|
current = parent.parent;
|
|
388
388
|
break;
|
|
389
|
-
case
|
|
389
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
390
390
|
if (getName(parent) === current)
|
|
391
391
|
return undefined;
|
|
392
392
|
current = parent.parent;
|
|
@@ -407,12 +407,12 @@ export function isDottedName(node) {
|
|
|
407
407
|
case 79 /* SyntaxKind.Identifier */:
|
|
408
408
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
409
409
|
case 107 /* SyntaxKind.SuperKeyword */:
|
|
410
|
-
case
|
|
410
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
411
411
|
return true;
|
|
412
|
-
case
|
|
412
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
413
413
|
current = current.expression;
|
|
414
414
|
break;
|
|
415
|
-
case
|
|
415
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
416
416
|
current = current.expression;
|
|
417
417
|
break;
|
|
418
418
|
default:
|
|
@@ -439,10 +439,10 @@ export function isEntityNameExpression(node, allowJS) {
|
|
|
439
439
|
}
|
|
440
440
|
/** An `export default` or `module.exports =` expression that aliases a declaration. */
|
|
441
441
|
export function expressionIsAlias(node) {
|
|
442
|
-
return isEntityNameExpression(node, false) || node.kind ===
|
|
442
|
+
return isEntityNameExpression(node, false) || node.kind === 233 /* SyntaxKind.ClassExpression */;
|
|
443
443
|
}
|
|
444
444
|
export function isAccessExpression(node) {
|
|
445
|
-
return node.kind ===
|
|
445
|
+
return node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 214 /* SyntaxKind.ElementAccessExpression */;
|
|
446
446
|
}
|
|
447
447
|
/** The name of `x.name` or the literal of `x["name"]`. */
|
|
448
448
|
export function getElementOrPropertyAccessName(node) {
|
|
@@ -466,7 +466,7 @@ export function getImmediatelyInvokedFunctionExpression(fn) {
|
|
|
466
466
|
return undefined;
|
|
467
467
|
let prev = fn;
|
|
468
468
|
let parent = fn.parent;
|
|
469
|
-
while (parent.kind ===
|
|
469
|
+
while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */) {
|
|
470
470
|
prev = parent;
|
|
471
471
|
parent = parent.parent;
|
|
472
472
|
}
|
|
@@ -477,7 +477,7 @@ export function getImmediatelyInvokedFunctionExpression(fn) {
|
|
|
477
477
|
}
|
|
478
478
|
/** `x as const` or `<const>x`. */
|
|
479
479
|
export function isConstAssertion(node) {
|
|
480
|
-
if (node.kind !==
|
|
480
|
+
if (node.kind !== 236 /* SyntaxKind.AsExpression */ && node.kind !== 218 /* SyntaxKind.TypeAssertionExpression */)
|
|
481
481
|
return false;
|
|
482
482
|
const type = getType(node);
|
|
483
483
|
if (!(type instanceof TypeReferenceNode))
|
|
@@ -564,7 +564,7 @@ export function getAssignmentDeclarationKind(node) {
|
|
|
564
564
|
return 4 /* JSDeclarationKind.Property */;
|
|
565
565
|
return 0 /* JSDeclarationKind.None */;
|
|
566
566
|
}
|
|
567
|
-
if (node.kind ===
|
|
567
|
+
if (node.kind === 215 /* SyntaxKind.CallExpression */ &&
|
|
568
568
|
(node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0 &&
|
|
569
569
|
isBindableObjectDefinePropertyCall(node)) {
|
|
570
570
|
const entityName = getArguments(node).nodes[0];
|
|
@@ -582,15 +582,15 @@ export function isExpandoInitializer(declaration, initializer) {
|
|
|
582
582
|
return true;
|
|
583
583
|
if ((initializer.flags & 65536 /* NodeFlags.JavaScriptFile */) === 0)
|
|
584
584
|
return false;
|
|
585
|
-
if (initializer.kind ===
|
|
585
|
+
if (initializer.kind === 233 /* SyntaxKind.ClassExpression */)
|
|
586
586
|
return true;
|
|
587
|
-
return (initializer.kind ===
|
|
587
|
+
return (initializer.kind === 212 /* SyntaxKind.ObjectLiteralExpression */ &&
|
|
588
588
|
getProperties(initializer).nodes.length === 0 &&
|
|
589
589
|
getType(declaration) === undefined);
|
|
590
590
|
}
|
|
591
591
|
/** `const x = require("m")` in JavaScript, or a binding element of one. */
|
|
592
592
|
export function isVariableDeclarationInitializedToRequire(node) {
|
|
593
|
-
const candidate = node.kind ===
|
|
593
|
+
const candidate = node.kind === 210 /* SyntaxKind.BindingElement */ ? node.parent.parent : node;
|
|
594
594
|
if (!(candidate instanceof VariableDeclaration) ||
|
|
595
595
|
(candidate.flags & 65536 /* NodeFlags.JavaScriptFile */) === 0)
|
|
596
596
|
return false;
|
|
@@ -611,18 +611,18 @@ function isRequireCallWithLiteral(node) {
|
|
|
611
611
|
/** A `@typedef` or `@callback` at the top level of a module. */
|
|
612
612
|
export function isImplicitlyExportedJSDocDeclaration(node) {
|
|
613
613
|
const parent = node.parent;
|
|
614
|
-
if (parent.kind !==
|
|
614
|
+
if (parent.kind !== 308 /* SyntaxKind.SourceFile */ || !isExternalOrCommonJSModule(parent))
|
|
615
615
|
return false;
|
|
616
|
-
if (node.kind ===
|
|
616
|
+
if (node.kind === 346 /* SyntaxKind.JSTypeAliasDeclaration */)
|
|
617
617
|
return true;
|
|
618
|
-
return node.kind ===
|
|
618
|
+
return node.kind === 269 /* SyntaxKind.ModuleDeclaration */ && (node.flags & 8 /* NodeFlags.Reparsed */) !== 0;
|
|
619
619
|
}
|
|
620
620
|
// Declarations
|
|
621
621
|
/** The name of a declaration, not counting names it gets from an enclosing assignment. */
|
|
622
622
|
export function getNonAssignedNameOfDeclaration(declaration) {
|
|
623
623
|
switch (declaration.kind) {
|
|
624
|
-
case
|
|
625
|
-
case
|
|
624
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
625
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
626
626
|
switch (getAssignmentDeclarationKind(declaration)) {
|
|
627
627
|
case 4 /* JSDeclarationKind.Property */:
|
|
628
628
|
case 3 /* JSDeclarationKind.ThisProperty */:
|
|
@@ -636,7 +636,7 @@ export function getNonAssignedNameOfDeclaration(declaration) {
|
|
|
636
636
|
return getArguments(declaration).nodes[1];
|
|
637
637
|
}
|
|
638
638
|
return undefined;
|
|
639
|
-
case
|
|
639
|
+
case 279 /* SyntaxKind.ExportAssignment */: {
|
|
640
640
|
const expression = getExpression(declaration);
|
|
641
641
|
return expression.kind === 79 /* SyntaxKind.Identifier */ ? expression : undefined;
|
|
642
642
|
}
|
|
@@ -649,11 +649,11 @@ export function getAssignedName(node) {
|
|
|
649
649
|
if (parent === undefined)
|
|
650
650
|
return undefined;
|
|
651
651
|
switch (parent.kind) {
|
|
652
|
-
case
|
|
652
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
653
653
|
return getName(parent);
|
|
654
|
-
case
|
|
654
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
655
655
|
return parent.name;
|
|
656
|
-
case
|
|
656
|
+
case 228 /* SyntaxKind.BinaryExpression */: {
|
|
657
657
|
const binary = parent;
|
|
658
658
|
if (node !== binary.right)
|
|
659
659
|
return undefined;
|
|
@@ -669,7 +669,7 @@ export function getAssignedName(node) {
|
|
|
669
669
|
}
|
|
670
670
|
return undefined;
|
|
671
671
|
}
|
|
672
|
-
case
|
|
672
|
+
case 262 /* SyntaxKind.VariableDeclaration */: {
|
|
673
673
|
const name = parent.name;
|
|
674
674
|
return name.kind === 79 /* SyntaxKind.Identifier */ ? name : undefined;
|
|
675
675
|
}
|
|
@@ -682,14 +682,14 @@ export function getNameOfDeclaration(declaration) {
|
|
|
682
682
|
const name = getNonAssignedNameOfDeclaration(declaration);
|
|
683
683
|
if (name !== undefined)
|
|
684
684
|
return name;
|
|
685
|
-
if (isFunctionExpressionOrArrowFunction(declaration) || declaration.kind ===
|
|
685
|
+
if (isFunctionExpressionOrArrowFunction(declaration) || declaration.kind === 233 /* SyntaxKind.ClassExpression */)
|
|
686
686
|
return getAssignedName(declaration);
|
|
687
687
|
return undefined;
|
|
688
688
|
}
|
|
689
689
|
/** A computed name or element access whose name isn't a literal. */
|
|
690
690
|
export function isDynamicName(name) {
|
|
691
691
|
let expression;
|
|
692
|
-
if (name.kind ===
|
|
692
|
+
if (name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
693
693
|
expression = getExpression(name);
|
|
694
694
|
else if (name instanceof ElementAccessExpression)
|
|
695
695
|
expression = skipParentheses(name.argumentExpression);
|
|
@@ -702,11 +702,11 @@ export function hasDynamicName(declaration) {
|
|
|
702
702
|
return name !== undefined && isDynamicName(name);
|
|
703
703
|
}
|
|
704
704
|
export function isPartOfParameterDeclaration(node) {
|
|
705
|
-
return getRootDeclaration(node).kind ===
|
|
705
|
+
return getRootDeclaration(node).kind === 171 /* SyntaxKind.Parameter */;
|
|
706
706
|
}
|
|
707
707
|
export function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
|
|
708
708
|
const node = getRootDeclaration(declaration);
|
|
709
|
-
return node.kind ===
|
|
709
|
+
return node.kind === 262 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 301 /* SyntaxKind.CatchClause */;
|
|
710
710
|
}
|
|
711
711
|
/** A `let`, `const`, `using` or catch variable. */
|
|
712
712
|
export function isBlockOrCatchScoped(declaration) {
|
|
@@ -725,7 +725,7 @@ export function findConstructorDeclaration(node) {
|
|
|
725
725
|
if (members === undefined)
|
|
726
726
|
return undefined;
|
|
727
727
|
for (const member of members.nodes)
|
|
728
|
-
if (member.kind ===
|
|
728
|
+
if (member.kind === 178 /* SyntaxKind.Constructor */ && !nodeIsMissing(getBody(member)))
|
|
729
729
|
return member;
|
|
730
730
|
return undefined;
|
|
731
731
|
}
|
|
@@ -741,37 +741,37 @@ export function getThisContainer(node, includeArrowFunctions, includeClassComput
|
|
|
741
741
|
throw new Error('nil parent in getThisContainer');
|
|
742
742
|
current = parent;
|
|
743
743
|
switch (current.kind) {
|
|
744
|
-
case
|
|
744
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
745
745
|
if (includeClassComputedPropertyName && isClassLike(current.parent.parent))
|
|
746
746
|
return current;
|
|
747
747
|
current = current.parent.parent;
|
|
748
748
|
break;
|
|
749
|
-
case
|
|
750
|
-
if (current.parent.kind ===
|
|
749
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
750
|
+
if (current.parent.kind === 171 /* SyntaxKind.Parameter */ && isClassElement(current.parent.parent))
|
|
751
751
|
current = current.parent.parent;
|
|
752
752
|
else if (isClassElement(current.parent))
|
|
753
753
|
current = current.parent;
|
|
754
754
|
break;
|
|
755
|
-
case
|
|
755
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
756
756
|
if (includeArrowFunctions)
|
|
757
757
|
return current;
|
|
758
758
|
break;
|
|
759
|
-
case
|
|
760
|
-
case
|
|
761
|
-
case
|
|
762
|
-
case
|
|
763
|
-
case
|
|
764
|
-
case
|
|
765
|
-
case
|
|
766
|
-
case
|
|
767
|
-
case
|
|
768
|
-
case
|
|
769
|
-
case
|
|
770
|
-
case
|
|
771
|
-
case
|
|
772
|
-
case
|
|
773
|
-
case
|
|
774
|
-
case
|
|
759
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
760
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
761
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
762
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
763
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
764
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
765
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
766
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
767
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
768
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
769
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
770
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
771
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
772
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
773
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
774
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
775
775
|
return current;
|
|
776
776
|
}
|
|
777
777
|
}
|
|
@@ -781,49 +781,49 @@ export function isInTopLevelContext(node) {
|
|
|
781
781
|
let current = node;
|
|
782
782
|
if (current.kind === 79 /* SyntaxKind.Identifier */) {
|
|
783
783
|
const parent = current.parent;
|
|
784
|
-
if ((parent.kind ===
|
|
784
|
+
if ((parent.kind === 265 /* SyntaxKind.ClassDeclaration */ || parent.kind === 264 /* SyntaxKind.FunctionDeclaration */) &&
|
|
785
785
|
getName(parent) === current)
|
|
786
786
|
current = parent;
|
|
787
787
|
}
|
|
788
|
-
return getThisContainer(current, true, false).kind ===
|
|
788
|
+
return getThisContainer(current, true, false).kind === 308 /* SyntaxKind.SourceFile */;
|
|
789
789
|
}
|
|
790
790
|
/** An identifier in a property name position, which never resolves to a symbol. */
|
|
791
791
|
export function isIdentifierName(node) {
|
|
792
792
|
const parent = node.parent;
|
|
793
793
|
switch (parent.kind) {
|
|
794
|
-
case
|
|
795
|
-
case
|
|
796
|
-
case
|
|
797
|
-
case
|
|
798
|
-
case
|
|
799
|
-
case
|
|
800
|
-
case
|
|
801
|
-
case
|
|
802
|
-
case
|
|
794
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
795
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
796
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
797
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
798
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
799
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
800
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
801
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
802
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
803
803
|
return getName(parent) === node;
|
|
804
|
-
case
|
|
804
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
805
805
|
return parent.right === node;
|
|
806
|
-
case
|
|
807
|
-
case
|
|
806
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
807
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
808
808
|
return getPropertyName(parent) === node;
|
|
809
|
-
case
|
|
810
|
-
case
|
|
811
|
-
case
|
|
812
|
-
case
|
|
813
|
-
case
|
|
809
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
810
|
+
case 293 /* SyntaxKind.JsxAttribute */:
|
|
811
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
812
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
813
|
+
case 289 /* SyntaxKind.JsxClosingElement */:
|
|
814
814
|
return true;
|
|
815
815
|
}
|
|
816
816
|
return false;
|
|
817
817
|
}
|
|
818
818
|
export function isPartOfTypeQuery(node) {
|
|
819
819
|
let current = node;
|
|
820
|
-
while (current.kind ===
|
|
820
|
+
while (current.kind === 168 /* SyntaxKind.QualifiedName */ || current.kind === 79 /* SyntaxKind.Identifier */)
|
|
821
821
|
current = current.parent;
|
|
822
|
-
return current.kind ===
|
|
822
|
+
return current.kind === 188 /* SyntaxKind.TypeQuery */;
|
|
823
823
|
}
|
|
824
824
|
/** A statement that runs code, or a declaration that does (classes, enums, namespaces). */
|
|
825
825
|
export function isPotentiallyExecutableNode(node) {
|
|
826
|
-
if (node.kind >=
|
|
826
|
+
if (node.kind >= 245 /* SyntaxKind.FirstStatement */ && node.kind <= 261 /* SyntaxKind.LastStatement */) {
|
|
827
827
|
if (node instanceof VariableStatement) {
|
|
828
828
|
const list = node.declarationList;
|
|
829
829
|
if ((getCombinedNodeFlags(list) & 7 /* NodeFlags.BlockScoped */) !== 0)
|
|
@@ -835,21 +835,21 @@ export function isPotentiallyExecutableNode(node) {
|
|
|
835
835
|
}
|
|
836
836
|
return true;
|
|
837
837
|
}
|
|
838
|
-
return (node.kind ===
|
|
839
|
-
node.kind ===
|
|
840
|
-
node.kind ===
|
|
838
|
+
return (node.kind === 265 /* SyntaxKind.ClassDeclaration */ ||
|
|
839
|
+
node.kind === 268 /* SyntaxKind.EnumDeclaration */ ||
|
|
840
|
+
node.kind === 269 /* SyntaxKind.ModuleDeclaration */);
|
|
841
841
|
}
|
|
842
842
|
/** A `declare module "m"` that augments an external module rather than declaring one. */
|
|
843
843
|
export function isModuleAugmentationExternal(node) {
|
|
844
844
|
const parent = node.parent;
|
|
845
845
|
switch (parent.kind) {
|
|
846
|
-
case
|
|
846
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
847
847
|
return isExternalModule(parent);
|
|
848
|
-
case
|
|
848
|
+
case 270 /* SyntaxKind.ModuleBlock */: {
|
|
849
849
|
const grandParent = parent.parent;
|
|
850
850
|
return (grandParent instanceof ModuleDeclaration &&
|
|
851
851
|
isAmbientModuleDeclaration(grandParent) &&
|
|
852
|
-
grandParent.parent.kind ===
|
|
852
|
+
grandParent.parent.kind === 308 /* SyntaxKind.SourceFile */ &&
|
|
853
853
|
!isExternalModule(grandParent.parent));
|
|
854
854
|
}
|
|
855
855
|
}
|
|
@@ -952,25 +952,25 @@ class ModuleInstanceStateComputer extends NodeVisitor {
|
|
|
952
952
|
}
|
|
953
953
|
worker(node, ancestors) {
|
|
954
954
|
switch (node.kind) {
|
|
955
|
-
case
|
|
956
|
-
case
|
|
957
|
-
case
|
|
955
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
956
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
957
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
958
958
|
return 1 /* ModuleInstanceState.NonInstantiated */;
|
|
959
|
-
case
|
|
959
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
960
960
|
if (isEnumConst(node))
|
|
961
961
|
return 3 /* ModuleInstanceState.ConstEnumOnly */;
|
|
962
962
|
break;
|
|
963
|
-
case
|
|
964
|
-
case
|
|
965
|
-
case
|
|
963
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
964
|
+
case 347 /* SyntaxKind.JSImportDeclaration */:
|
|
965
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
966
966
|
if (!hasSyntacticModifier(node, 32 /* ModifierFlags.Export */))
|
|
967
967
|
return 1 /* ModuleInstanceState.NonInstantiated */;
|
|
968
968
|
break;
|
|
969
|
-
case
|
|
969
|
+
case 280 /* SyntaxKind.ExportDeclaration */: {
|
|
970
970
|
const exportClause = node.exportClause;
|
|
971
971
|
if (node.moduleSpecifier === undefined &&
|
|
972
972
|
exportClause !== undefined &&
|
|
973
|
-
exportClause.kind ===
|
|
973
|
+
exportClause.kind === 281 /* SyntaxKind.NamedExports */) {
|
|
974
974
|
let state = 1 /* ModuleInstanceState.NonInstantiated */;
|
|
975
975
|
const specifierAncestors = withAncestor(withAncestor(ancestors, node), exportClause);
|
|
976
976
|
for (const specifier of getElements(exportClause).nodes) {
|
|
@@ -984,7 +984,7 @@ class ModuleInstanceStateComputer extends NodeVisitor {
|
|
|
984
984
|
}
|
|
985
985
|
break;
|
|
986
986
|
}
|
|
987
|
-
case
|
|
987
|
+
case 270 /* SyntaxKind.ModuleBlock */: {
|
|
988
988
|
const saveAncestors = this.blockAncestors;
|
|
989
989
|
const saveState = this.blockState;
|
|
990
990
|
this.blockAncestors = withAncestor(ancestors, node);
|
|
@@ -995,7 +995,7 @@ class ModuleInstanceStateComputer extends NodeVisitor {
|
|
|
995
995
|
this.blockState = saveState;
|
|
996
996
|
return state;
|
|
997
997
|
}
|
|
998
|
-
case
|
|
998
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
999
999
|
return this.ofModule(node, ancestors);
|
|
1000
1000
|
}
|
|
1001
1001
|
return 2 /* ModuleInstanceState.Instantiated */;
|
|
@@ -1030,7 +1030,7 @@ class ModuleInstanceStateComputer extends NodeVisitor {
|
|
|
1030
1030
|
p = ancestors[--remaining];
|
|
1031
1031
|
if (p === undefined)
|
|
1032
1032
|
break;
|
|
1033
|
-
if (p.kind !==
|
|
1033
|
+
if (p.kind !== 243 /* SyntaxKind.Block */ && p.kind !== 270 /* SyntaxKind.ModuleBlock */ && p.kind !== 308 /* SyntaxKind.SourceFile */)
|
|
1034
1034
|
continue;
|
|
1035
1035
|
let found = 0 /* ModuleInstanceState.Unknown */;
|
|
1036
1036
|
const statementsAncestors = ancestors.slice(0, remaining);
|
|
@@ -1042,7 +1042,7 @@ class ModuleInstanceStateComputer extends NodeVisitor {
|
|
|
1042
1042
|
if (found === 2 /* ModuleInstanceState.Instantiated */)
|
|
1043
1043
|
return found;
|
|
1044
1044
|
// A re-exported import alias is ambiguous, like `export import x = mod.x`.
|
|
1045
|
-
if (statement.kind ===
|
|
1045
|
+
if (statement.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */)
|
|
1046
1046
|
found = 2 /* ModuleInstanceState.Instantiated */;
|
|
1047
1047
|
}
|
|
1048
1048
|
if (found !== 0 /* ModuleInstanceState.Unknown */)
|
|
@@ -1119,7 +1119,7 @@ function getErrorRangeForArrowFunction(file, node) {
|
|
|
1119
1119
|
const text = file.text;
|
|
1120
1120
|
const pos = skipTrivia(text, node.pos);
|
|
1121
1121
|
const body = getBody(node);
|
|
1122
|
-
if (body !== undefined && body.kind ===
|
|
1122
|
+
if (body !== undefined && body.kind === 243 /* SyntaxKind.Block */) {
|
|
1123
1123
|
const lineStarts = file.lineStarts();
|
|
1124
1124
|
const startLine = computeLineOfPosition(lineStarts, body.pos);
|
|
1125
1125
|
const endLine = computeLineOfPosition(lineStarts, body.end);
|
|
@@ -1169,53 +1169,53 @@ export function getErrorRangeForNode(file, node) {
|
|
|
1169
1169
|
const text = file.text;
|
|
1170
1170
|
let errorNode = node;
|
|
1171
1171
|
switch (node.kind) {
|
|
1172
|
-
case
|
|
1172
|
+
case 308 /* SyntaxKind.SourceFile */: {
|
|
1173
1173
|
const pos = skipTrivia(text, 0);
|
|
1174
1174
|
return pos === text.length ? new TextRange(0, 0) : getRangeOfTokenAtPosition(file, pos);
|
|
1175
1175
|
}
|
|
1176
|
-
case
|
|
1177
|
-
case
|
|
1176
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
1177
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
1178
1178
|
if ((node.flags & 8 /* NodeFlags.Reparsed */) === 0)
|
|
1179
1179
|
errorNode = getNameOfDeclaration(node);
|
|
1180
1180
|
break;
|
|
1181
|
-
case
|
|
1182
|
-
case
|
|
1183
|
-
case
|
|
1184
|
-
case
|
|
1185
|
-
case
|
|
1186
|
-
case
|
|
1187
|
-
case
|
|
1188
|
-
case
|
|
1189
|
-
case
|
|
1190
|
-
case
|
|
1191
|
-
case
|
|
1192
|
-
case
|
|
1193
|
-
case
|
|
1194
|
-
case
|
|
1195
|
-
case
|
|
1181
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
1182
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
1183
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
1184
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
1185
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
1186
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
1187
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
1188
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
1189
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
1190
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
1191
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
1192
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
1193
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
1194
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
1195
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
1196
1196
|
errorNode = getNameOfDeclaration(node);
|
|
1197
1197
|
break;
|
|
1198
|
-
case
|
|
1198
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
1199
1199
|
errorNode = getName(node);
|
|
1200
1200
|
break;
|
|
1201
|
-
case
|
|
1201
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
1202
1202
|
return getErrorRangeForArrowFunction(file, node);
|
|
1203
|
-
case
|
|
1204
|
-
case
|
|
1203
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
1204
|
+
case 299 /* SyntaxKind.DefaultClause */: {
|
|
1205
1205
|
const start = skipTrivia(text, node.pos);
|
|
1206
1206
|
const statements = getStatements(node).nodes;
|
|
1207
1207
|
return new TextRange(start, statements.length !== 0 ? statements[0].pos : node.end);
|
|
1208
1208
|
}
|
|
1209
|
-
case
|
|
1210
|
-
case
|
|
1209
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
1210
|
+
case 231 /* SyntaxKind.YieldExpression */:
|
|
1211
1211
|
return getRangeOfTokenAtPosition(file, skipTrivia(text, node.pos));
|
|
1212
|
-
case
|
|
1212
|
+
case 240 /* SyntaxKind.SatisfiesExpression */: {
|
|
1213
1213
|
const tag = findOriginatingJSDocSatisfiesTag(file, node);
|
|
1214
1214
|
if (tag !== undefined)
|
|
1215
1215
|
return getRangeOfTokenAtPosition(file, skipTrivia(text, getTagName(tag).pos));
|
|
1216
1216
|
return getRangeOfTokenAtPosition(file, skipTrivia(text, getExpression(node).end));
|
|
1217
1217
|
}
|
|
1218
|
-
case
|
|
1218
|
+
case 178 /* SyntaxKind.Constructor */: {
|
|
1219
1219
|
if ((node.flags & 8 /* NodeFlags.Reparsed */) !== 0)
|
|
1220
1220
|
break;
|
|
1221
1221
|
const scanner = scannerAt(file, node.pos);
|