tsc-ts 0.0.10 → 0.1.1
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 +29 -18
- package/dist/api/compiler/ast.js +1040 -1007
- 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 +136 -91
- package/dist/api/compiler/checker-contextual.d.ts +20 -0
- package/dist/api/compiler/checker-contextual.js +175 -62
- 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 +258 -212
- 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 +107 -89
- 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 +190 -46
- 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 +97 -31
- package/dist/api/compiler/checker.js +149 -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 +24 -4
- package/dist/api/compiler/compile-program.js +53 -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/expr-record.d.ts +11 -0
- package/dist/api/compiler/expr-record.js +53 -0
- 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/identifier-name.d.ts +9 -0
- package/dist/api/compiler/identifier-name.js +10 -0
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +27 -25
- 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 +42 -20
- package/dist/api/compiler/parser.js +318 -224
- 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 +6 -3
- 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 +306 -283
- 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 +64 -59
- package/dist/api/compiler/scanner.d.ts +27 -2
- package/dist/api/compiler/scanner.js +181 -150
- package/dist/api/compiler/shared-results.d.ts +696 -0
- package/dist/api/compiler/shared-results.js +2905 -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 +307 -239
- 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 +74 -38
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/cgroup.ts +157 -0
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +80 -25
- package/src/compiler/checker-contextual.ts +110 -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 +95 -47
- 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 +28 -5
- 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 +173 -35
- 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 +175 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +59 -25
- package/src/compiler/decoder.ts +15 -5
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/doctor-report.ts +133 -0
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/expr-record.ts +59 -0
- 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/identifier-name.ts +13 -0
- 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 +7 -3
- 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 +543 -147
- package/src/compiler/parallel-emit.ts +4 -4
- package/src/compiler/parser.ts +166 -47
- 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 +7 -3
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +39 -16
- 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 +14 -5
- package/src/compiler/run-config.ts +1383 -0
- package/src/compiler/run-record-read.ts +87 -0
- package/src/compiler/run-records.ts +575 -0
- package/src/compiler/scanner.ts +166 -120
- package/src/compiler/shared-results.ts +3144 -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 +22 -3
- 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 +136 -49
- 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 +67 -6
- package/src/compiler/tsc-cli.ts +35 -4
- package/src/compiler/tsc-compile.ts +220 -10
- package/src/compiler/tsc-watch.ts +97 -47
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// values, alias targets and module exports, like tsgo's checker services. These answer *some*
|
|
3
3
|
// symbol or type for any node; the checker itself uses the precise functions they call.
|
|
4
4
|
import { getArguments, getExpression, getInitializer, getName, getParameters, getPropertyName, getSymbol, getTagName, getText, getType, getTypeArguments, isDeclarationNode, NodeVisitor, } from './ast.js';
|
|
5
|
-
import { compareNodePositions, getExternalModuleName, isAssignmentOperator, isFunctionLike, isImportCall, isLiteralImportTypeNode, isStringLiteralLike, isTypeDeclaration, nodeIsMissing, } from './ast-utilities.js';
|
|
5
|
+
import { compareNodePositions, getExternalModuleName, isAssignmentOperator, isFunctionLike, isImportCall, isLiteralImportTypeNode, isNameOfHeritageClauseTypeReference, isStringLiteralLike, isTypeDeclaration, nodeIsMissing, isImportPhaseMetaProperty, } from './ast-utilities.js';
|
|
6
6
|
import { getNameOfDeclaration, getSourceFileOfNode, getThisContainer, isAssignmentTarget, isBindableObjectDefinePropertyCall, isClassLike, isEnumConst, isExternalOrCommonJSModule, isVariableDeclarationInitializedToRequire, } from './binder-utilities.js';
|
|
7
7
|
import { getResolvedSignature, tryGetRestTypeOfSignature } from './checker-calls.js';
|
|
8
8
|
import { getContextualType } from './checker-contextual.js';
|
|
@@ -10,7 +10,7 @@ import { computeEnumMemberValues, getBaseTypes, getDeclaredTypeOfClassOrInterfac
|
|
|
10
10
|
import { checkExpression, checkExpressionCached, checkPropertyAccessExpression, checkQualifiedName, isThisInTypeQuery, } from './checker-expressions.js';
|
|
11
11
|
import { getIntrinsicTagSymbol, isJsxIntrinsicTagName } from './checker-jsx.js';
|
|
12
12
|
import { getApplicableIndexInfo, getIndexInfosOfType, getPropertyOfType, getTypeWithThisArgument, isApplicableIndexType, } from './checker-members.js';
|
|
13
|
-
import { checkNewTargetMetaProperty, getExternalModuleMember, getHostSignatureFromJSDoc, getSymbolOfPartOfRightHandSideOfImportEquals, getTargetOfAliasDeclaration, resolveExternalModuleName, resolveJSDocMemberName, } from './checker-modules.js';
|
|
13
|
+
import { checkNewTargetMetaProperty, getExternalModuleMember, getHostSignatureFromJSDoc, getSymbolOfPartOfRightHandSideOfImportEquals, getTargetOfAliasDeclaration, resolveExternalModuleName, resolveJSDocMemberName, checkImportAttributesExpression, getImportAttributesTypeForModuleSpecifier, } from './checker-modules.js';
|
|
14
14
|
import { getSymbolHasInstanceMethodOfObjectType } from './checker-operators.js';
|
|
15
15
|
import { getSymbolForPrivateIdentifierExpression } from './checker-property-access.js';
|
|
16
16
|
import { getSignatureFromDeclaration } from './checker-signatures.js';
|
|
@@ -29,7 +29,7 @@ export function getSymbolAtLocation(c, node) {
|
|
|
29
29
|
}
|
|
30
30
|
/** The symbol a node refers to, reporting resolution errors unless `ignoreErrors`. */
|
|
31
31
|
export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
32
|
-
if (node.kind ===
|
|
32
|
+
if (node.kind === 308 /* SyntaxKind.SourceFile */)
|
|
33
33
|
return isExternalOrCommonJSModule(node) ? getSymbolOfDeclaration(c, node) : undefined;
|
|
34
34
|
const parent = node.parent;
|
|
35
35
|
const grandParent = parent.parent;
|
|
@@ -47,14 +47,14 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
47
47
|
if (node.kind === 79 /* SyntaxKind.Identifier */) {
|
|
48
48
|
if (isInRightSideOfImportOrExportAssignment(node))
|
|
49
49
|
return getSymbolOfNameOrPropertyAccessExpression(c, node);
|
|
50
|
-
if (parent.kind ===
|
|
51
|
-
grandParent.kind ===
|
|
50
|
+
if (parent.kind === 210 /* SyntaxKind.BindingElement */ &&
|
|
51
|
+
grandParent.kind === 208 /* SyntaxKind.ObjectBindingPattern */ &&
|
|
52
52
|
node === getPropertyName(parent)) {
|
|
53
53
|
const property = getPropertyOfType(c, getTypeOfNode(c, grandParent), getText(node));
|
|
54
54
|
if (property !== undefined)
|
|
55
55
|
return property;
|
|
56
56
|
}
|
|
57
|
-
else if (parent.kind ===
|
|
57
|
+
else if (parent.kind === 238 /* SyntaxKind.MetaProperty */ && parent.name === node) {
|
|
58
58
|
const meta = parent;
|
|
59
59
|
// `target` in `new.target`.
|
|
60
60
|
if (meta.keywordToken === 104 /* SyntaxKind.NewKeyword */ && getText(node) === 'target')
|
|
@@ -65,7 +65,7 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
65
65
|
// Other meta properties are invalid syntax.
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
68
|
-
else if (parent.kind ===
|
|
68
|
+
else if (parent.kind === 334 /* SyntaxKind.JSDocParameterTag */ && getName(parent) === node) {
|
|
69
69
|
const fn = getNodeAtPosition(getSourceFileOfNode(node), node.pos, false);
|
|
70
70
|
if (isFunctionLike(fn)) {
|
|
71
71
|
for (const param of getParameters(fn).nodes) {
|
|
@@ -79,20 +79,20 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
79
79
|
switch (node.kind) {
|
|
80
80
|
case 79 /* SyntaxKind.Identifier */:
|
|
81
81
|
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
82
|
-
case
|
|
83
|
-
case
|
|
82
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
83
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
84
84
|
if (!isThisInTypeQuery(node))
|
|
85
85
|
return getSymbolOfNameOrPropertyAccessExpression(c, node);
|
|
86
86
|
return getSymbolOfThis(c, node);
|
|
87
87
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
88
88
|
return getSymbolOfThis(c, node);
|
|
89
|
-
case
|
|
89
|
+
case 199 /* SyntaxKind.ThisType */:
|
|
90
90
|
return getTypeFromThisTypeNode(c, node).symbol;
|
|
91
91
|
case 107 /* SyntaxKind.SuperKeyword */:
|
|
92
92
|
return checkExpression(c, node).symbol;
|
|
93
93
|
case 136 /* SyntaxKind.ConstructorKeyword */:
|
|
94
94
|
// The keyword of a constructor overload.
|
|
95
|
-
return parent.kind ===
|
|
95
|
+
return parent.kind === 178 /* SyntaxKind.Constructor */ ? getSymbol(parent.parent) : undefined;
|
|
96
96
|
case 10 /* SyntaxKind.StringLiteral */:
|
|
97
97
|
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
|
|
98
98
|
// Module names: `import x = require("m")`, import and export declarations, `require("m")`,
|
|
@@ -100,18 +100,18 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
100
100
|
if ((grandParent !== undefined &&
|
|
101
101
|
isExternalModuleImportEqualsDeclaration(grandParent) &&
|
|
102
102
|
grandParent.moduleReference.expression === node) ||
|
|
103
|
-
((parent.kind ===
|
|
104
|
-
parent.kind ===
|
|
105
|
-
parent.kind ===
|
|
103
|
+
((parent.kind === 274 /* SyntaxKind.ImportDeclaration */ ||
|
|
104
|
+
parent.kind === 347 /* SyntaxKind.JSImportDeclaration */ ||
|
|
105
|
+
parent.kind === 280 /* SyntaxKind.ExportDeclaration */) &&
|
|
106
106
|
getExternalModuleName(parent) === node) ||
|
|
107
107
|
(grandParent !== undefined && isVariableDeclarationInitializedToRequire(grandParent)) ||
|
|
108
108
|
isImportCall(parent) ||
|
|
109
|
-
(parent.kind ===
|
|
109
|
+
(parent.kind === 203 /* SyntaxKind.LiteralType */ &&
|
|
110
110
|
grandParent !== undefined &&
|
|
111
111
|
isLiteralImportTypeNode(grandParent) &&
|
|
112
112
|
grandParent.argument === parent))
|
|
113
|
-
return resolveExternalModuleName(c, node, node, ignoreErrors);
|
|
114
|
-
if (parent.kind ===
|
|
113
|
+
return resolveExternalModuleName(c, node, node, ignoreErrors, getImportAttributesTypeForModuleSpecifier(c, node));
|
|
114
|
+
if (parent.kind === 215 /* SyntaxKind.CallExpression */ &&
|
|
115
115
|
isBindableObjectDefinePropertyCall(parent) &&
|
|
116
116
|
getArguments(parent).nodes[1] === node)
|
|
117
117
|
return getSymbolOfDeclaration(c, parent);
|
|
@@ -123,20 +123,20 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
123
123
|
case 38 /* SyntaxKind.EqualsGreaterThanToken */:
|
|
124
124
|
case 85 /* SyntaxKind.ClassKeyword */:
|
|
125
125
|
return getSymbolOfDeclaration(c, parent);
|
|
126
|
-
case
|
|
126
|
+
case 207 /* SyntaxKind.ImportType */:
|
|
127
127
|
if (isLiteralImportTypeNode(node))
|
|
128
128
|
return getSymbolAtLocationWorker(c, node.argument.literal, ignoreErrors);
|
|
129
129
|
return undefined;
|
|
130
130
|
case 94 /* SyntaxKind.ExportKeyword */:
|
|
131
|
-
return parent.kind ===
|
|
131
|
+
return parent.kind === 279 /* SyntaxKind.ExportAssignment */ ? getSymbol(parent) : undefined;
|
|
132
132
|
case 101 /* SyntaxKind.ImportKeyword */:
|
|
133
|
-
if (parent
|
|
133
|
+
if (isImportPhaseMetaProperty(parent))
|
|
134
134
|
return undefined;
|
|
135
|
-
return parent.kind ===
|
|
135
|
+
return parent.kind === 238 /* SyntaxKind.MetaProperty */ ? checkMetaPropertyKeyword(c).symbol : undefined;
|
|
136
136
|
case 104 /* SyntaxKind.NewKeyword */:
|
|
137
|
-
return parent.kind ===
|
|
137
|
+
return parent.kind === 238 /* SyntaxKind.MetaProperty */ ? checkMetaPropertyKeyword(c).symbol : undefined;
|
|
138
138
|
case 103 /* SyntaxKind.InstanceOfKeyword */:
|
|
139
|
-
if (parent.kind ===
|
|
139
|
+
if (parent.kind === 228 /* SyntaxKind.BinaryExpression */) {
|
|
140
140
|
const t = checkExpressionCached(c, parent.right);
|
|
141
141
|
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(c, t);
|
|
142
142
|
if (hasInstanceMethodType !== undefined && hasInstanceMethodType.symbol !== undefined)
|
|
@@ -144,9 +144,9 @@ export function getSymbolAtLocationWorker(c, node, ignoreErrors) {
|
|
|
144
144
|
return t.symbol;
|
|
145
145
|
}
|
|
146
146
|
return undefined;
|
|
147
|
-
case
|
|
147
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
148
148
|
return checkExpression(c, node).symbol;
|
|
149
|
-
case
|
|
149
|
+
case 297 /* SyntaxKind.JsxNamespacedName */:
|
|
150
150
|
if (isJsxTagName(node) && isJsxIntrinsicTagName(node)) {
|
|
151
151
|
const symbol = getIntrinsicTagSymbol(c, parent);
|
|
152
152
|
return symbol === c.unknownSymbol ? undefined : symbol;
|
|
@@ -171,11 +171,11 @@ function getSymbolOfThis(c, node) {
|
|
|
171
171
|
function getSymbolOfLiteralIndex(c, node) {
|
|
172
172
|
const parent = node.parent;
|
|
173
173
|
let objectType;
|
|
174
|
-
if (parent.kind ===
|
|
174
|
+
if (parent.kind === 214 /* SyntaxKind.ElementAccessExpression */) {
|
|
175
175
|
if (parent.argumentExpression === node)
|
|
176
176
|
objectType = checkExpressionCached(c, parent.expression);
|
|
177
177
|
}
|
|
178
|
-
else if (parent.kind ===
|
|
178
|
+
else if (parent.kind === 203 /* SyntaxKind.LiteralType */ && parent.parent.kind === 201 /* SyntaxKind.IndexedAccessType */)
|
|
179
179
|
objectType = getTypeFromTypeNode(c, parent.parent.objectType);
|
|
180
180
|
return objectType !== undefined ? getPropertyOfType(c, objectType, getText(node)) : undefined;
|
|
181
181
|
}
|
|
@@ -183,7 +183,7 @@ function getSymbolOfNameOrPropertyAccessExpression(c, nameIn) {
|
|
|
183
183
|
let name = nameIn;
|
|
184
184
|
if (isDeclarationName(name))
|
|
185
185
|
return getSymbolOfDeclaration(c, name.parent);
|
|
186
|
-
if (name.parent.kind ===
|
|
186
|
+
if (name.parent.kind === 279 /* SyntaxKind.ExportAssignment */ && isEntityNameExpression(name)) {
|
|
187
187
|
// An entity name that doesn't resolve as one may still check as a property access.
|
|
188
188
|
const meaning = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */;
|
|
189
189
|
const success = resolveEntityName(c, name, meaning, true, false, undefined);
|
|
@@ -204,10 +204,11 @@ function getSymbolOfNameOrPropertyAccessExpression(c, nameIn) {
|
|
|
204
204
|
}
|
|
205
205
|
while (isRightSideOfQualifiedNameOrPropertyAccess(name))
|
|
206
206
|
name = name.parent;
|
|
207
|
-
if (
|
|
207
|
+
if (isInNameOfExpressionWithTypeArgumentsOrHeritageTypeReference(name)) {
|
|
208
208
|
let meaning;
|
|
209
|
-
if (name.parent.kind ===
|
|
210
|
-
|
|
209
|
+
if (name.parent.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */ ||
|
|
210
|
+
name.parent.kind === 185 /* SyntaxKind.TypeReference */) {
|
|
211
|
+
// A heritage element name is a type, `foo<T>` a value, and a class `extends` both.
|
|
211
212
|
meaning = isPartOfTypeNode(name) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */;
|
|
212
213
|
if (isExpressionWithTypeArgumentsInClassExtendsClause(name.parent))
|
|
213
214
|
meaning |= 111551 /* SymbolFlags.Value */;
|
|
@@ -252,11 +253,11 @@ function getSymbolOfNameOrPropertyAccessExpression(c, nameIn) {
|
|
|
252
253
|
}
|
|
253
254
|
if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */)
|
|
254
255
|
return getSymbolForPrivateIdentifierExpression(c, name);
|
|
255
|
-
if (name.kind ===
|
|
256
|
+
if (name.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
256
257
|
const cached = c.resolvedSymbols.get(name.id);
|
|
257
258
|
if (cached !== undefined)
|
|
258
259
|
return cached;
|
|
259
|
-
if (name.kind ===
|
|
260
|
+
if (name.kind === 213 /* SyntaxKind.PropertyAccessExpression */) {
|
|
260
261
|
const access = name;
|
|
261
262
|
checkPropertyAccessExpression(c, access, false);
|
|
262
263
|
if (c.resolvedSymbols.get(name.id) === undefined && access.name.kind !== 80 /* SyntaxKind.PrivateIdentifier */)
|
|
@@ -264,19 +265,21 @@ function getSymbolOfNameOrPropertyAccessExpression(c, nameIn) {
|
|
|
264
265
|
}
|
|
265
266
|
else
|
|
266
267
|
checkQualifiedName(c, name);
|
|
267
|
-
if (c.resolvedSymbols.get(name.id) === undefined && isJSDoc && name.kind ===
|
|
268
|
+
if (c.resolvedSymbols.get(name.id) === undefined && isJSDoc && name.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
268
269
|
return resolveJSDocMemberName(c, name);
|
|
269
270
|
return c.resolvedSymbols.get(name.id);
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
else if (isEntityName(name) && isTypeReferenceIdentifier(name)) {
|
|
273
|
-
const meaning = name.parent.kind ===
|
|
274
|
+
const meaning = name.parent.kind === 185 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */;
|
|
274
275
|
const symbol = resolveEntityName(c, name, meaning, true, true, undefined);
|
|
275
276
|
if (symbol !== undefined && symbol !== c.unknownSymbol)
|
|
276
277
|
return symbol;
|
|
278
|
+
if (isNameOfHeritageClauseTypeReference(name))
|
|
279
|
+
return undefined;
|
|
277
280
|
return getUnresolvedSymbolForEntityName(c, name);
|
|
278
281
|
}
|
|
279
|
-
if (name.parent.kind ===
|
|
282
|
+
if (name.parent.kind === 184 /* SyntaxKind.TypePredicate */)
|
|
280
283
|
return resolveEntityName(c, name, 1 /* SymbolFlags.FunctionScopedVariable */, true, false, undefined);
|
|
281
284
|
return undefined;
|
|
282
285
|
}
|
|
@@ -294,7 +297,7 @@ function getApplicableIndexSymbol(c, t, keyType) {
|
|
|
294
297
|
if (other.declaration !== undefined && isApplicableIndexType(c, keyType, other.keyType))
|
|
295
298
|
declarations.push(other.declaration);
|
|
296
299
|
if (declarations.length !== 0) {
|
|
297
|
-
const symbol = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */, "\uFFFEindex" /* InternalSymbolName.Index */,
|
|
300
|
+
const symbol = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */, "\uFFFEindex" /* InternalSymbolName.Index */, 67108864 /* CheckFlags.IndexSymbol */);
|
|
298
301
|
setDeclarations(symbol, declarations);
|
|
299
302
|
symbol.valueDeclaration = declarations[0];
|
|
300
303
|
symbol.parent = t.symbol;
|
|
@@ -329,13 +332,13 @@ function checkMetaPropertyKeyword(c) {
|
|
|
329
332
|
export function getTypeAtLocation(c, node) {
|
|
330
333
|
return getTypeOfNode(c, getReparsedNodeForNode(node));
|
|
331
334
|
}
|
|
332
|
-
function getTypeOfNode(c, node) {
|
|
333
|
-
if (node.kind ===
|
|
335
|
+
export function getTypeOfNode(c, node) {
|
|
336
|
+
if (node.kind === 308 /* SyntaxKind.SourceFile */ && !isExternalOrCommonJSModule(node))
|
|
334
337
|
return c.errorType;
|
|
335
338
|
// Semantic questions inside `with` blocks have no answer.
|
|
336
339
|
if ((node.flags & 16777216 /* NodeFlags.InWithStatement */) !== 0)
|
|
337
340
|
return c.errorType;
|
|
338
|
-
const heritage =
|
|
341
|
+
const heritage = getClassOfHeritageElement(node);
|
|
339
342
|
const classType = heritage !== undefined ? getDeclaredTypeOfClassOrInterface(c, getSymbolOfDeclaration(c, heritage)) : undefined;
|
|
340
343
|
if (isPartOfTypeNode(node)) {
|
|
341
344
|
const typeFromTypeNode = getTypeFromTypeNode(c, node);
|
|
@@ -356,7 +359,7 @@ function getTypeOfNode(c, node) {
|
|
|
356
359
|
const symbol = getSymbolAtLocationWorker(c, node, false);
|
|
357
360
|
return symbol !== undefined ? getDeclaredTypeOfSymbol(c, symbol) : c.errorType;
|
|
358
361
|
}
|
|
359
|
-
if (node.kind ===
|
|
362
|
+
if (node.kind === 210 /* SyntaxKind.BindingElement */)
|
|
360
363
|
return getTypeForVariableLikeDeclaration(c, node, true) ?? c.errorType;
|
|
361
364
|
if (isDeclaration(node)) {
|
|
362
365
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
@@ -377,11 +380,11 @@ function getTypeOfNode(c, node) {
|
|
|
377
380
|
}
|
|
378
381
|
const parent = node.parent;
|
|
379
382
|
if (parent !== undefined &&
|
|
380
|
-
parent.kind ===
|
|
383
|
+
parent.kind === 238 /* SyntaxKind.MetaProperty */ &&
|
|
381
384
|
parent.keywordToken === node.kind)
|
|
382
385
|
return checkMetaPropertyKeyword(c);
|
|
383
|
-
if (node.kind ===
|
|
384
|
-
return
|
|
386
|
+
if (node.kind === 302 /* SyntaxKind.ImportAttributes */)
|
|
387
|
+
return checkImportAttributesExpression(c, node);
|
|
385
388
|
return c.errorType;
|
|
386
389
|
}
|
|
387
390
|
function getRegularTypeOfExpression(c, node) {
|
|
@@ -396,8 +399,8 @@ export function getTypeOfSymbolAtLocation(c, symbolIn, locationIn) {
|
|
|
396
399
|
// A reference to the symbol that isn't only assigned to has a flow type.
|
|
397
400
|
if ((location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) &&
|
|
398
401
|
!(isJsxTagName(location) ||
|
|
399
|
-
location.parent.kind ===
|
|
400
|
-
location.parent.kind ===
|
|
402
|
+
location.parent.kind === 293 /* SyntaxKind.JsxAttribute */ ||
|
|
403
|
+
location.parent.kind === 297 /* SyntaxKind.JsxNamespacedName */)) {
|
|
401
404
|
if (isRightSideOfQualifiedNameOrPropertyAccess(location))
|
|
402
405
|
location = location.parent;
|
|
403
406
|
if (isExpressionNode(location) && (!isAssignmentTarget(location) || isWriteAccess(location))) {
|
|
@@ -408,7 +411,7 @@ export function getTypeOfSymbolAtLocation(c, symbolIn, locationIn) {
|
|
|
408
411
|
}
|
|
409
412
|
}
|
|
410
413
|
if (isDeclarationName(location) &&
|
|
411
|
-
location.parent.kind ===
|
|
414
|
+
location.parent.kind === 180 /* SyntaxKind.SetAccessor */ &&
|
|
412
415
|
getAnnotatedAccessorTypeNode(location.parent) !== undefined)
|
|
413
416
|
return getWriteTypeOfAccessors(c, getSymbol(location.parent));
|
|
414
417
|
// A hypothetical reference has no flow information, so it gets the declared type.
|
|
@@ -420,14 +423,14 @@ export function getTypeOfSymbolAtLocation(c, symbolIn, locationIn) {
|
|
|
420
423
|
// ---- Other queries
|
|
421
424
|
/** The value symbol of a shorthand property assignment's name. */
|
|
422
425
|
export function getShorthandAssignmentValueSymbol(c, node) {
|
|
423
|
-
if (node === undefined || node.kind !==
|
|
426
|
+
if (node === undefined || node.kind !== 305 /* SyntaxKind.ShorthandPropertyAssignment */)
|
|
424
427
|
return undefined;
|
|
425
428
|
return resolveEntityName(c, node.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */, true, false, undefined);
|
|
426
429
|
}
|
|
427
430
|
/** The local symbol an export specifier, or the identifier of one, refers to. Throws for other nodes. */
|
|
428
431
|
export function getExportSpecifierLocalTargetSymbol(c, node) {
|
|
429
432
|
const meaning = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */;
|
|
430
|
-
if (node.kind ===
|
|
433
|
+
if (node.kind === 283 /* SyntaxKind.ExportSpecifier */) {
|
|
431
434
|
const exportDeclaration = node.parent.parent;
|
|
432
435
|
if (getExternalModuleName(exportDeclaration) !== undefined)
|
|
433
436
|
return getExternalModuleMember(c, exportDeclaration, node, false);
|
|
@@ -444,7 +447,7 @@ export function getExportSpecifierLocalTargetSymbol(c, node) {
|
|
|
444
447
|
}
|
|
445
448
|
/** The value of an enum member, or of a reference to a const enum member. */
|
|
446
449
|
export function getConstantValue(c, node) {
|
|
447
|
-
if (node.kind ===
|
|
450
|
+
if (node.kind === 307 /* SyntaxKind.EnumMember */)
|
|
448
451
|
return getEnumMemberValue(c, node);
|
|
449
452
|
// Checking the expression records the symbol it resolves to.
|
|
450
453
|
if (c.resolvedSymbols.get(node.id) === undefined)
|
|
@@ -511,14 +514,14 @@ export function querySignatureFromDeclaration(c, node) {
|
|
|
511
514
|
/** The signature a call-like expression resolves to. Throws for other nodes. */
|
|
512
515
|
export function queryResolvedSignature(c, node) {
|
|
513
516
|
switch (node.kind) {
|
|
514
|
-
case
|
|
515
|
-
case
|
|
516
|
-
case
|
|
517
|
-
case
|
|
518
|
-
case
|
|
519
|
-
case
|
|
520
|
-
case
|
|
521
|
-
case
|
|
517
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
518
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
519
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
520
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
521
|
+
case 291 /* SyntaxKind.JsxOpeningFragment */:
|
|
522
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
523
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
524
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
522
525
|
return getResolvedSignature(c, node, 0 /* CheckMode.Normal */);
|
|
523
526
|
}
|
|
524
527
|
throw new Error('getResolvedSignature expects a call-like expression');
|
|
@@ -601,31 +604,31 @@ class ChildCollector extends NodeVisitor {
|
|
|
601
604
|
}
|
|
602
605
|
}
|
|
603
606
|
export function isEntityName(node) {
|
|
604
|
-
return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind ===
|
|
607
|
+
return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 168 /* SyntaxKind.QualifiedName */;
|
|
605
608
|
}
|
|
606
609
|
function isBindingPattern(node) {
|
|
607
|
-
return node.kind ===
|
|
610
|
+
return node.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 209 /* SyntaxKind.ArrayBindingPattern */;
|
|
608
611
|
}
|
|
609
612
|
function isImportOrExportSpecifier(node) {
|
|
610
|
-
return node.kind ===
|
|
613
|
+
return node.kind === 278 /* SyntaxKind.ImportSpecifier */ || node.kind === 283 /* SyntaxKind.ExportSpecifier */;
|
|
611
614
|
}
|
|
612
615
|
function isClassOrInterfaceLike(node) {
|
|
613
|
-
return (node.kind ===
|
|
614
|
-
node.kind ===
|
|
615
|
-
node.kind ===
|
|
616
|
+
return (node.kind === 265 /* SyntaxKind.ClassDeclaration */ ||
|
|
617
|
+
node.kind === 233 /* SyntaxKind.ClassExpression */ ||
|
|
618
|
+
node.kind === 266 /* SyntaxKind.InterfaceDeclaration */);
|
|
616
619
|
}
|
|
617
620
|
function isJSDocLinkLike(node) {
|
|
618
|
-
return (node.kind ===
|
|
619
|
-
node.kind ===
|
|
620
|
-
node.kind ===
|
|
621
|
+
return (node.kind === 320 /* SyntaxKind.JSDocLink */ ||
|
|
622
|
+
node.kind === 321 /* SyntaxKind.JSDocLinkCode */ ||
|
|
623
|
+
node.kind === 322 /* SyntaxKind.JSDocLinkPlain */);
|
|
621
624
|
}
|
|
622
625
|
export function isDeclaration(node) {
|
|
623
|
-
if (node.kind ===
|
|
626
|
+
if (node.kind === 170 /* SyntaxKind.TypeParameter */)
|
|
624
627
|
return node.parent !== undefined;
|
|
625
628
|
return isDeclarationNode(node);
|
|
626
629
|
}
|
|
627
630
|
export function isDeclarationName(name) {
|
|
628
|
-
return (name.kind !==
|
|
631
|
+
return (name.kind !== 308 /* SyntaxKind.SourceFile */ &&
|
|
629
632
|
!isBindingPattern(name) &&
|
|
630
633
|
isDeclaration(name.parent) &&
|
|
631
634
|
getName(name.parent) === name);
|
|
@@ -638,48 +641,48 @@ function isDeclarationNameOrImportPropertyName(name) {
|
|
|
638
641
|
}
|
|
639
642
|
export function isLiteralComputedPropertyDeclarationName(node) {
|
|
640
643
|
return ((isStringLiteralLike(node) || node.kind === 8 /* SyntaxKind.NumericLiteral */) &&
|
|
641
|
-
node.parent.kind ===
|
|
644
|
+
node.parent.kind === 169 /* SyntaxKind.ComputedPropertyName */ &&
|
|
642
645
|
isDeclaration(node.parent.parent));
|
|
643
646
|
}
|
|
644
647
|
function isExternalModuleImportEqualsDeclaration(node) {
|
|
645
|
-
return (node.kind ===
|
|
646
|
-
node.moduleReference.kind ===
|
|
648
|
+
return (node.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */ &&
|
|
649
|
+
node.moduleReference.kind === 285 /* SyntaxKind.ExternalModuleReference */);
|
|
647
650
|
}
|
|
648
651
|
export function isInRightSideOfImportOrExportAssignment(nodeIn) {
|
|
649
652
|
let node = nodeIn;
|
|
650
|
-
while (node.parent.kind ===
|
|
653
|
+
while (node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
651
654
|
node = node.parent;
|
|
652
655
|
const parent = node.parent;
|
|
653
|
-
return ((parent.kind ===
|
|
656
|
+
return ((parent.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */ &&
|
|
654
657
|
parent.moduleReference === node) ||
|
|
655
|
-
(parent.kind ===
|
|
658
|
+
(parent.kind === 279 /* SyntaxKind.ExportAssignment */ && getExpression(parent) === node));
|
|
656
659
|
}
|
|
657
660
|
/** The `import()` type whose qualifier contains `node`. */
|
|
658
661
|
function isImportTypeQualifierPart(nodeIn) {
|
|
659
662
|
let node = nodeIn;
|
|
660
663
|
let parent = node.parent;
|
|
661
|
-
while (parent !== undefined && parent.kind ===
|
|
664
|
+
while (parent !== undefined && parent.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
662
665
|
node = parent;
|
|
663
666
|
parent = parent.parent;
|
|
664
667
|
}
|
|
665
|
-
if (parent !== undefined && parent.kind ===
|
|
668
|
+
if (parent !== undefined && parent.kind === 207 /* SyntaxKind.ImportType */ && parent.qualifier === node)
|
|
666
669
|
return parent;
|
|
667
670
|
return undefined;
|
|
668
671
|
}
|
|
669
|
-
function
|
|
672
|
+
function isInNameOfExpressionWithTypeArgumentsOrHeritageTypeReference(nodeIn) {
|
|
670
673
|
let node = nodeIn;
|
|
671
|
-
while (node.parent.kind ===
|
|
674
|
+
while (node.parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
672
675
|
node = node.parent;
|
|
673
|
-
return node.parent.kind ===
|
|
676
|
+
return node.parent.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */ || isNameOfHeritageClauseTypeReference(node);
|
|
674
677
|
}
|
|
675
678
|
export function isRightSideOfQualifiedNameOrPropertyAccess(node) {
|
|
676
679
|
const parent = node.parent;
|
|
677
680
|
switch (parent.kind) {
|
|
678
|
-
case
|
|
681
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
679
682
|
return parent.right === node;
|
|
680
|
-
case
|
|
683
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
681
684
|
return parent.name === node;
|
|
682
|
-
case
|
|
685
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
683
686
|
return parent.name === node;
|
|
684
687
|
}
|
|
685
688
|
return false;
|
|
@@ -688,18 +691,18 @@ function isRightSideOfAccessExpression(node) {
|
|
|
688
691
|
const parent = node.parent;
|
|
689
692
|
if (parent === undefined)
|
|
690
693
|
return false;
|
|
691
|
-
if (parent.kind ===
|
|
694
|
+
if (parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
692
695
|
return parent.name === node;
|
|
693
|
-
if (parent.kind ===
|
|
696
|
+
if (parent.kind === 214 /* SyntaxKind.ElementAccessExpression */)
|
|
694
697
|
return parent.argumentExpression === node;
|
|
695
698
|
return false;
|
|
696
699
|
}
|
|
697
700
|
function isJsxTagName(node) {
|
|
698
701
|
const parent = node.parent;
|
|
699
702
|
switch (parent.kind) {
|
|
700
|
-
case
|
|
701
|
-
case
|
|
702
|
-
case
|
|
703
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
704
|
+
case 289 /* SyntaxKind.JsxClosingElement */:
|
|
705
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
703
706
|
return getTagName(parent) === node;
|
|
704
707
|
}
|
|
705
708
|
return false;
|
|
@@ -708,16 +711,21 @@ export function isJSDocNameReferenceContext(node) {
|
|
|
708
711
|
if ((node.flags & 4194304 /* NodeFlags.JSDoc */) === 0)
|
|
709
712
|
return false;
|
|
710
713
|
for (let current = node; current !== undefined; current = current.parent)
|
|
711
|
-
if (current.kind ===
|
|
714
|
+
if (current.kind === 310 /* SyntaxKind.JSDocNameReference */ || isJSDocLinkLike(current))
|
|
712
715
|
return true;
|
|
713
716
|
return false;
|
|
714
717
|
}
|
|
715
718
|
/** The class of an expression with type arguments in its heritage clause. */
|
|
716
719
|
function getClassOfHeritageExpression(node) {
|
|
717
|
-
|
|
720
|
+
return node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */ ? getClassOfHeritageElement(node) : undefined;
|
|
721
|
+
}
|
|
722
|
+
/** The class of a heritage clause element: an expression with type arguments, or a type reference in
|
|
723
|
+
* `implements`. */
|
|
724
|
+
function getClassOfHeritageElement(node) {
|
|
725
|
+
if (node.kind !== 235 /* SyntaxKind.ExpressionWithTypeArguments */ && node.kind !== 185 /* SyntaxKind.TypeReference */)
|
|
718
726
|
return undefined;
|
|
719
727
|
const parent = node.parent;
|
|
720
|
-
return parent.kind ===
|
|
728
|
+
return parent.kind === 300 /* SyntaxKind.HeritageClause */ && isClassLike(parent.parent) ? parent.parent : undefined;
|
|
721
729
|
}
|
|
722
730
|
function isImplementsExpression(node) {
|
|
723
731
|
return node.parent.token === 118 /* SyntaxKind.ImplementsKeyword */;
|
|
@@ -731,13 +739,13 @@ function isTypeDeclarationName(name) {
|
|
|
731
739
|
/** Whether a type reference names `node`, as `T`, `N.T` or the namespace part of one. */
|
|
732
740
|
function isTypeReferenceIdentifier(nodeIn) {
|
|
733
741
|
let node = nodeIn;
|
|
734
|
-
while (node.parent.kind ===
|
|
742
|
+
while (node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
735
743
|
node = node.parent;
|
|
736
|
-
return node.parent.kind ===
|
|
744
|
+
return node.parent.kind === 185 /* SyntaxKind.TypeReference */;
|
|
737
745
|
}
|
|
738
746
|
export function isPartOfTypeNode(node) {
|
|
739
747
|
const kind = node.kind;
|
|
740
|
-
if (kind >=
|
|
748
|
+
if (kind >= 184 /* SyntaxKind.FirstTypeNode */ && kind <= 207 /* SyntaxKind.LastTypeNode */)
|
|
741
749
|
return true;
|
|
742
750
|
switch (kind) {
|
|
743
751
|
case 132 /* SyntaxKind.AnyKeyword */:
|
|
@@ -753,21 +761,21 @@ export function isPartOfTypeNode(node) {
|
|
|
753
761
|
case 146 /* SyntaxKind.NeverKeyword */:
|
|
754
762
|
return true;
|
|
755
763
|
case 115 /* SyntaxKind.VoidKeyword */:
|
|
756
|
-
return node.parent.kind !==
|
|
757
|
-
case
|
|
764
|
+
return node.parent.kind !== 224 /* SyntaxKind.VoidExpression */;
|
|
765
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
758
766
|
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
759
|
-
case
|
|
760
|
-
return node.parent.kind ===
|
|
767
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
768
|
+
return node.parent.kind === 202 /* SyntaxKind.MappedType */ || node.parent.kind === 197 /* SyntaxKind.InferType */;
|
|
761
769
|
case 79 /* SyntaxKind.Identifier */: {
|
|
762
770
|
const parent = node.parent;
|
|
763
|
-
if (parent.kind ===
|
|
771
|
+
if (parent.kind === 168 /* SyntaxKind.QualifiedName */ && parent.right === node)
|
|
764
772
|
return isPartOfTypeNodeInParent(parent);
|
|
765
|
-
if (parent.kind ===
|
|
773
|
+
if (parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */ && parent.name === node)
|
|
766
774
|
return isPartOfTypeNodeInParent(parent);
|
|
767
775
|
return isPartOfTypeNodeInParent(node);
|
|
768
776
|
}
|
|
769
|
-
case
|
|
770
|
-
case
|
|
777
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
778
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
771
779
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
772
780
|
return isPartOfTypeNodeInParent(node);
|
|
773
781
|
}
|
|
@@ -775,45 +783,45 @@ export function isPartOfTypeNode(node) {
|
|
|
775
783
|
}
|
|
776
784
|
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
777
785
|
const parent = node.parent;
|
|
778
|
-
return ((parent.kind ===
|
|
786
|
+
return ((parent.kind === 300 /* SyntaxKind.HeritageClause */ &&
|
|
779
787
|
(!isClassLike(parent.parent) || parent.token === 118 /* SyntaxKind.ImplementsKeyword */)) ||
|
|
780
|
-
parent.kind ===
|
|
781
|
-
parent.kind ===
|
|
788
|
+
parent.kind === 325 /* SyntaxKind.JSDocImplementsTag */ ||
|
|
789
|
+
parent.kind === 324 /* SyntaxKind.JSDocAugmentsTag */);
|
|
782
790
|
}
|
|
783
791
|
// Only the parent is tested: in `let a: A.B.C`, `C` and `A.B.C` are type nodes but `A.B` isn't.
|
|
784
792
|
function isPartOfTypeNodeInParent(node) {
|
|
785
793
|
const parent = node.parent;
|
|
786
|
-
if (parent.kind ===
|
|
794
|
+
if (parent.kind === 188 /* SyntaxKind.TypeQuery */)
|
|
787
795
|
return false;
|
|
788
|
-
if (parent.kind ===
|
|
796
|
+
if (parent.kind === 207 /* SyntaxKind.ImportType */)
|
|
789
797
|
return !parent.isTypeOf;
|
|
790
|
-
if (parent.kind >=
|
|
798
|
+
if (parent.kind >= 184 /* SyntaxKind.FirstTypeNode */ && parent.kind <= 207 /* SyntaxKind.LastTypeNode */)
|
|
791
799
|
return true;
|
|
792
800
|
switch (parent.kind) {
|
|
793
|
-
case
|
|
801
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
794
802
|
return isPartOfTypeExpressionWithTypeArguments(parent);
|
|
795
|
-
case
|
|
803
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
796
804
|
return node === parent.constraint;
|
|
797
|
-
case
|
|
798
|
-
case
|
|
799
|
-
case
|
|
800
|
-
case
|
|
801
|
-
case
|
|
802
|
-
case
|
|
803
|
-
case
|
|
804
|
-
case
|
|
805
|
-
case
|
|
806
|
-
case
|
|
807
|
-
case
|
|
808
|
-
case
|
|
809
|
-
case
|
|
810
|
-
case
|
|
811
|
-
case
|
|
812
|
-
case
|
|
805
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
806
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
807
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
808
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
809
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
810
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
811
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
812
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
813
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
814
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
815
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
816
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
817
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
818
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
819
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
820
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
813
821
|
return node === getType(parent);
|
|
814
|
-
case
|
|
815
|
-
case
|
|
816
|
-
case
|
|
822
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
823
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
824
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */: {
|
|
817
825
|
const typeArguments = getTypeArguments(parent);
|
|
818
826
|
return typeArguments !== undefined && typeArguments.nodes.includes(node);
|
|
819
827
|
}
|
|
@@ -828,49 +836,49 @@ export function isExpressionNode(nodeIn) {
|
|
|
828
836
|
case 111 /* SyntaxKind.TrueKeyword */:
|
|
829
837
|
case 96 /* SyntaxKind.FalseKeyword */:
|
|
830
838
|
case 13 /* SyntaxKind.RegularExpressionLiteral */:
|
|
831
|
-
case
|
|
832
|
-
case
|
|
833
|
-
case
|
|
834
|
-
case
|
|
835
|
-
case
|
|
836
|
-
case
|
|
837
|
-
case
|
|
838
|
-
case
|
|
839
|
-
case
|
|
840
|
-
case
|
|
841
|
-
case
|
|
842
|
-
case
|
|
843
|
-
case
|
|
844
|
-
case
|
|
845
|
-
case
|
|
846
|
-
case
|
|
847
|
-
case
|
|
848
|
-
case
|
|
849
|
-
case
|
|
850
|
-
case
|
|
851
|
-
case
|
|
852
|
-
case
|
|
853
|
-
case
|
|
854
|
-
case
|
|
855
|
-
case
|
|
856
|
-
case
|
|
857
|
-
case
|
|
858
|
-
case
|
|
859
|
-
case
|
|
860
|
-
case
|
|
839
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
840
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
841
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
842
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
843
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
844
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
845
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
846
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
847
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
848
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
849
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
850
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
851
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
852
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
853
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
854
|
+
case 224 /* SyntaxKind.VoidExpression */:
|
|
855
|
+
case 222 /* SyntaxKind.DeleteExpression */:
|
|
856
|
+
case 223 /* SyntaxKind.TypeOfExpression */:
|
|
857
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
858
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
859
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
860
|
+
case 229 /* SyntaxKind.ConditionalExpression */:
|
|
861
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
862
|
+
case 230 /* SyntaxKind.TemplateExpression */:
|
|
863
|
+
case 234 /* SyntaxKind.OmittedExpression */:
|
|
864
|
+
case 286 /* SyntaxKind.JsxElement */:
|
|
865
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
866
|
+
case 290 /* SyntaxKind.JsxFragment */:
|
|
867
|
+
case 231 /* SyntaxKind.YieldExpression */:
|
|
868
|
+
case 225 /* SyntaxKind.AwaitExpression */:
|
|
861
869
|
return true;
|
|
862
|
-
case
|
|
870
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
863
871
|
// `import.defer` in `import.defer(...)` isn't an expression.
|
|
864
872
|
return !isImportCall(node.parent) || getExpression(node.parent) !== node;
|
|
865
|
-
case
|
|
866
|
-
return node.parent.kind !==
|
|
867
|
-
case
|
|
868
|
-
while (node.parent.kind ===
|
|
873
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
874
|
+
return node.parent.kind !== 300 /* SyntaxKind.HeritageClause */;
|
|
875
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
876
|
+
while (node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
869
877
|
node = node.parent;
|
|
870
878
|
return isNameReferenceParent(node) || isJsxTagName(node);
|
|
871
879
|
case 80 /* SyntaxKind.PrivateIdentifier */: {
|
|
872
880
|
const parent = node.parent;
|
|
873
|
-
return (parent.kind ===
|
|
881
|
+
return (parent.kind === 228 /* SyntaxKind.BinaryExpression */ &&
|
|
874
882
|
parent.left === node &&
|
|
875
883
|
parent.operatorToken.kind === 102 /* SyntaxKind.InKeyword */);
|
|
876
884
|
}
|
|
@@ -890,55 +898,59 @@ export function isExpressionNode(nodeIn) {
|
|
|
890
898
|
/** Whether `node`'s parent is a `typeof` query, a JSDoc link or a JSDoc name reference. */
|
|
891
899
|
function isNameReferenceParent(node) {
|
|
892
900
|
const parent = node.parent;
|
|
893
|
-
return (parent.kind ===
|
|
901
|
+
return (parent.kind === 188 /* SyntaxKind.TypeQuery */ || isJSDocLinkLike(parent) || parent.kind === 310 /* SyntaxKind.JSDocNameReference */);
|
|
894
902
|
}
|
|
895
903
|
function isInExpressionContext(node) {
|
|
896
904
|
const parent = node.parent;
|
|
897
905
|
switch (parent.kind) {
|
|
898
|
-
case
|
|
899
|
-
case
|
|
900
|
-
case
|
|
901
|
-
case
|
|
902
|
-
case
|
|
903
|
-
case
|
|
904
|
-
case
|
|
906
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
907
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
908
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
909
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
910
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
911
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
912
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
905
913
|
return getInitializer(parent) === node;
|
|
906
|
-
case
|
|
907
|
-
case
|
|
908
|
-
case
|
|
909
|
-
case
|
|
910
|
-
case
|
|
911
|
-
case
|
|
912
|
-
case
|
|
913
|
-
case
|
|
914
|
-
case
|
|
915
|
-
case
|
|
916
|
-
case
|
|
917
|
-
case
|
|
918
|
-
case
|
|
919
|
-
case
|
|
920
|
-
case
|
|
914
|
+
case 246 /* SyntaxKind.ExpressionStatement */:
|
|
915
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
916
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
917
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
918
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
919
|
+
case 256 /* SyntaxKind.WithStatement */:
|
|
920
|
+
case 257 /* SyntaxKind.SwitchStatement */:
|
|
921
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
922
|
+
case 299 /* SyntaxKind.DefaultClause */:
|
|
923
|
+
case 259 /* SyntaxKind.ThrowStatement */:
|
|
924
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
925
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
926
|
+
case 241 /* SyntaxKind.TemplateSpan */:
|
|
927
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
928
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
921
929
|
return getExpression(parent) === node;
|
|
922
|
-
case
|
|
930
|
+
case 250 /* SyntaxKind.ForStatement */: {
|
|
923
931
|
const s = parent;
|
|
924
|
-
return ((s.initializer === node && node.kind !==
|
|
932
|
+
return ((s.initializer === node && node.kind !== 263 /* SyntaxKind.VariableDeclarationList */) ||
|
|
925
933
|
s.condition === node ||
|
|
926
934
|
s.incrementor === node);
|
|
927
935
|
}
|
|
928
|
-
case
|
|
929
|
-
case
|
|
936
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
937
|
+
case 252 /* SyntaxKind.ForOfStatement */: {
|
|
930
938
|
const s = parent;
|
|
931
|
-
return (s.initializer === node && node.kind !==
|
|
939
|
+
return (s.initializer === node && node.kind !== 263 /* SyntaxKind.VariableDeclarationList */) || s.expression === node;
|
|
932
940
|
}
|
|
933
|
-
case
|
|
934
|
-
case
|
|
935
|
-
case
|
|
936
|
-
case
|
|
941
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
942
|
+
case 296 /* SyntaxKind.JsxExpression */:
|
|
943
|
+
case 295 /* SyntaxKind.JsxSpreadAttribute */:
|
|
944
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
937
945
|
return true;
|
|
938
|
-
case
|
|
946
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
939
947
|
return getExpression(parent) === node && !isPartOfTypeNode(parent);
|
|
940
|
-
case
|
|
948
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
941
949
|
return parent.objectAssignmentInitializer === node;
|
|
950
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
951
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
952
|
+
// The name of a function or class expression is a declaration name, not an expression.
|
|
953
|
+
return getName(parent) !== node;
|
|
942
954
|
}
|
|
943
955
|
return isExpressionNode(parent);
|
|
944
956
|
}
|
|
@@ -950,27 +962,27 @@ function accessKind(node) {
|
|
|
950
962
|
if (parent === undefined)
|
|
951
963
|
return 0 /* AccessKind.Read */;
|
|
952
964
|
switch (parent.kind) {
|
|
953
|
-
case
|
|
954
|
-
case
|
|
965
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
966
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
955
967
|
return accessKind(parent);
|
|
956
|
-
case
|
|
957
|
-
case
|
|
958
|
-
const operator = parent.kind ===
|
|
968
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
969
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */: {
|
|
970
|
+
const operator = parent.kind === 226 /* SyntaxKind.PrefixUnaryExpression */
|
|
959
971
|
? parent.operator
|
|
960
972
|
: parent.operator;
|
|
961
973
|
return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */
|
|
962
974
|
? 2 /* AccessKind.ReadWrite */
|
|
963
975
|
: 0 /* AccessKind.Read */;
|
|
964
976
|
}
|
|
965
|
-
case
|
|
977
|
+
case 228 /* SyntaxKind.BinaryExpression */: {
|
|
966
978
|
const binary = parent;
|
|
967
979
|
if (binary.left === node && isAssignmentOperator(binary.operatorToken.kind))
|
|
968
980
|
return binary.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */;
|
|
969
981
|
return 0 /* AccessKind.Read */;
|
|
970
982
|
}
|
|
971
|
-
case
|
|
983
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
972
984
|
return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent);
|
|
973
|
-
case
|
|
985
|
+
case 304 /* SyntaxKind.PropertyAssignment */: {
|
|
974
986
|
const parentAccess = accessKind(parent.parent);
|
|
975
987
|
// In `({ x: v } = o)`, the `x` is read and `v` written.
|
|
976
988
|
if (node === getName(parent)) {
|
|
@@ -982,13 +994,13 @@ function accessKind(node) {
|
|
|
982
994
|
}
|
|
983
995
|
return parentAccess;
|
|
984
996
|
}
|
|
985
|
-
case
|
|
997
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
986
998
|
// The local variable is what's accessed.
|
|
987
999
|
if (node === parent.objectAssignmentInitializer)
|
|
988
1000
|
return 0 /* AccessKind.Read */;
|
|
989
1001
|
return accessKind(parent.parent);
|
|
990
|
-
case
|
|
991
|
-
case
|
|
1002
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
1003
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
992
1004
|
return node === parent.initializer ? 1 /* AccessKind.Write */ : 0 /* AccessKind.Read */;
|
|
993
1005
|
}
|
|
994
1006
|
return 0 /* AccessKind.Read */;
|