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
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
// to, except where a property access of a const enum (or an enum member in an enum
|
|
4
4
|
// initializer) is inlined. Without types, a property access through anything but an alias of a
|
|
5
5
|
// namespace, enum or module counts as a use.
|
|
6
|
-
import { BinaryExpression, ConditionalTypeNode, ExportAssignment, ExportDeclaration, ExportSpecifier, ForInOrOfStatement, ForStatement, HeritageClause, Identifier, ImportEqualsDeclaration, ImportTypeNode, LiteralTypeNode, MetaProperty, NodeVisitor, PropertyAccessExpression, QualifiedName, ShorthandPropertyAssignment, TypeParameterDeclaration, TypeReferenceNode, VariableDeclarationList, IntersectionTypeNode, UnionTypeNode, getDotDotDotToken, getExpression, getInitializer, getParameters, getTagName, getType, getTypeArguments, } from '../ast.js';
|
|
6
|
+
import { BinaryExpression, ComputedPropertyName, ConditionalTypeNode, ExportAssignment, ExportDeclaration, ExportSpecifier, ForInOrOfStatement, ForStatement, HeritageClause, Identifier, ImportEqualsDeclaration, ImportTypeNode, LiteralTypeNode, MetaProperty, NodeVisitor, PropertyAccessExpression, QualifiedName, ShorthandPropertyAssignment, TypeParameterDeclaration, TypeReferenceNode, VariableDeclarationList, IntersectionTypeNode, UnionTypeNode, getDotDotDotToken, getExpression, getHeritageClauses, getInitializer, getName, getParameters, getTagName, getType, getTypeArguments, } from '../ast.js';
|
|
7
7
|
import { canHaveDecorators, isImportCall } from '../ast-utilities.js';
|
|
8
|
+
import { isAssignmentTarget, isClassLike } from '../binder-utilities.js';
|
|
8
9
|
import { JsxEmit, getIsolatedModules, getStrictOptionValue, shouldPreserveConstEnums, } from '../options.js';
|
|
9
10
|
import { getDeclarationOfAliasSymbol } from './reference-resolver.js';
|
|
10
|
-
import { getFirstConstructorWithBody, getRestParameterElementType, getSetAccessorValueParameter, nodeCanBeDecorated, } from './decorator-utilities.js';
|
|
11
|
+
import { getFirstConstructorWithBody, getRestParameterElementType, getSetAccessorValueParameter, isAccessor, nodeCanBeDecorated, } from './decorator-utilities.js';
|
|
11
12
|
import { hasDecorators, hasSyntacticModifier } from './utilities.js';
|
|
12
13
|
import { getDeclarations } from '../symbol.js';
|
|
13
14
|
export class AliasReferences extends NodeVisitor {
|
|
@@ -36,7 +37,7 @@ export class AliasReferences extends NodeVisitor {
|
|
|
36
37
|
// Imports are marked by their uses.
|
|
37
38
|
if (node instanceof ImportEqualsDeclaration && !hasSyntacticModifier(node, 32 /* ModifierFlags.Export */))
|
|
38
39
|
return false;
|
|
39
|
-
if (node.kind ===
|
|
40
|
+
if (node.kind === 274 /* SyntaxKind.ImportDeclaration */ || node.kind === 347 /* SyntaxKind.JSImportDeclaration */)
|
|
40
41
|
return false;
|
|
41
42
|
this.mark(node);
|
|
42
43
|
node.forEachChild(this);
|
|
@@ -45,15 +46,20 @@ export class AliasReferences extends NodeVisitor {
|
|
|
45
46
|
mark(node) {
|
|
46
47
|
// Types and declaration files don't use imports, except decorated properties.
|
|
47
48
|
if ((node.flags & 8388608 /* NodeFlags.Ambient */) !== 0 &&
|
|
48
|
-
node.kind !==
|
|
49
|
-
node.kind !==
|
|
49
|
+
node.kind !== 173 /* SyntaxKind.PropertySignature */ &&
|
|
50
|
+
node.kind !== 174 /* SyntaxKind.PropertyDeclaration */)
|
|
51
|
+
return false;
|
|
52
|
+
// tsgo doesn't answer semantic questions inside a `with` statement.
|
|
53
|
+
if ((node.flags & 16777216 /* NodeFlags.InWithStatement */) !== 0)
|
|
50
54
|
return false;
|
|
51
55
|
if (node instanceof Identifier) {
|
|
52
56
|
const parent = node.parent;
|
|
53
57
|
if (parent === undefined ||
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
isUnresolvedIdentifier(node, this.options.experimentalDecorators === true))
|
|
59
|
+
return false;
|
|
60
|
+
if (!(isExpressionNode(node) ||
|
|
61
|
+
parent instanceof ShorthandPropertyAssignment ||
|
|
62
|
+
(parent instanceof ImportEqualsDeclaration && parent.moduleReference === node)) ||
|
|
57
63
|
!shouldMarkIdentifier(node))
|
|
58
64
|
return false;
|
|
59
65
|
// Only the left of a property access or qualified name; the right is a property lookup.
|
|
@@ -61,13 +67,13 @@ export class AliasReferences extends NodeVisitor {
|
|
|
61
67
|
return false;
|
|
62
68
|
if (parent instanceof QualifiedName && parent.left !== node)
|
|
63
69
|
return false;
|
|
64
|
-
if (isInsideMetaProperty(node))
|
|
65
|
-
return false;
|
|
66
70
|
return this.markIdentifier(node);
|
|
67
71
|
}
|
|
68
|
-
if (node.kind ===
|
|
72
|
+
if (node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
69
73
|
for (let top = node; top !== undefined && isPropertyAccessOrQualifiedName(top); top = top.parent)
|
|
70
|
-
|
|
74
|
+
// Names in an import type's qualifier, `ns.y` in `typeof import("./b").ns.y`, are exports of the
|
|
75
|
+
// imported module, not references to this file's imports.
|
|
76
|
+
if (isPartOfTypeNode(top) || isImportTypeQualifierPart(top))
|
|
71
77
|
return false;
|
|
72
78
|
return this.markProperty(node);
|
|
73
79
|
}
|
|
@@ -81,9 +87,9 @@ export class AliasReferences extends NodeVisitor {
|
|
|
81
87
|
return true;
|
|
82
88
|
}
|
|
83
89
|
switch (node.kind) {
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
90
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
91
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
92
|
+
case 291 /* SyntaxKind.JsxOpeningFragment */:
|
|
87
93
|
return this.markJsx(node);
|
|
88
94
|
}
|
|
89
95
|
if (node instanceof ImportEqualsDeclaration) {
|
|
@@ -103,14 +109,14 @@ export class AliasReferences extends NodeVisitor {
|
|
|
103
109
|
/** Type references that decorator metadata serializes as values use the aliases they name. */
|
|
104
110
|
markDecoratorMetadata(node) {
|
|
105
111
|
switch (node.kind) {
|
|
106
|
-
case
|
|
112
|
+
case 265 /* SyntaxKind.ClassDeclaration */: {
|
|
107
113
|
const constructor = getFirstConstructorWithBody(node);
|
|
108
114
|
if (constructor !== undefined)
|
|
109
115
|
this.markParameterTypes(constructor);
|
|
110
116
|
break;
|
|
111
117
|
}
|
|
112
|
-
case
|
|
113
|
-
case
|
|
118
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
119
|
+
case 180 /* SyntaxKind.SetAccessor */: {
|
|
114
120
|
let annotation = getAnnotatedAccessorTypeNode(node);
|
|
115
121
|
if (annotation === undefined) {
|
|
116
122
|
const other = this.getOtherAccessor(node);
|
|
@@ -120,14 +126,14 @@ export class AliasReferences extends NodeVisitor {
|
|
|
120
126
|
this.markMetadataTypeNode(annotation);
|
|
121
127
|
break;
|
|
122
128
|
}
|
|
123
|
-
case
|
|
129
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
124
130
|
this.markParameterTypes(node);
|
|
125
131
|
this.markMetadataTypeNode(getType(node));
|
|
126
132
|
break;
|
|
127
|
-
case
|
|
133
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
128
134
|
this.markMetadataTypeNode(getType(node));
|
|
129
135
|
break;
|
|
130
|
-
case
|
|
136
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
131
137
|
this.markMetadataTypeNode(getParameterTypeNodeForDecoratorCheck(node));
|
|
132
138
|
if (node.parent !== undefined) {
|
|
133
139
|
this.markParameterTypes(node.parent);
|
|
@@ -149,7 +155,7 @@ export class AliasReferences extends NodeVisitor {
|
|
|
149
155
|
const symbol = this.resolver.getSymbolOfDeclaration(node);
|
|
150
156
|
if (symbol === undefined)
|
|
151
157
|
return undefined;
|
|
152
|
-
const kind = node.kind ===
|
|
158
|
+
const kind = node.kind === 180 /* SyntaxKind.SetAccessor */ ? 179 /* SyntaxKind.GetAccessor */ : 180 /* SyntaxKind.SetAccessor */;
|
|
153
159
|
for (const declaration of getDeclarations(symbol))
|
|
154
160
|
if (declaration.kind === kind)
|
|
155
161
|
return declaration;
|
|
@@ -176,17 +182,17 @@ export class AliasReferences extends NodeVisitor {
|
|
|
176
182
|
if (node === undefined)
|
|
177
183
|
return undefined;
|
|
178
184
|
switch (node.kind) {
|
|
179
|
-
case
|
|
180
|
-
case
|
|
185
|
+
case 195 /* SyntaxKind.IntersectionType */:
|
|
186
|
+
case 194 /* SyntaxKind.UnionType */:
|
|
181
187
|
return this.getEntityNameForDecoratorMetadataFromTypeList(getTypes(node));
|
|
182
|
-
case
|
|
188
|
+
case 196 /* SyntaxKind.ConditionalType */:
|
|
183
189
|
if (node instanceof ConditionalTypeNode)
|
|
184
190
|
return this.getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
|
|
185
191
|
break;
|
|
186
|
-
case
|
|
187
|
-
case
|
|
192
|
+
case 198 /* SyntaxKind.ParenthesizedType */:
|
|
193
|
+
case 204 /* SyntaxKind.NamedTupleMember */:
|
|
188
194
|
return this.getEntityNameForDecoratorMetadata(getType(node));
|
|
189
|
-
case
|
|
195
|
+
case 185 /* SyntaxKind.TypeReference */:
|
|
190
196
|
if (node instanceof TypeReferenceNode)
|
|
191
197
|
return node.typeName;
|
|
192
198
|
break;
|
|
@@ -244,7 +250,7 @@ export class AliasReferences extends NodeVisitor {
|
|
|
244
250
|
this.referenced.add(symbol);
|
|
245
251
|
const declaration = getDeclarationOfAliasSymbol(symbol);
|
|
246
252
|
if (declaration instanceof ImportEqualsDeclaration &&
|
|
247
|
-
declaration.moduleReference.kind !==
|
|
253
|
+
declaration.moduleReference.kind !== 285 /* SyntaxKind.ExternalModuleReference */) {
|
|
248
254
|
const target = this.resolver.resolveAlias(symbol);
|
|
249
255
|
const flags = target === undefined ? 4 /* SymbolFlags.Property */ : this.resolver.getSymbolFlags(target, false, false);
|
|
250
256
|
if ((flags & 111551 /* SymbolFlags.Value */) !== 0)
|
|
@@ -271,7 +277,7 @@ export class AliasReferences extends NodeVisitor {
|
|
|
271
277
|
(isConstEnumOrConstEnumOnlyModule(property) ||
|
|
272
278
|
((property.flags & 8 /* SymbolFlags.EnumMember */) !== 0 &&
|
|
273
279
|
node.parent !== undefined &&
|
|
274
|
-
node.parent.kind ===
|
|
280
|
+
node.parent.kind === 307 /* SyntaxKind.EnumMember */)))
|
|
275
281
|
return false;
|
|
276
282
|
return this.markAlias(parentSymbol, node);
|
|
277
283
|
}
|
|
@@ -288,7 +294,7 @@ export class AliasReferences extends NodeVisitor {
|
|
|
288
294
|
markJsx(node) {
|
|
289
295
|
if (this.jsxRuntimeResolved)
|
|
290
296
|
return false;
|
|
291
|
-
const fragment = node.kind ===
|
|
297
|
+
const fragment = node.kind === 291 /* SyntaxKind.JsxOpeningFragment */;
|
|
292
298
|
const location = fragment ? node : jsxTagName(node);
|
|
293
299
|
const namespace = fragment ? this.jsxFragmentNamespace : this.jsxNamespace;
|
|
294
300
|
// `@jsxFrag null` has no fragment factory.
|
|
@@ -337,8 +343,18 @@ export class AliasReferences extends NodeVisitor {
|
|
|
337
343
|
return true;
|
|
338
344
|
}
|
|
339
345
|
}
|
|
346
|
+
/** Whether `node` is the qualifier of an import type, or a part of one. */
|
|
347
|
+
function isImportTypeQualifierPart(node) {
|
|
348
|
+
let current = node;
|
|
349
|
+
let parent = current.parent;
|
|
350
|
+
while (parent !== undefined && parent.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
351
|
+
current = parent;
|
|
352
|
+
parent = parent.parent;
|
|
353
|
+
}
|
|
354
|
+
return parent instanceof ImportTypeNode && parent.qualifier === current;
|
|
355
|
+
}
|
|
340
356
|
function isPropertyAccessOrQualifiedName(node) {
|
|
341
|
-
return node.kind ===
|
|
357
|
+
return node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 168 /* SyntaxKind.QualifiedName */;
|
|
342
358
|
}
|
|
343
359
|
function leftOf(node) {
|
|
344
360
|
if (node instanceof PropertyAccessExpression)
|
|
@@ -372,17 +388,105 @@ function shouldMarkIdentifier(node) {
|
|
|
372
388
|
const exportDeclaration = grandparent === undefined ? undefined : grandparent.parent;
|
|
373
389
|
return !(exportDeclaration instanceof ExportDeclaration && exportDeclaration.isTypeOnly);
|
|
374
390
|
}
|
|
375
|
-
|
|
376
|
-
|
|
391
|
+
/**
|
|
392
|
+
* Whether checking never resolves identifier `node`, so tsgo doesn't mark it: in a meta property, the name of a
|
|
393
|
+
* shorthand property with an initializer outside a destructuring assignment, in a decorator of a node that can't be
|
|
394
|
+
* decorated, in the expression of `for (var of x)`, in an invalid computed property name, in an interface's heritage
|
|
395
|
+
* clause, or in a class's `extends` types after the first.
|
|
396
|
+
*/
|
|
397
|
+
function isUnresolvedIdentifier(node, legacyDecorators) {
|
|
398
|
+
const parent = node.parent;
|
|
399
|
+
if (parent instanceof ShorthandPropertyAssignment &&
|
|
400
|
+
parent.name === node &&
|
|
401
|
+
parent.objectAssignmentInitializer !== undefined &&
|
|
402
|
+
!isAssignmentTarget(parent.parent))
|
|
403
|
+
return true;
|
|
404
|
+
let decorator = undefined;
|
|
405
|
+
let forNode = undefined;
|
|
406
|
+
let computedName = undefined;
|
|
407
|
+
let heritageClause = undefined;
|
|
408
|
+
for (let current = node; current !== undefined; current = current.parent) {
|
|
377
409
|
if (current instanceof MetaProperty)
|
|
378
410
|
return true;
|
|
411
|
+
if (current.kind === 172 /* SyntaxKind.Decorator */) {
|
|
412
|
+
if (decorator === undefined)
|
|
413
|
+
decorator = current;
|
|
414
|
+
}
|
|
415
|
+
else if (current instanceof ForInOrOfStatement) {
|
|
416
|
+
if (forNode === undefined)
|
|
417
|
+
forNode = current;
|
|
418
|
+
}
|
|
419
|
+
else if (current instanceof ComputedPropertyName) {
|
|
420
|
+
if (computedName === undefined)
|
|
421
|
+
computedName = current;
|
|
422
|
+
}
|
|
423
|
+
else if (current instanceof HeritageClause) {
|
|
424
|
+
if (heritageClause === undefined)
|
|
425
|
+
heritageClause = current;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (decorator !== undefined) {
|
|
429
|
+
const decorated = decorator.parent;
|
|
430
|
+
if (decorated !== undefined &&
|
|
431
|
+
!nodeCanBeDecorated(legacyDecorators, decorated, decorated.parent, decorated.parent === undefined ? undefined : decorated.parent.parent))
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
if (forNode !== undefined) {
|
|
435
|
+
const statement = forNode;
|
|
436
|
+
if (statement.initializer instanceof VariableDeclarationList &&
|
|
437
|
+
statement.initializer.declarations.nodes.length === 0 &&
|
|
438
|
+
(node === statement.expression || isNodeDescendantOf(node, statement.expression)))
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
if (computedName !== undefined) {
|
|
442
|
+
const grandparent = computedName.parent.parent;
|
|
443
|
+
if ((grandparent.kind === 189 /* SyntaxKind.TypeLiteral */ ||
|
|
444
|
+
isClassLike(grandparent) ||
|
|
445
|
+
grandparent.kind === 266 /* SyntaxKind.InterfaceDeclaration */) &&
|
|
446
|
+
computedName.expression instanceof BinaryExpression &&
|
|
447
|
+
computedName.expression.operatorToken.kind ===
|
|
448
|
+
102 /* SyntaxKind.InKeyword */ &&
|
|
449
|
+
!isAccessor(computedName.parent))
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
if (heritageClause !== undefined) {
|
|
453
|
+
const declaration = heritageClause.parent;
|
|
454
|
+
// An interface's heritage clauses are types.
|
|
455
|
+
if (declaration.kind === 266 /* SyntaxKind.InterfaceDeclaration */)
|
|
456
|
+
return true;
|
|
457
|
+
// Only a class's first `extends` type is its base class; checking never resolves the others.
|
|
458
|
+
if (isClassLike(declaration) && heritageClause.token === 95 /* SyntaxKind.ExtendsKeyword */) {
|
|
459
|
+
const first = getClassExtendsHeritageElement(declaration);
|
|
460
|
+
if (first !== undefined && node !== first && !isNodeDescendantOf(node, first))
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
/** The first type of a class's first `extends` clause. */
|
|
467
|
+
function getClassExtendsHeritageElement(node) {
|
|
468
|
+
const clauses = getHeritageClauses(node);
|
|
469
|
+
if (clauses === undefined)
|
|
470
|
+
return undefined;
|
|
471
|
+
for (const clause of clauses.nodes)
|
|
472
|
+
if (clause.token === 95 /* SyntaxKind.ExtendsKeyword */) {
|
|
473
|
+
const types = clause.types.nodes;
|
|
474
|
+
return types.length > 0 ? types[0] : undefined;
|
|
475
|
+
}
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
/** Whether `node` is inside `ancestor`. */
|
|
479
|
+
function isNodeDescendantOf(node, ancestor) {
|
|
480
|
+
for (let current = node.parent; current !== undefined; current = current.parent)
|
|
481
|
+
if (current === ancestor)
|
|
482
|
+
return true;
|
|
379
483
|
return false;
|
|
380
484
|
}
|
|
381
485
|
function isInTypeQuery(node) {
|
|
382
486
|
for (let current = node; current !== undefined; current = current.parent) {
|
|
383
|
-
if (current.kind ===
|
|
487
|
+
if (current.kind === 188 /* SyntaxKind.TypeQuery */)
|
|
384
488
|
return true;
|
|
385
|
-
if (current.kind !== 79 /* SyntaxKind.Identifier */ && current.kind !==
|
|
489
|
+
if (current.kind !== 79 /* SyntaxKind.Identifier */ && current.kind !== 168 /* SyntaxKind.QualifiedName */)
|
|
386
490
|
return false;
|
|
387
491
|
}
|
|
388
492
|
return false;
|
|
@@ -440,49 +544,49 @@ export function isExpressionNode(node) {
|
|
|
440
544
|
case 111 /* SyntaxKind.TrueKeyword */:
|
|
441
545
|
case 96 /* SyntaxKind.FalseKeyword */:
|
|
442
546
|
case 13 /* SyntaxKind.RegularExpressionLiteral */:
|
|
443
|
-
case
|
|
444
|
-
case
|
|
445
|
-
case
|
|
446
|
-
case
|
|
447
|
-
case
|
|
448
|
-
case
|
|
449
|
-
case
|
|
450
|
-
case
|
|
451
|
-
case
|
|
452
|
-
case
|
|
453
|
-
case
|
|
454
|
-
case
|
|
455
|
-
case
|
|
456
|
-
case
|
|
457
|
-
case
|
|
458
|
-
case
|
|
459
|
-
case
|
|
460
|
-
case
|
|
461
|
-
case
|
|
462
|
-
case
|
|
463
|
-
case
|
|
464
|
-
case
|
|
465
|
-
case
|
|
466
|
-
case
|
|
467
|
-
case
|
|
468
|
-
case
|
|
469
|
-
case
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
case
|
|
547
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
548
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
549
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
550
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
551
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
552
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
553
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
554
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
555
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
556
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
557
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
558
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
559
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
560
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
561
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
562
|
+
case 224 /* SyntaxKind.VoidExpression */:
|
|
563
|
+
case 222 /* SyntaxKind.DeleteExpression */:
|
|
564
|
+
case 223 /* SyntaxKind.TypeOfExpression */:
|
|
565
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
566
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
567
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
568
|
+
case 229 /* SyntaxKind.ConditionalExpression */:
|
|
569
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
570
|
+
case 230 /* SyntaxKind.TemplateExpression */:
|
|
571
|
+
case 234 /* SyntaxKind.OmittedExpression */:
|
|
572
|
+
case 286 /* SyntaxKind.JsxElement */:
|
|
573
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
574
|
+
case 290 /* SyntaxKind.JsxFragment */:
|
|
575
|
+
case 231 /* SyntaxKind.YieldExpression */:
|
|
576
|
+
case 225 /* SyntaxKind.AwaitExpression */:
|
|
473
577
|
return true;
|
|
474
|
-
case
|
|
578
|
+
case 238 /* SyntaxKind.MetaProperty */: {
|
|
475
579
|
const parent = node.parent;
|
|
476
580
|
return !(parent !== undefined && isImportCall(parent) && getExpression(parent) === node);
|
|
477
581
|
}
|
|
478
|
-
case
|
|
582
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
479
583
|
return !(node.parent instanceof HeritageClause);
|
|
480
|
-
case
|
|
584
|
+
case 168 /* SyntaxKind.QualifiedName */: {
|
|
481
585
|
let current = node;
|
|
482
|
-
while (current.parent !== undefined && current.parent.kind ===
|
|
586
|
+
while (current.parent !== undefined && current.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
483
587
|
current = current.parent;
|
|
484
588
|
const parent = current.parent;
|
|
485
|
-
return parent !== undefined && (parent.kind ===
|
|
589
|
+
return parent !== undefined && (parent.kind === 188 /* SyntaxKind.TypeQuery */ || isJsxTagName(current));
|
|
486
590
|
}
|
|
487
591
|
case 80 /* SyntaxKind.PrivateIdentifier */: {
|
|
488
592
|
const parent = node.parent;
|
|
@@ -490,7 +594,7 @@ export function isExpressionNode(node) {
|
|
|
490
594
|
}
|
|
491
595
|
case 79 /* SyntaxKind.Identifier */: {
|
|
492
596
|
const parent = node.parent;
|
|
493
|
-
if (parent !== undefined && (parent.kind ===
|
|
597
|
+
if (parent !== undefined && (parent.kind === 188 /* SyntaxKind.TypeQuery */ || isJsxTagName(node)))
|
|
494
598
|
return true;
|
|
495
599
|
return isInExpressionContext(node);
|
|
496
600
|
}
|
|
@@ -508,51 +612,55 @@ function isInExpressionContext(node) {
|
|
|
508
612
|
if (parent === undefined)
|
|
509
613
|
return false;
|
|
510
614
|
switch (parent.kind) {
|
|
511
|
-
case
|
|
512
|
-
case
|
|
513
|
-
case
|
|
514
|
-
case
|
|
515
|
-
case
|
|
516
|
-
case
|
|
517
|
-
case
|
|
615
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
616
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
617
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
618
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
619
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
620
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
621
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
518
622
|
return getInitializer(parent) === node;
|
|
519
|
-
case
|
|
520
|
-
case
|
|
521
|
-
case
|
|
522
|
-
case
|
|
523
|
-
case
|
|
524
|
-
case
|
|
525
|
-
case
|
|
526
|
-
case
|
|
527
|
-
case
|
|
528
|
-
case
|
|
529
|
-
case
|
|
530
|
-
case
|
|
531
|
-
case
|
|
532
|
-
case
|
|
533
|
-
case
|
|
623
|
+
case 246 /* SyntaxKind.ExpressionStatement */:
|
|
624
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
625
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
626
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
627
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
628
|
+
case 256 /* SyntaxKind.WithStatement */:
|
|
629
|
+
case 257 /* SyntaxKind.SwitchStatement */:
|
|
630
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
631
|
+
case 299 /* SyntaxKind.DefaultClause */:
|
|
632
|
+
case 259 /* SyntaxKind.ThrowStatement */:
|
|
633
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
634
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
635
|
+
case 241 /* SyntaxKind.TemplateSpan */:
|
|
636
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
637
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
534
638
|
return getExpression(parent) === node;
|
|
535
|
-
case
|
|
639
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
536
640
|
if (!(parent instanceof ForStatement))
|
|
537
641
|
return false;
|
|
538
642
|
return ((parent.initializer === node && !(parent.initializer instanceof VariableDeclarationList)) ||
|
|
539
643
|
parent.condition === node ||
|
|
540
644
|
parent.incrementor === node);
|
|
541
|
-
case
|
|
542
|
-
case
|
|
645
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
646
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
543
647
|
if (!(parent instanceof ForInOrOfStatement))
|
|
544
648
|
return false;
|
|
545
649
|
return ((parent.initializer === node && !(parent.initializer instanceof VariableDeclarationList)) ||
|
|
546
650
|
parent.expression === node);
|
|
547
|
-
case
|
|
548
|
-
case
|
|
549
|
-
case
|
|
550
|
-
case
|
|
651
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
652
|
+
case 296 /* SyntaxKind.JsxExpression */:
|
|
653
|
+
case 295 /* SyntaxKind.JsxSpreadAttribute */:
|
|
654
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
551
655
|
return true;
|
|
552
|
-
case
|
|
656
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
553
657
|
return getExpression(parent) === node && !isPartOfTypeNode(parent);
|
|
554
|
-
case
|
|
658
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
555
659
|
return parent instanceof ShorthandPropertyAssignment && parent.objectAssignmentInitializer === node;
|
|
660
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
661
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
662
|
+
// The name of a function or class expression is a declaration name, not an expression.
|
|
663
|
+
return getName(parent) !== node;
|
|
556
664
|
}
|
|
557
665
|
return isExpressionNode(parent);
|
|
558
666
|
}
|
|
@@ -561,16 +669,16 @@ function isJsxTagName(node) {
|
|
|
561
669
|
if (parent === undefined)
|
|
562
670
|
return false;
|
|
563
671
|
switch (parent.kind) {
|
|
564
|
-
case
|
|
565
|
-
case
|
|
566
|
-
case
|
|
672
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
673
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
674
|
+
case 289 /* SyntaxKind.JsxClosingElement */:
|
|
567
675
|
return getTagName(parent) === node;
|
|
568
676
|
}
|
|
569
677
|
return false;
|
|
570
678
|
}
|
|
571
679
|
export function isPartOfTypeNode(node) {
|
|
572
680
|
const kind = node.kind;
|
|
573
|
-
if (kind >=
|
|
681
|
+
if (kind >= 184 /* SyntaxKind.FirstTypeNode */ && kind <= 207 /* SyntaxKind.LastTypeNode */)
|
|
574
682
|
return true;
|
|
575
683
|
switch (kind) {
|
|
576
684
|
case 132 /* SyntaxKind.AnyKeyword */:
|
|
@@ -586,12 +694,12 @@ export function isPartOfTypeNode(node) {
|
|
|
586
694
|
case 146 /* SyntaxKind.NeverKeyword */:
|
|
587
695
|
return true;
|
|
588
696
|
case 115 /* SyntaxKind.VoidKeyword */:
|
|
589
|
-
return node.parent !== undefined && node.parent.kind !==
|
|
590
|
-
case
|
|
697
|
+
return node.parent !== undefined && node.parent.kind !== 224 /* SyntaxKind.VoidExpression */;
|
|
698
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
591
699
|
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
592
|
-
case
|
|
700
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
593
701
|
return (node.parent !== undefined &&
|
|
594
|
-
(node.parent.kind ===
|
|
702
|
+
(node.parent.kind === 202 /* SyntaxKind.MappedType */ || node.parent.kind === 197 /* SyntaxKind.InferType */));
|
|
595
703
|
case 79 /* SyntaxKind.Identifier */: {
|
|
596
704
|
const parent = node.parent;
|
|
597
705
|
if (parent instanceof QualifiedName && parent.right === node)
|
|
@@ -600,8 +708,8 @@ export function isPartOfTypeNode(node) {
|
|
|
600
708
|
return isPartOfTypeNodeInParent(parent);
|
|
601
709
|
return isPartOfTypeNodeInParent(node);
|
|
602
710
|
}
|
|
603
|
-
case
|
|
604
|
-
case
|
|
711
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
712
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
605
713
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
606
714
|
return isPartOfTypeNodeInParent(node);
|
|
607
715
|
}
|
|
@@ -609,37 +717,37 @@ export function isPartOfTypeNode(node) {
|
|
|
609
717
|
}
|
|
610
718
|
function isPartOfTypeNodeInParent(node) {
|
|
611
719
|
const parent = node.parent;
|
|
612
|
-
if (parent === undefined || parent.kind ===
|
|
720
|
+
if (parent === undefined || parent.kind === 188 /* SyntaxKind.TypeQuery */)
|
|
613
721
|
return false;
|
|
614
722
|
if (parent instanceof ImportTypeNode)
|
|
615
723
|
return !parent.isTypeOf;
|
|
616
|
-
if (parent.kind >=
|
|
724
|
+
if (parent.kind >= 184 /* SyntaxKind.FirstTypeNode */ && parent.kind <= 207 /* SyntaxKind.LastTypeNode */)
|
|
617
725
|
return true;
|
|
618
726
|
switch (parent.kind) {
|
|
619
|
-
case
|
|
727
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
620
728
|
return isPartOfTypeExpressionWithTypeArguments(parent);
|
|
621
|
-
case
|
|
729
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
622
730
|
return parent instanceof TypeParameterDeclaration && parent.constraint === node;
|
|
623
|
-
case
|
|
624
|
-
case
|
|
625
|
-
case
|
|
626
|
-
case
|
|
627
|
-
case
|
|
628
|
-
case
|
|
629
|
-
case
|
|
630
|
-
case
|
|
631
|
-
case
|
|
632
|
-
case
|
|
633
|
-
case
|
|
634
|
-
case
|
|
635
|
-
case
|
|
636
|
-
case
|
|
637
|
-
case
|
|
638
|
-
case
|
|
731
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
732
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
733
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
734
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
735
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
736
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
737
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
738
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
739
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
740
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
741
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
742
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
743
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
744
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
745
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
746
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
639
747
|
return getType(parent) === node;
|
|
640
|
-
case
|
|
641
|
-
case
|
|
642
|
-
case
|
|
748
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
749
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
750
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */: {
|
|
643
751
|
const typeArguments = getTypeArguments(parent);
|
|
644
752
|
return typeArguments !== undefined && typeArguments.nodes.indexOf(node) >= 0;
|
|
645
753
|
}
|
|
@@ -651,11 +759,11 @@ function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
|
651
759
|
if (parent instanceof HeritageClause) {
|
|
652
760
|
const container = parent.parent;
|
|
653
761
|
const classLike = container !== undefined &&
|
|
654
|
-
(container.kind ===
|
|
762
|
+
(container.kind === 265 /* SyntaxKind.ClassDeclaration */ || container.kind === 233 /* SyntaxKind.ClassExpression */);
|
|
655
763
|
return !classLike || parent.token === 118 /* SyntaxKind.ImplementsKeyword */;
|
|
656
764
|
}
|
|
657
765
|
return (parent !== undefined &&
|
|
658
|
-
(parent.kind ===
|
|
766
|
+
(parent.kind === 325 /* SyntaxKind.JSDocImplementsTag */ || parent.kind === 324 /* SyntaxKind.JSDocAugmentsTag */));
|
|
659
767
|
}
|
|
660
768
|
function getParameterTypeNodeForDecoratorCheck(node) {
|
|
661
769
|
const type = getType(node);
|
|
@@ -663,7 +771,7 @@ function getParameterTypeNodeForDecoratorCheck(node) {
|
|
|
663
771
|
}
|
|
664
772
|
/** The type annotation of a getter, or of a setter's parameter. */
|
|
665
773
|
function getAnnotatedAccessorTypeNode(node) {
|
|
666
|
-
if (node.kind ===
|
|
774
|
+
if (node.kind === 179 /* SyntaxKind.GetAccessor */)
|
|
667
775
|
return getType(node);
|
|
668
776
|
const parameter = getSetAccessorValueParameter(node);
|
|
669
777
|
return parameter === undefined ? undefined : getType(parameter);
|