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,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Fields of `instanceof`-narrowed nodes are read through `as` casts: scriptc reads them
|
|
5
5
|
// statically, but reads fields of a narrowed value dynamically.
|
|
6
|
-
import { appendToList, BinaryExpression, CallExpression, ConditionalTypeNode, ElementAccessExpression, ExportAssignment, FunctionExpression, KeywordExpression, ModuleDeclaration, NodeVisitor, PatternAmbientModule, PrefixUnaryExpression, PropertyAccessExpression, ReferenceIdentifier, TypeAliasDeclaration, VariableDeclaration, getArguments, getBody, getElements, getExpression, getInitializer, getLabel, getLocals, getModifiers, getName, getParameters, getPostfixToken, getProperties, getStatements, getSymbol, getText, isDeclarationNode, isLocalsContainer, setEndFlowNode, setFlowNode, setLocalSymbol, setLocals, setNextContainer, setReturnFlowNode, setSymbol, callQuestionDotToken, callTypeArguments, } from './ast.js';
|
|
6
|
+
import { appendToList, BinaryExpression, CallExpression, ConditionalTypeNode, ElementAccessExpression, ExportAssignment, FunctionExpression, KeywordExpression, ModuleDeclaration, getNodeId, NodeVisitor, PatternAmbientModule, PrefixUnaryExpression, PropertyAccessExpression, ReferenceIdentifier, TypeAliasDeclaration, VariableDeclaration, getArguments, getBody, getElements, getExpression, getInitializer, getLabel, getLocals, getModifiers, getName, getParameters, getPostfixToken, getProperties, getStatements, getSymbol, getText, isDeclarationNode, isLocalsContainer, setEndFlowNode, setFlowNode, setLocalSymbol, setLocals, setNextContainer, setReturnFlowNode, setSymbol, callQuestionDotToken, callTypeArguments, } from './ast.js';
|
|
7
7
|
import { isAmbientModule, isAssignmentOperator, isFunctionLike, isGlobalScopeAugmentation, isInJSFile, isLeftHandSideExpression, isRequireCall, isStringLiteralLike, nodeIsMissing, nodeIsPresent, } from './ast-utilities.js';
|
|
8
8
|
import { declarationNameToString, expressionIsAlias, getAssignmentDeclarationKind, getCombinedModifierFlags, getContainingClass, getElementOrPropertyAccessName, getErrorRangeForNode, getImmediatelyInvokedFunctionExpression, getModuleInstanceState, StatementsByName, getNameOfDeclaration, getRangeOfTokenAtPosition, getSourceTextOfNode, hasDynamicName, hasSyntacticModifier, isAssignmentTarget, isAsyncFunction, isAutoAccessorPropertyDeclaration, isBlockOrCatchScoped, isBooleanLiteral, isDeclarationStatementKind, isDestructuringAssignment, isDottedName, isEntityNameExpression, isEnumConst, isExpandoInitializer, isExpressionOfOptionalChainRoot, isExternalModule, isExternalOrCommonJSModule, isIdentifierName, isImplicitlyExportedJSDocDeclaration, isInTopLevelContext, isJsonSourceFile, isLogicalExpression, isLogicalOrCoalescingAssignmentExpression, isLogicalOrCoalescingAssignmentOperator, isLogicalOrCoalescingBinaryOperator, isModuleAugmentationExternal, isNullishCoalesce, isObjectLiteralMethod, isObjectLiteralOrClassExpressionMethodOrAccessor, isOptionalChain, isOptionalChainRoot, isOutermostOptionalChain, isParameterPropertyDeclaration, isPartOfParameterDeclaration, isPartOfTypeQuery, isPotentiallyExecutableNode, isPrologueDirective, isPropertyNameLiteral, isPushOrUnshiftIdentifier, isSignedNumericLiteral, isStatic, isStringOrNumericLiteralLike, isVariableDeclarationInitializedToRequire, moduleExportNameIsDefault, nodeText, skipParentheses, } from './binder-utilities.js';
|
|
9
9
|
import { Diagnostic } from './diagnostics.js';
|
|
@@ -13,26 +13,26 @@ import { getIdentifierToken, tokenToString } from './scanner.js';
|
|
|
13
13
|
import { addDeclaration, copyDeclarations, declarationCount, getDeclarations, getExports, getMembers, getSymbolId, internalSymbolNamePrefix, Symbol, } from './symbol.js';
|
|
14
14
|
export function getContainerFlags(node) {
|
|
15
15
|
switch (node.kind) {
|
|
16
|
-
case
|
|
17
|
-
case
|
|
18
|
-
case
|
|
19
|
-
case
|
|
20
|
-
case
|
|
21
|
-
case
|
|
16
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
17
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
18
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
19
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
20
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
21
|
+
case 294 /* SyntaxKind.JsxAttributes */:
|
|
22
22
|
return 1 /* ContainerFlags.IsContainer */;
|
|
23
|
-
case
|
|
23
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
24
24
|
return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */;
|
|
25
|
-
case
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
25
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
26
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
27
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
28
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
29
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
30
30
|
return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */;
|
|
31
|
-
case
|
|
31
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
32
32
|
return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */;
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
33
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
34
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
35
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
36
36
|
if (isObjectLiteralOrClassExpressionMethodOrAccessor(node))
|
|
37
37
|
return (1 /* ContainerFlags.IsContainer */ |
|
|
38
38
|
4 /* ContainerFlags.IsControlFlowContainer */ |
|
|
@@ -41,49 +41,49 @@ export function getContainerFlags(node) {
|
|
|
41
41
|
128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */ |
|
|
42
42
|
256 /* ContainerFlags.IsThisContainer */);
|
|
43
43
|
return functionContainerFlags;
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
44
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
45
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
46
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
47
47
|
return functionContainerFlags;
|
|
48
|
-
case
|
|
49
|
-
case
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
case
|
|
48
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
49
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
50
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
51
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
52
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
53
53
|
return (1 /* ContainerFlags.IsContainer */ |
|
|
54
54
|
4 /* ContainerFlags.IsControlFlowContainer */ |
|
|
55
55
|
32 /* ContainerFlags.HasLocals */ |
|
|
56
56
|
8 /* ContainerFlags.IsFunctionLike */ |
|
|
57
57
|
512 /* ContainerFlags.PropagatesThisKeyword */);
|
|
58
|
-
case
|
|
58
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
59
59
|
return (1 /* ContainerFlags.IsContainer */ |
|
|
60
60
|
4 /* ContainerFlags.IsControlFlowContainer */ |
|
|
61
61
|
32 /* ContainerFlags.HasLocals */ |
|
|
62
62
|
8 /* ContainerFlags.IsFunctionLike */ |
|
|
63
63
|
16 /* ContainerFlags.IsFunctionExpression */ |
|
|
64
64
|
256 /* ContainerFlags.IsThisContainer */);
|
|
65
|
-
case
|
|
65
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
66
66
|
return (1 /* ContainerFlags.IsContainer */ |
|
|
67
67
|
4 /* ContainerFlags.IsControlFlowContainer */ |
|
|
68
68
|
32 /* ContainerFlags.HasLocals */ |
|
|
69
69
|
8 /* ContainerFlags.IsFunctionLike */ |
|
|
70
70
|
16 /* ContainerFlags.IsFunctionExpression */ |
|
|
71
71
|
512 /* ContainerFlags.PropagatesThisKeyword */);
|
|
72
|
-
case
|
|
72
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
73
73
|
return 4 /* ContainerFlags.IsControlFlowContainer */;
|
|
74
|
-
case
|
|
74
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
75
75
|
return getInitializer(node) !== undefined
|
|
76
76
|
? 4 /* ContainerFlags.IsControlFlowContainer */ | 256 /* ContainerFlags.IsThisContainer */
|
|
77
77
|
: 0 /* ContainerFlags.None */;
|
|
78
|
-
case
|
|
79
|
-
case
|
|
80
|
-
case
|
|
81
|
-
case
|
|
82
|
-
case
|
|
78
|
+
case 301 /* SyntaxKind.CatchClause */:
|
|
79
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
80
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
81
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
82
|
+
case 271 /* SyntaxKind.CaseBlock */:
|
|
83
83
|
return 2 /* ContainerFlags.IsBlockScopedContainer */ | 32 /* ContainerFlags.HasLocals */;
|
|
84
|
-
case
|
|
84
|
+
case 243 /* SyntaxKind.Block */: {
|
|
85
85
|
const parent = node.parent;
|
|
86
|
-
return isFunctionLike(parent) || parent.kind ===
|
|
86
|
+
return isFunctionLike(parent) || parent.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */
|
|
87
87
|
? 0 /* ContainerFlags.None */
|
|
88
88
|
: 2 /* ContainerFlags.IsBlockScopedContainer */ | 32 /* ContainerFlags.HasLocals */;
|
|
89
89
|
}
|
|
@@ -148,17 +148,17 @@ export function setValueDeclaration(symbol, node) {
|
|
|
148
148
|
}
|
|
149
149
|
function isAssignmentDeclaration(declaration) {
|
|
150
150
|
switch (declaration.kind) {
|
|
151
|
-
case
|
|
152
|
-
case
|
|
153
|
-
case
|
|
151
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
152
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
153
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
154
154
|
case 79 /* SyntaxKind.Identifier */:
|
|
155
|
-
case
|
|
155
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
156
156
|
return true;
|
|
157
157
|
}
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
160
|
function isEffectiveModuleDeclaration(node) {
|
|
161
|
-
return node.kind ===
|
|
161
|
+
return node.kind === 269 /* SyntaxKind.ModuleDeclaration */ || node.kind === 79 /* SyntaxKind.Identifier */;
|
|
162
162
|
}
|
|
163
163
|
class Binder extends NodeVisitor {
|
|
164
164
|
file;
|
|
@@ -251,7 +251,7 @@ class Binder extends NodeVisitor {
|
|
|
251
251
|
}
|
|
252
252
|
declareSymbolEx(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) {
|
|
253
253
|
const isDefaultExport = hasSyntacticModifier(node, 2048 /* ModifierFlags.Default */) ||
|
|
254
|
-
(node.kind ===
|
|
254
|
+
(node.kind === 283 /* SyntaxKind.ExportSpecifier */ && moduleExportNameIsDefault(getName(node)));
|
|
255
255
|
// The exported symbol of `export default function/class` is always named "default".
|
|
256
256
|
const name = isComputedName
|
|
257
257
|
? "\uFFFEcomputed" /* InternalSymbolName.Computed */
|
|
@@ -298,18 +298,18 @@ class Binder extends NodeVisitor {
|
|
|
298
298
|
}
|
|
299
299
|
reportDuplicate(symbol, node, includes, isDefaultExport) {
|
|
300
300
|
let message = (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0
|
|
301
|
-
?
|
|
302
|
-
:
|
|
301
|
+
? 626 /* Diagnostics.Cannot_redeclare_block_scoped_variable_0 */
|
|
302
|
+
: 485 /* Diagnostics.Duplicate_identifier_0 */;
|
|
303
303
|
let messageNeedsName = true;
|
|
304
304
|
if ((symbol.flags & 384 /* SymbolFlags.Enum */) !== 0 || (includes & 384 /* SymbolFlags.Enum */) !== 0) {
|
|
305
|
-
message =
|
|
305
|
+
message = 728 /* Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations */;
|
|
306
306
|
messageNeedsName = false;
|
|
307
307
|
}
|
|
308
308
|
let multipleDefaultExports = false;
|
|
309
309
|
if (declarationCount(symbol) !== 0) {
|
|
310
310
|
// A default export (by modifier, or `export default` assignment) after another one.
|
|
311
311
|
if (isDefaultExport || (node instanceof ExportAssignment && !node.isExportEquals)) {
|
|
312
|
-
message =
|
|
312
|
+
message = 693 /* Diagnostics.A_module_cannot_have_multiple_default_exports */;
|
|
313
313
|
messageNeedsName = false;
|
|
314
314
|
multipleDefaultExports = true;
|
|
315
315
|
}
|
|
@@ -331,10 +331,10 @@ class Binder extends NodeVisitor {
|
|
|
331
331
|
const decl = getNameOfDeclaration(declaration) ?? declaration;
|
|
332
332
|
const d = this.createDiagnosticForNode(decl, message, messageNeedsName ? [this.getDisplayName(declaration)] : noArgs);
|
|
333
333
|
if (multipleDefaultExports)
|
|
334
|
-
d.addRelatedInfo(this.createDiagnosticForNode(declarationName, index === 0 ?
|
|
334
|
+
d.addRelatedInfo(this.createDiagnosticForNode(declarationName, index === 0 ? 892 /* Diagnostics.Another_export_default_is_here */ : 1368 /* Diagnostics.X_and_here */, noArgs));
|
|
335
335
|
this.addDiagnostic(d);
|
|
336
336
|
if (multipleDefaultExports)
|
|
337
|
-
diagnostic.addRelatedInfo(this.createDiagnosticForNode(decl,
|
|
337
|
+
diagnostic.addRelatedInfo(this.createDiagnosticForNode(decl, 891 /* Diagnostics.The_first_export_default_is_here */, noArgs));
|
|
338
338
|
}
|
|
339
339
|
this.addDiagnostic(diagnostic);
|
|
340
340
|
// An accessor conflicting with a non-accessor or the other accessor kind makes the symbol a
|
|
@@ -352,7 +352,14 @@ class Binder extends NodeVisitor {
|
|
|
352
352
|
if (isAmbientModule(node)) {
|
|
353
353
|
if (isGlobalScopeAugmentation(node))
|
|
354
354
|
return "\uFFFEglobal" /* InternalSymbolName.Global */;
|
|
355
|
-
|
|
355
|
+
const moduleName = nodeText(name);
|
|
356
|
+
// A pattern module with import attributes has its own symbol, named after the attributes node's id: it merges
|
|
357
|
+
// only with pattern modules of the same pattern and identical attributes, which the checker decides. The id
|
|
358
|
+
// is written at a fixed width so that names sort in declaration order.
|
|
359
|
+
const attributes = node.attributes;
|
|
360
|
+
if (attributes !== undefined && hasSingleStar(moduleName))
|
|
361
|
+
return (internalSymbolNamePrefix + '"' + moduleName + '"pattern@' + String(getNodeId(attributes)).padStart(10, '0'));
|
|
362
|
+
return '"' + moduleName + '"';
|
|
356
363
|
}
|
|
357
364
|
if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) {
|
|
358
365
|
// Private names are only allowed in classes; elsewhere there is already a parse error.
|
|
@@ -361,9 +368,9 @@ class Binder extends NodeVisitor {
|
|
|
361
368
|
return "\uFFFEmissing" /* InternalSymbolName.Missing */;
|
|
362
369
|
return getSymbolNameForPrivateIdentifier(getSymbol(containingClass), getText(name));
|
|
363
370
|
}
|
|
364
|
-
if (isPropertyNameLiteral(name) || name.kind ===
|
|
371
|
+
if (isPropertyNameLiteral(name) || name.kind === 297 /* SyntaxKind.JsxNamespacedName */)
|
|
365
372
|
return nodeText(name);
|
|
366
|
-
if (name.kind ===
|
|
373
|
+
if (name.kind === 169 /* SyntaxKind.ComputedPropertyName */) {
|
|
367
374
|
const expression = getExpression(name);
|
|
368
375
|
// A literal computed name is just the literal.
|
|
369
376
|
if (isStringOrNumericLiteralLike(expression))
|
|
@@ -377,20 +384,20 @@ class Binder extends NodeVisitor {
|
|
|
377
384
|
return "\uFFFEmissing" /* InternalSymbolName.Missing */;
|
|
378
385
|
}
|
|
379
386
|
switch (node.kind) {
|
|
380
|
-
case
|
|
387
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
381
388
|
return "\uFFFEconstructor" /* InternalSymbolName.Constructor */;
|
|
382
|
-
case
|
|
383
|
-
case
|
|
389
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
390
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
384
391
|
return "\uFFFEcall" /* InternalSymbolName.Call */;
|
|
385
|
-
case
|
|
386
|
-
case
|
|
392
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
393
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
387
394
|
return "\uFFFEnew" /* InternalSymbolName.New */;
|
|
388
|
-
case
|
|
395
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
389
396
|
return "\uFFFEindex" /* InternalSymbolName.Index */;
|
|
390
|
-
case
|
|
397
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
391
398
|
return "\uFFFEexport" /* InternalSymbolName.ExportStar */;
|
|
392
|
-
case
|
|
393
|
-
case
|
|
399
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
400
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
394
401
|
return "export=" /* InternalSymbolName.ExportEquals */;
|
|
395
402
|
}
|
|
396
403
|
return "\uFFFEmissing" /* InternalSymbolName.Missing */;
|
|
@@ -411,8 +418,8 @@ class Binder extends NodeVisitor {
|
|
|
411
418
|
const container = this.container;
|
|
412
419
|
const hasExportModifier = (getCombinedModifierFlags(node) & 32 /* ModifierFlags.Export */) !== 0 || isImplicitlyExportedJSDocDeclaration(node);
|
|
413
420
|
if ((symbolFlags & 2097152 /* SymbolFlags.Alias */) !== 0) {
|
|
414
|
-
if (node.kind ===
|
|
415
|
-
(node.kind ===
|
|
421
|
+
if (node.kind === 283 /* SyntaxKind.ExportSpecifier */ ||
|
|
422
|
+
(node.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) {
|
|
416
423
|
const containerSymbol = getSymbol(container);
|
|
417
424
|
return this.declareSymbol(getExports(containerSymbol), containerSymbol, node, symbolFlags, symbolExcludes);
|
|
418
425
|
}
|
|
@@ -447,41 +454,41 @@ class Binder extends NodeVisitor {
|
|
|
447
454
|
declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
|
|
448
455
|
const container = this.container;
|
|
449
456
|
switch (container.kind) {
|
|
450
|
-
case
|
|
457
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
451
458
|
return this.declareModuleMember(node, symbolFlags, symbolExcludes);
|
|
452
|
-
case
|
|
459
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
453
460
|
return this.declareSourceFileMember(node, symbolFlags, symbolExcludes);
|
|
454
|
-
case
|
|
455
|
-
case
|
|
461
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
462
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
456
463
|
return this.declareClassMember(node, symbolFlags, symbolExcludes);
|
|
457
|
-
case
|
|
464
|
+
case 268 /* SyntaxKind.EnumDeclaration */: {
|
|
458
465
|
const enumSymbol = getSymbol(container);
|
|
459
466
|
return this.declareSymbol(getExports(enumSymbol), enumSymbol, node, symbolFlags, symbolExcludes);
|
|
460
467
|
}
|
|
461
|
-
case
|
|
462
|
-
case
|
|
463
|
-
case
|
|
464
|
-
case
|
|
468
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
469
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
470
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
471
|
+
case 294 /* SyntaxKind.JsxAttributes */: {
|
|
465
472
|
const containerSymbol = getSymbol(container);
|
|
466
473
|
return this.declareSymbol(getMembers(containerSymbol), containerSymbol, node, symbolFlags, symbolExcludes);
|
|
467
474
|
}
|
|
468
|
-
case
|
|
469
|
-
case
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
case
|
|
473
|
-
case
|
|
474
|
-
case
|
|
475
|
-
case
|
|
476
|
-
case
|
|
477
|
-
case
|
|
478
|
-
case
|
|
479
|
-
case
|
|
480
|
-
case
|
|
481
|
-
case
|
|
482
|
-
case
|
|
483
|
-
case
|
|
484
|
-
case
|
|
475
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
476
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
477
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
478
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
479
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
480
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
481
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
482
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
483
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
484
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
485
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
486
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
487
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
488
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
|
|
489
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
490
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
491
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
485
492
|
return this.declareSymbol(this.localsOf(container), undefined, node, symbolFlags, symbolExcludes);
|
|
486
493
|
}
|
|
487
494
|
throw new Error('Unhandled case in declareSymbolAndAddToSymbolTable');
|
|
@@ -519,9 +526,9 @@ class Binder extends NodeVisitor {
|
|
|
519
526
|
bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
|
|
520
527
|
const blockScopeContainer = this.blockScopeContainer;
|
|
521
528
|
switch (blockScopeContainer.kind) {
|
|
522
|
-
case
|
|
529
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
523
530
|
return this.declareModuleMember(node, symbolFlags, symbolExcludes);
|
|
524
|
-
case
|
|
531
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
525
532
|
if (isExternalOrCommonJSModule(this.file))
|
|
526
533
|
return this.declareModuleMember(node, symbolFlags, symbolExcludes);
|
|
527
534
|
break;
|
|
@@ -564,22 +571,22 @@ class Binder extends NodeVisitor {
|
|
|
564
571
|
if (node instanceof KeywordExpression)
|
|
565
572
|
node.flowNode = this.currentFlowValue();
|
|
566
573
|
break;
|
|
567
|
-
case
|
|
574
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
568
575
|
if (isPartOfTypeQuery(node))
|
|
569
576
|
node.flowNode = this.currentFlowValue();
|
|
570
577
|
break;
|
|
571
|
-
case
|
|
578
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
572
579
|
node.flowNode = this.currentFlowValue();
|
|
573
580
|
break;
|
|
574
581
|
case 80 /* SyntaxKind.PrivateIdentifier */:
|
|
575
582
|
this.checkPrivateIdentifier(node);
|
|
576
583
|
break;
|
|
577
|
-
case
|
|
578
|
-
case
|
|
584
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
585
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
579
586
|
if (isNarrowableReference(node))
|
|
580
587
|
setFlowNode(node, this.currentFlowValue());
|
|
581
588
|
break;
|
|
582
|
-
case
|
|
589
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
583
590
|
switch (getAssignmentDeclarationKind(node)) {
|
|
584
591
|
case 1 /* JSDeclarationKind.ModuleExports */:
|
|
585
592
|
this.bindModuleExportsAssignment(node);
|
|
@@ -596,103 +603,103 @@ class Binder extends NodeVisitor {
|
|
|
596
603
|
}
|
|
597
604
|
this.checkStrictModeBinaryExpression(node);
|
|
598
605
|
break;
|
|
599
|
-
case
|
|
606
|
+
case 301 /* SyntaxKind.CatchClause */:
|
|
600
607
|
this.checkStrictModeCatchClause(node);
|
|
601
608
|
break;
|
|
602
|
-
case
|
|
609
|
+
case 222 /* SyntaxKind.DeleteExpression */:
|
|
603
610
|
this.checkStrictModeDeleteExpression(node);
|
|
604
611
|
break;
|
|
605
|
-
case
|
|
612
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */:
|
|
606
613
|
this.checkStrictModeEvalOrArguments(node, node.operand);
|
|
607
614
|
break;
|
|
608
|
-
case
|
|
615
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */: {
|
|
609
616
|
const operator = node.operator;
|
|
610
617
|
if (operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */)
|
|
611
618
|
this.checkStrictModeEvalOrArguments(node, node.operand);
|
|
612
619
|
break;
|
|
613
620
|
}
|
|
614
|
-
case
|
|
621
|
+
case 256 /* SyntaxKind.WithStatement */:
|
|
615
622
|
this.errorOnFirstToken(node, 70 /* Diagnostics.X_with_statements_are_not_allowed_in_strict_mode */, noArgs);
|
|
616
623
|
break;
|
|
617
|
-
case
|
|
624
|
+
case 258 /* SyntaxKind.LabeledStatement */: {
|
|
618
625
|
const statement = node.statement;
|
|
619
|
-
if (isDeclarationStatementKind(statement.kind) || statement.kind ===
|
|
626
|
+
if (isDeclarationStatementKind(statement.kind) || statement.kind === 245 /* SyntaxKind.VariableStatement */)
|
|
620
627
|
this.errorOnFirstToken(node.label, 278 /* Diagnostics.A_label_is_not_allowed_here */, noArgs);
|
|
621
628
|
break;
|
|
622
629
|
}
|
|
623
|
-
case
|
|
630
|
+
case 199 /* SyntaxKind.ThisType */:
|
|
624
631
|
this.seenThisKeyword = true;
|
|
625
632
|
break;
|
|
626
|
-
case
|
|
633
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
627
634
|
this.bindTypeParameter(node);
|
|
628
635
|
break;
|
|
629
|
-
case
|
|
636
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
630
637
|
this.bindParameter(node);
|
|
631
638
|
break;
|
|
632
|
-
case
|
|
639
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
633
640
|
this.bindVariableDeclarationOrBindingElement(node);
|
|
634
641
|
break;
|
|
635
|
-
case
|
|
642
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
636
643
|
node.flowNode = this.currentFlowValue();
|
|
637
644
|
this.bindVariableDeclarationOrBindingElement(node);
|
|
638
645
|
break;
|
|
639
|
-
case
|
|
640
|
-
case
|
|
646
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
647
|
+
case 173 /* SyntaxKind.PropertySignature */: {
|
|
641
648
|
const isAutoAccessor = isAutoAccessorPropertyDeclaration(node);
|
|
642
649
|
this.bindPropertyOrMethodOrAccessor(node, (isAutoAccessor ? 98304 /* SymbolFlags.Accessor */ : 4 /* SymbolFlags.Property */) | optionalSymbolFlag(node), isAutoAccessor ? 111547 /* SymbolFlags.AccessorExcludes */ : 13243 /* SymbolFlags.PropertyExcludes */);
|
|
643
650
|
break;
|
|
644
651
|
}
|
|
645
|
-
case
|
|
646
|
-
case
|
|
652
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
653
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
647
654
|
this.bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 13243 /* SymbolFlags.PropertyExcludes */);
|
|
648
655
|
break;
|
|
649
|
-
case
|
|
656
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
650
657
|
this.bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */);
|
|
651
658
|
break;
|
|
652
|
-
case
|
|
653
|
-
case
|
|
654
|
-
case
|
|
659
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
660
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
661
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
655
662
|
this.declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */);
|
|
656
663
|
break;
|
|
657
|
-
case
|
|
658
|
-
case
|
|
664
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
665
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
659
666
|
this.bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | optionalSymbolFlag(node), isObjectLiteralMethod(node) ? 111551 /* SymbolFlags.Value */ : 103359 /* SymbolFlags.MethodExcludes */);
|
|
660
667
|
break;
|
|
661
|
-
case
|
|
668
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
662
669
|
this.bindFunctionDeclaration(node);
|
|
663
670
|
break;
|
|
664
|
-
case
|
|
671
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
665
672
|
this.declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, 0 /* SymbolFlags.None */);
|
|
666
673
|
break;
|
|
667
|
-
case
|
|
674
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
668
675
|
this.bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46011 /* SymbolFlags.GetAccessorExcludes */);
|
|
669
676
|
break;
|
|
670
|
-
case
|
|
677
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
671
678
|
this.bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78779 /* SymbolFlags.SetAccessorExcludes */);
|
|
672
679
|
break;
|
|
673
|
-
case
|
|
674
|
-
case
|
|
680
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
681
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
675
682
|
this.bindFunctionOrConstructorType(node);
|
|
676
683
|
break;
|
|
677
|
-
case
|
|
678
|
-
case
|
|
684
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
685
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
679
686
|
this.bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "\uFFFEtype" /* InternalSymbolName.Type */);
|
|
680
687
|
break;
|
|
681
|
-
case
|
|
688
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
682
689
|
this.bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "\uFFFEobject" /* InternalSymbolName.Object */);
|
|
683
690
|
break;
|
|
684
|
-
case
|
|
685
|
-
case
|
|
691
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
692
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
686
693
|
this.bindFunctionExpression(node);
|
|
687
694
|
break;
|
|
688
|
-
case
|
|
689
|
-
case
|
|
695
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
696
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
690
697
|
this.bindClassLikeDeclaration(node);
|
|
691
698
|
break;
|
|
692
|
-
case
|
|
699
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
693
700
|
this.bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */);
|
|
694
701
|
break;
|
|
695
|
-
case
|
|
702
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
696
703
|
switch (getAssignmentDeclarationKind(node)) {
|
|
697
704
|
case 5 /* JSDeclarationKind.ObjectDefinePropertyValue */:
|
|
698
705
|
this.bindExpandoPropertyAssignment(node);
|
|
@@ -705,55 +712,55 @@ class Binder extends NodeVisitor {
|
|
|
705
712
|
if (isInJSFile(node) && this.file.commonJSModuleIndicator === undefined && isRequireCall(node, false))
|
|
706
713
|
this.setCommonJSModuleIndicator(node);
|
|
707
714
|
break;
|
|
708
|
-
case
|
|
715
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
709
716
|
this.bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
|
|
710
717
|
break;
|
|
711
|
-
case
|
|
718
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
712
719
|
// Top-level ones are bound by bindContainer, after CommonJS module indicators.
|
|
713
|
-
if (this.blockScopeContainer.kind !==
|
|
720
|
+
if (this.blockScopeContainer.kind !== 308 /* SyntaxKind.SourceFile */)
|
|
714
721
|
this.bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
|
|
715
722
|
break;
|
|
716
|
-
case
|
|
723
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
717
724
|
if (isEnumConst(node))
|
|
718
725
|
this.bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */);
|
|
719
726
|
else
|
|
720
727
|
this.bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */);
|
|
721
728
|
break;
|
|
722
|
-
case
|
|
729
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
723
730
|
this.bindModuleDeclaration(node);
|
|
724
731
|
break;
|
|
725
|
-
case
|
|
726
|
-
case
|
|
727
|
-
case
|
|
728
|
-
case
|
|
732
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
733
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
734
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
735
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
729
736
|
this.declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
730
737
|
break;
|
|
731
|
-
case
|
|
738
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
732
739
|
this.bindNamespaceExportDeclaration(node);
|
|
733
740
|
break;
|
|
734
|
-
case
|
|
741
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
735
742
|
if (node.name !== undefined)
|
|
736
743
|
this.declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
737
744
|
break;
|
|
738
|
-
case
|
|
745
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
739
746
|
this.bindExportDeclaration(node);
|
|
740
747
|
break;
|
|
741
|
-
case
|
|
748
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
742
749
|
this.bindExportAssignment(node);
|
|
743
750
|
break;
|
|
744
|
-
case
|
|
751
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
745
752
|
this.bindSourceFileIfExternalModule(node);
|
|
746
753
|
break;
|
|
747
|
-
case
|
|
754
|
+
case 294 /* SyntaxKind.JsxAttributes */:
|
|
748
755
|
this.bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "\uFFFEjsxAttributes" /* InternalSymbolName.JSXAttributes */);
|
|
749
756
|
break;
|
|
750
|
-
case
|
|
757
|
+
case 293 /* SyntaxKind.JsxAttribute */:
|
|
751
758
|
this.declareSymbolAndAddToSymbolTable(node, 4 /* SymbolFlags.Property */, 13243 /* SymbolFlags.PropertyExcludes */);
|
|
752
759
|
break;
|
|
753
760
|
}
|
|
754
761
|
// Then bind the children, tracking the current container. Tokens have no children.
|
|
755
762
|
let thisNodeOrAnySubnodesHasError = (node.flags & 32768 /* NodeFlags.ThisNodeHasError */) !== 0;
|
|
756
|
-
if (node.kind >
|
|
763
|
+
if (node.kind > 167 /* SyntaxKind.LastToken */) {
|
|
757
764
|
const saveSeenParseError = this.seenParseError;
|
|
758
765
|
this.seenParseError = false;
|
|
759
766
|
const containerFlags = getContainerFlags(node);
|
|
@@ -806,7 +813,7 @@ class Binder extends NodeVisitor {
|
|
|
806
813
|
}
|
|
807
814
|
else
|
|
808
815
|
this.bindChildren(node);
|
|
809
|
-
if (node.kind ===
|
|
816
|
+
if (node.kind === 308 /* SyntaxKind.SourceFile */)
|
|
810
817
|
this.finishSourceFile(node);
|
|
811
818
|
else if (isAmbientModule(node))
|
|
812
819
|
this.bindCommonJSTypeExports(getSymbol(node));
|
|
@@ -829,7 +836,7 @@ class Binder extends NodeVisitor {
|
|
|
829
836
|
!hasSyntacticModifier(node, 1024 /* ModifierFlags.Async */) &&
|
|
830
837
|
!isGeneratorFunctionExpression(node) &&
|
|
831
838
|
getImmediatelyInvokedFunctionExpression(node) !== undefined) ||
|
|
832
|
-
node.kind ===
|
|
839
|
+
node.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */;
|
|
833
840
|
if (!isImmediatelyInvoked) {
|
|
834
841
|
const flowStart = new FlowNode(2 /* FlowFlags.Start */, undefined, undefined);
|
|
835
842
|
this.currentFlow = flowStart;
|
|
@@ -840,7 +847,7 @@ class Binder extends NodeVisitor {
|
|
|
840
847
|
}
|
|
841
848
|
// IIFEs and constructors get a return graph; constructors use it to check property initialization.
|
|
842
849
|
this.currentReturnTarget =
|
|
843
|
-
isImmediatelyInvoked || node.kind ===
|
|
850
|
+
isImmediatelyInvoked || node.kind === 178 /* SyntaxKind.Constructor */ ? this.createBranchLabel() : undefined;
|
|
844
851
|
this.currentExceptionTarget = undefined;
|
|
845
852
|
this.currentBreakTarget = undefined;
|
|
846
853
|
this.currentContinueTarget = undefined;
|
|
@@ -851,7 +858,7 @@ class Binder extends NodeVisitor {
|
|
|
851
858
|
node.flags &= ~(262912 /* NodeFlags.ReachabilityAndEmitFlags */ | 128 /* NodeFlags.ContainsThis */);
|
|
852
859
|
if ((this.currentFlow.flags & 1 /* FlowFlags.Unreachable */) === 0 &&
|
|
853
860
|
(containerFlags & 8 /* ContainerFlags.IsFunctionLike */) !== 0 &&
|
|
854
|
-
node.kind !==
|
|
861
|
+
node.kind !== 177 /* SyntaxKind.ClassStaticBlockDeclaration */ &&
|
|
855
862
|
nodeIsPresent(getBody(node))) {
|
|
856
863
|
node.flags |= 256 /* NodeFlags.HasImplicitReturn */;
|
|
857
864
|
if (this.hasExplicitReturn)
|
|
@@ -860,15 +867,14 @@ class Binder extends NodeVisitor {
|
|
|
860
867
|
}
|
|
861
868
|
if (this.seenThisKeyword)
|
|
862
869
|
node.flags |= 128 /* NodeFlags.ContainsThis */;
|
|
863
|
-
if (node.kind ===
|
|
870
|
+
if (node.kind === 308 /* SyntaxKind.SourceFile */) {
|
|
864
871
|
node.flags |= this.emitFlags;
|
|
865
|
-
node.endFlowNode = this.currentFlow;
|
|
866
872
|
}
|
|
867
873
|
const returnTarget = this.currentReturnTarget;
|
|
868
874
|
if (returnTarget !== undefined) {
|
|
869
875
|
this.addAntecedent(returnTarget, this.currentFlow);
|
|
870
876
|
this.currentFlow = this.finishFlowLabel(returnTarget);
|
|
871
|
-
if (node.kind ===
|
|
877
|
+
if (node.kind === 178 /* SyntaxKind.Constructor */ || node.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */)
|
|
872
878
|
setReturnFlowNode(node, this.currentFlow);
|
|
873
879
|
}
|
|
874
880
|
if (!isImmediatelyInvoked)
|
|
@@ -888,7 +894,7 @@ class Binder extends NodeVisitor {
|
|
|
888
894
|
if (isInJSFile(file)) {
|
|
889
895
|
// Top-level @typedef aliases wait until CommonJS module indicators are known.
|
|
890
896
|
for (const statement of file.statements.nodes)
|
|
891
|
-
if (statement.kind ===
|
|
897
|
+
if (statement.kind === 346 /* SyntaxKind.JSTypeAliasDeclaration */)
|
|
892
898
|
this.bindBlockScopedDeclaration(statement, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
|
|
893
899
|
if (file.commonJSModuleIndicator !== undefined) {
|
|
894
900
|
this.declareCommonJSVariable('module');
|
|
@@ -932,26 +938,26 @@ class Binder extends NodeVisitor {
|
|
|
932
938
|
this.inAssignmentPattern = saveInAssignmentPattern;
|
|
933
939
|
return;
|
|
934
940
|
}
|
|
935
|
-
if (node.kind >=
|
|
941
|
+
if (node.kind >= 245 /* SyntaxKind.FirstStatement */ && node.kind <= 261 /* SyntaxKind.LastStatement */)
|
|
936
942
|
setFlowNode(node, this.currentFlowValue());
|
|
937
943
|
switch (node.kind) {
|
|
938
|
-
case
|
|
944
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
939
945
|
this.bindWhileStatement(node);
|
|
940
946
|
break;
|
|
941
|
-
case
|
|
947
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
942
948
|
this.bindDoStatement(node);
|
|
943
949
|
break;
|
|
944
|
-
case
|
|
950
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
945
951
|
this.bindForStatement(node);
|
|
946
952
|
break;
|
|
947
|
-
case
|
|
948
|
-
case
|
|
953
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
954
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
949
955
|
this.bindForInOrForOfStatement(node);
|
|
950
956
|
break;
|
|
951
|
-
case
|
|
957
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
952
958
|
this.bindIfStatement(node);
|
|
953
959
|
break;
|
|
954
|
-
case
|
|
960
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
955
961
|
this.bindOptional(getExpression(node));
|
|
956
962
|
if (this.currentReturnTarget !== undefined)
|
|
957
963
|
this.addAntecedent(this.currentReturnTarget, this.currentFlow);
|
|
@@ -959,50 +965,50 @@ class Binder extends NodeVisitor {
|
|
|
959
965
|
this.hasExplicitReturn = true;
|
|
960
966
|
this.hasFlowEffects = true;
|
|
961
967
|
break;
|
|
962
|
-
case
|
|
968
|
+
case 259 /* SyntaxKind.ThrowStatement */:
|
|
963
969
|
this.bindOptional(getExpression(node));
|
|
964
970
|
this.currentFlow = this.unreachableFlow;
|
|
965
971
|
this.hasFlowEffects = true;
|
|
966
972
|
break;
|
|
967
|
-
case
|
|
973
|
+
case 254 /* SyntaxKind.BreakStatement */:
|
|
968
974
|
this.bindBreakOrContinueStatement(getLabel(node), true);
|
|
969
975
|
break;
|
|
970
|
-
case
|
|
976
|
+
case 253 /* SyntaxKind.ContinueStatement */:
|
|
971
977
|
this.bindBreakOrContinueStatement(getLabel(node), false);
|
|
972
978
|
break;
|
|
973
|
-
case
|
|
979
|
+
case 260 /* SyntaxKind.TryStatement */:
|
|
974
980
|
this.bindTryStatement(node);
|
|
975
981
|
break;
|
|
976
|
-
case
|
|
982
|
+
case 257 /* SyntaxKind.SwitchStatement */:
|
|
977
983
|
this.bindSwitchStatement(node);
|
|
978
984
|
break;
|
|
979
|
-
case
|
|
985
|
+
case 271 /* SyntaxKind.CaseBlock */:
|
|
980
986
|
this.bindCaseBlock(node);
|
|
981
987
|
break;
|
|
982
|
-
case
|
|
983
|
-
case
|
|
988
|
+
case 298 /* SyntaxKind.CaseClause */:
|
|
989
|
+
case 299 /* SyntaxKind.DefaultClause */:
|
|
984
990
|
this.bindCaseOrDefaultClause(node);
|
|
985
991
|
break;
|
|
986
|
-
case
|
|
992
|
+
case 246 /* SyntaxKind.ExpressionStatement */: {
|
|
987
993
|
const expression = node.expression;
|
|
988
994
|
this.bind(expression);
|
|
989
995
|
this.maybeBindExpressionFlowIfCall(expression);
|
|
990
996
|
break;
|
|
991
997
|
}
|
|
992
|
-
case
|
|
998
|
+
case 258 /* SyntaxKind.LabeledStatement */:
|
|
993
999
|
this.bindLabeledStatement(node);
|
|
994
1000
|
break;
|
|
995
|
-
case
|
|
1001
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */:
|
|
996
1002
|
this.bindPrefixUnaryExpressionFlow(node);
|
|
997
1003
|
break;
|
|
998
|
-
case
|
|
1004
|
+
case 227 /* SyntaxKind.PostfixUnaryExpression */: {
|
|
999
1005
|
node.forEachChild(this);
|
|
1000
1006
|
const operator = node.operator;
|
|
1001
1007
|
if (operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */)
|
|
1002
1008
|
this.bindAssignmentTargetFlow(node.operand);
|
|
1003
1009
|
break;
|
|
1004
1010
|
}
|
|
1005
|
-
case
|
|
1011
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
1006
1012
|
if (isDestructuringAssignment(node)) {
|
|
1007
1013
|
// Carry the assignment pattern state into initializers of the pattern.
|
|
1008
1014
|
this.inAssignmentPattern = saveInAssignmentPattern;
|
|
@@ -1011,40 +1017,40 @@ class Binder extends NodeVisitor {
|
|
|
1011
1017
|
}
|
|
1012
1018
|
this.bindBinaryExpressionFlow(node);
|
|
1013
1019
|
break;
|
|
1014
|
-
case
|
|
1020
|
+
case 222 /* SyntaxKind.DeleteExpression */:
|
|
1015
1021
|
node.forEachChild(this);
|
|
1016
|
-
if (node.expression.kind ===
|
|
1022
|
+
if (node.expression.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
1017
1023
|
this.bindAssignmentTargetFlow(node.expression);
|
|
1018
1024
|
break;
|
|
1019
|
-
case
|
|
1025
|
+
case 229 /* SyntaxKind.ConditionalExpression */:
|
|
1020
1026
|
this.bindConditionalExpressionFlow(node);
|
|
1021
1027
|
break;
|
|
1022
|
-
case
|
|
1028
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
1023
1029
|
node.forEachChild(this);
|
|
1024
1030
|
if (node.initializer !== undefined ||
|
|
1025
1031
|
isForInOrOfStatementKind(node.parent.parent.kind))
|
|
1026
1032
|
this.bindInitializedVariableFlow(node);
|
|
1027
1033
|
break;
|
|
1028
|
-
case
|
|
1029
|
-
case
|
|
1030
|
-
case
|
|
1034
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
1035
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
1036
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
1031
1037
|
if (isOptionalChain(node))
|
|
1032
1038
|
this.bindOptionalChainFlow(node);
|
|
1033
1039
|
else
|
|
1034
1040
|
node.forEachChild(this);
|
|
1035
1041
|
break;
|
|
1036
|
-
case
|
|
1042
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
1037
1043
|
this.bindCallExpressionFlow(node);
|
|
1038
1044
|
break;
|
|
1039
|
-
case
|
|
1045
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
1040
1046
|
this.bindEachStatementFunctionsFirst(node.statements);
|
|
1041
1047
|
this.bind(node.endOfFileToken);
|
|
1042
1048
|
break;
|
|
1043
|
-
case
|
|
1044
|
-
case
|
|
1049
|
+
case 243 /* SyntaxKind.Block */:
|
|
1050
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
1045
1051
|
this.bindEachStatementFunctionsFirst(getStatements(node));
|
|
1046
1052
|
break;
|
|
1047
|
-
case
|
|
1053
|
+
case 210 /* SyntaxKind.BindingElement */: {
|
|
1048
1054
|
// The initializer runs before the binding pattern.
|
|
1049
1055
|
const element = node;
|
|
1050
1056
|
this.bindOptional(element.dotDotDotToken);
|
|
@@ -1053,7 +1059,7 @@ class Binder extends NodeVisitor {
|
|
|
1053
1059
|
this.bindOptional(element.name);
|
|
1054
1060
|
break;
|
|
1055
1061
|
}
|
|
1056
|
-
case
|
|
1062
|
+
case 171 /* SyntaxKind.Parameter */: {
|
|
1057
1063
|
const parameter = node;
|
|
1058
1064
|
this.bindNodes(parameter.modifiers);
|
|
1059
1065
|
this.bindOptional(parameter.dotDotDotToken);
|
|
@@ -1063,10 +1069,10 @@ class Binder extends NodeVisitor {
|
|
|
1063
1069
|
this.bind(parameter.name);
|
|
1064
1070
|
break;
|
|
1065
1071
|
}
|
|
1066
|
-
case
|
|
1067
|
-
case
|
|
1068
|
-
case
|
|
1069
|
-
case
|
|
1072
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
1073
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
1074
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
1075
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
1070
1076
|
this.inAssignmentPattern = saveInAssignmentPattern;
|
|
1071
1077
|
node.forEachChild(this);
|
|
1072
1078
|
break;
|
|
@@ -1085,10 +1091,10 @@ class Binder extends NodeVisitor {
|
|
|
1085
1091
|
bindEachStatementFunctionsFirst(statements) {
|
|
1086
1092
|
const nodes = statements.nodes;
|
|
1087
1093
|
for (let i = 0; i < nodes.length; i++)
|
|
1088
|
-
if (nodes[i].kind ===
|
|
1094
|
+
if (nodes[i].kind === 264 /* SyntaxKind.FunctionDeclaration */)
|
|
1089
1095
|
this.bind(nodes[i]);
|
|
1090
1096
|
for (let i = 0; i < nodes.length; i++)
|
|
1091
|
-
if (nodes[i].kind !==
|
|
1097
|
+
if (nodes[i].kind !== 264 /* SyntaxKind.FunctionDeclaration */)
|
|
1092
1098
|
this.bind(nodes[i]);
|
|
1093
1099
|
}
|
|
1094
1100
|
// Flow graph
|
|
@@ -1156,7 +1162,7 @@ class Binder extends NodeVisitor {
|
|
|
1156
1162
|
setContinueTarget(node, target) {
|
|
1157
1163
|
let label = this.activeLabelList;
|
|
1158
1164
|
let current = node;
|
|
1159
|
-
while (label !== undefined && current.parent.kind ===
|
|
1165
|
+
while (label !== undefined && current.parent.kind === 258 /* SyntaxKind.LabeledStatement */) {
|
|
1160
1166
|
label.continueTarget = target;
|
|
1161
1167
|
label = label.next;
|
|
1162
1168
|
current = current.parent;
|
|
@@ -1194,24 +1200,24 @@ class Binder extends NodeVisitor {
|
|
|
1194
1200
|
}
|
|
1195
1201
|
bindAssignmentTargetFlow(node) {
|
|
1196
1202
|
switch (node.kind) {
|
|
1197
|
-
case
|
|
1203
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
1198
1204
|
for (const element of getElements(node).nodes) {
|
|
1199
|
-
if (element.kind ===
|
|
1205
|
+
if (element.kind === 232 /* SyntaxKind.SpreadElement */)
|
|
1200
1206
|
this.bindAssignmentTargetFlow(getExpression(element));
|
|
1201
1207
|
else
|
|
1202
1208
|
this.bindDestructuringTargetFlow(element);
|
|
1203
1209
|
}
|
|
1204
1210
|
break;
|
|
1205
|
-
case
|
|
1211
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
1206
1212
|
for (const property of getProperties(node).nodes) {
|
|
1207
1213
|
switch (property.kind) {
|
|
1208
|
-
case
|
|
1214
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
1209
1215
|
this.bindDestructuringTargetFlow(getInitializer(property));
|
|
1210
1216
|
break;
|
|
1211
|
-
case
|
|
1217
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
1212
1218
|
this.bindAssignmentTargetFlow(getName(property));
|
|
1213
1219
|
break;
|
|
1214
|
-
case
|
|
1220
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
1215
1221
|
this.bindAssignmentTargetFlow(getExpression(property));
|
|
1216
1222
|
break;
|
|
1217
1223
|
}
|
|
@@ -1253,11 +1259,19 @@ class Binder extends NodeVisitor {
|
|
|
1253
1259
|
this.currentFlow = this.finishFlowLabel(postDoLabel);
|
|
1254
1260
|
}
|
|
1255
1261
|
bindForStatement(node) {
|
|
1262
|
+
this.bindOptional(node.initializer);
|
|
1263
|
+
if (this.currentFlow === this.unreachableFlow) {
|
|
1264
|
+
// An initializer that ends the flow (a throwing IIFE) would leave the loop label only the
|
|
1265
|
+
// incrementor's back edge: a cycle with no entry. Bind the rest as unreachable.
|
|
1266
|
+
this.bindOptional(node.condition);
|
|
1267
|
+
this.bind(node.statement);
|
|
1268
|
+
this.bindOptional(node.incrementor);
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1256
1271
|
const preLoopLabel = this.setContinueTarget(node, this.createLoopLabel());
|
|
1257
1272
|
const preBodyLabel = this.createBranchLabel();
|
|
1258
1273
|
const preIncrementorLabel = this.createBranchLabel();
|
|
1259
1274
|
const postLoopLabel = this.createBranchLabel();
|
|
1260
|
-
this.bindOptional(node.initializer);
|
|
1261
1275
|
this.addAntecedent(preLoopLabel, this.currentFlow);
|
|
1262
1276
|
this.currentFlow = preLoopLabel;
|
|
1263
1277
|
this.bindCondition(node.condition, preBodyLabel, postLoopLabel);
|
|
@@ -1270,16 +1284,22 @@ class Binder extends NodeVisitor {
|
|
|
1270
1284
|
this.currentFlow = this.finishFlowLabel(postLoopLabel);
|
|
1271
1285
|
}
|
|
1272
1286
|
bindForInOrForOfStatement(node) {
|
|
1287
|
+
this.bind(node.expression);
|
|
1288
|
+
if (this.currentFlow === this.unreachableFlow) {
|
|
1289
|
+
// As for a `for` initializer: an expression that ends the flow leaves the loop unreachable.
|
|
1290
|
+
this.bind(node.initializer);
|
|
1291
|
+
this.bind(node.statement);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1273
1294
|
const preLoopLabel = this.setContinueTarget(node, this.createLoopLabel());
|
|
1274
1295
|
const postLoopLabel = this.createBranchLabel();
|
|
1275
|
-
this.bind(node.expression);
|
|
1276
1296
|
this.addAntecedent(preLoopLabel, this.currentFlow);
|
|
1277
1297
|
this.currentFlow = preLoopLabel;
|
|
1278
|
-
if (node.kind ===
|
|
1298
|
+
if (node.kind === 252 /* SyntaxKind.ForOfStatement */)
|
|
1279
1299
|
this.bindOptional(node.awaitModifier);
|
|
1280
1300
|
this.addAntecedent(postLoopLabel, this.currentFlow);
|
|
1281
1301
|
this.bind(node.initializer);
|
|
1282
|
-
if (node.initializer.kind !==
|
|
1302
|
+
if (node.initializer.kind !== 263 /* SyntaxKind.VariableDeclarationList */)
|
|
1283
1303
|
this.bindAssignmentTargetFlow(node.initializer);
|
|
1284
1304
|
this.bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
|
|
1285
1305
|
this.addAntecedent(preLoopLabel, this.currentFlow);
|
|
@@ -1388,7 +1408,7 @@ class Binder extends NodeVisitor {
|
|
|
1388
1408
|
this.addAntecedent(postSwitchLabel, this.currentFlow);
|
|
1389
1409
|
let hasDefault = false;
|
|
1390
1410
|
for (const clause of node.caseBlock.clauses.nodes)
|
|
1391
|
-
if (clause.kind ===
|
|
1411
|
+
if (clause.kind === 299 /* SyntaxKind.DefaultClause */)
|
|
1392
1412
|
hasDefault = true;
|
|
1393
1413
|
if (!hasDefault)
|
|
1394
1414
|
this.addAntecedent(postSwitchLabel, this.createFlowSwitchClause(this.preSwitchCaseFlow, node, 0, 0));
|
|
@@ -1562,7 +1582,7 @@ class Binder extends NodeVisitor {
|
|
|
1562
1582
|
bindInitializedVariableFlow(node) {
|
|
1563
1583
|
const name = getName(node);
|
|
1564
1584
|
if (name !== undefined &&
|
|
1565
|
-
(name.kind ===
|
|
1585
|
+
(name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)) {
|
|
1566
1586
|
for (const element of getElements(name).nodes)
|
|
1567
1587
|
this.bindInitializedVariableFlow(element);
|
|
1568
1588
|
}
|
|
@@ -1630,7 +1650,7 @@ class Binder extends NodeVisitor {
|
|
|
1630
1650
|
else {
|
|
1631
1651
|
// An IIFE's flow node includes the evaluation of its arguments.
|
|
1632
1652
|
const callee = skipParentheses(node.expression);
|
|
1633
|
-
if (callee.kind ===
|
|
1653
|
+
if (callee.kind === 220 /* SyntaxKind.FunctionExpression */ || callee.kind === 221 /* SyntaxKind.ArrowFunction */) {
|
|
1634
1654
|
this.bindNodes(callTypeArguments(node));
|
|
1635
1655
|
this.bindNodes(node.arguments);
|
|
1636
1656
|
this.bind(node.expression);
|
|
@@ -1684,7 +1704,7 @@ class Binder extends NodeVisitor {
|
|
|
1684
1704
|
this.setExportContextFlag(node);
|
|
1685
1705
|
if (isAmbientModule(node)) {
|
|
1686
1706
|
if (hasSyntacticModifier(node, 32 /* ModifierFlags.Export */))
|
|
1687
|
-
this.errorOnFirstToken(node,
|
|
1707
|
+
this.errorOnFirstToken(node, 809 /* Diagnostics.X_export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible */, noArgs);
|
|
1688
1708
|
if (isModuleAugmentationExternal(node)) {
|
|
1689
1709
|
this.declareModuleSymbol(node);
|
|
1690
1710
|
return;
|
|
@@ -1695,9 +1715,11 @@ class Binder extends NodeVisitor {
|
|
|
1695
1715
|
const text = getText(name);
|
|
1696
1716
|
const starIndex = text.indexOf('*');
|
|
1697
1717
|
if (starIndex >= 0 && text.indexOf('*', starIndex + 1) >= 0)
|
|
1698
|
-
this.errorOnFirstToken(name,
|
|
1718
|
+
this.errorOnFirstToken(name, 1143 /* Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character */, [text]);
|
|
1699
1719
|
else if (starIndex >= 0)
|
|
1700
1720
|
this.file.patternAmbientModules = appendToList(this.file.patternAmbientModules, new PatternAmbientModule(text, starIndex, symbol));
|
|
1721
|
+
else if (node.attributes !== undefined)
|
|
1722
|
+
this.errorOnNode(name, 463 /* Diagnostics.An_ambient_module_declaration_with_import_attributes_must_use_a_pattern_name_with_an_Asterisk_character */, noArgs);
|
|
1701
1723
|
}
|
|
1702
1724
|
return;
|
|
1703
1725
|
}
|
|
@@ -1726,7 +1748,7 @@ class Binder extends NodeVisitor {
|
|
|
1726
1748
|
const parent = node.parent;
|
|
1727
1749
|
if (getModifiers(node) !== undefined)
|
|
1728
1750
|
this.errorOnNode(node, 140 /* Diagnostics.Modifiers_cannot_appear_here */, noArgs);
|
|
1729
|
-
if (parent.kind !==
|
|
1751
|
+
if (parent.kind !== 308 /* SyntaxKind.SourceFile */)
|
|
1730
1752
|
this.errorOnNode(node, 252 /* Diagnostics.Global_module_exports_may_only_appear_at_top_level */, noArgs);
|
|
1731
1753
|
else if (!isExternalModule(parent))
|
|
1732
1754
|
this.errorOnNode(node, 250 /* Diagnostics.Global_module_exports_may_only_appear_in_module_files */, noArgs);
|
|
@@ -1750,7 +1772,7 @@ class Binder extends NodeVisitor {
|
|
|
1750
1772
|
else if (node.exportClause === undefined)
|
|
1751
1773
|
// All `export *` declarations go in one symbol.
|
|
1752
1774
|
this.declareSymbol(getExports(containerSymbol), containerSymbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */);
|
|
1753
|
-
else if (node.exportClause.kind ===
|
|
1775
|
+
else if (node.exportClause.kind === 282 /* SyntaxKind.NamespaceExport */)
|
|
1754
1776
|
this.declareSymbol(getExports(containerSymbol), containerSymbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
1755
1777
|
}
|
|
1756
1778
|
bindExportAssignment(node) {
|
|
@@ -1794,7 +1816,7 @@ class Binder extends NodeVisitor {
|
|
|
1794
1816
|
this.bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName);
|
|
1795
1817
|
}
|
|
1796
1818
|
bindClassLikeDeclaration(node) {
|
|
1797
|
-
if (node.kind ===
|
|
1819
|
+
if (node.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
1798
1820
|
this.bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */);
|
|
1799
1821
|
else {
|
|
1800
1822
|
const name = getName(node);
|
|
@@ -1807,7 +1829,7 @@ class Binder extends NodeVisitor {
|
|
|
1807
1829
|
const exports = getExports(symbol);
|
|
1808
1830
|
const existing = exports.get('prototype');
|
|
1809
1831
|
if (existing !== undefined)
|
|
1810
|
-
this.errorOnNode(existing.declaration,
|
|
1832
|
+
this.errorOnNode(existing.declaration, 485 /* Diagnostics.Duplicate_identifier_0 */, ['prototype']);
|
|
1811
1833
|
exports.set('prototype', prototypeSymbol);
|
|
1812
1834
|
prototypeSymbol.parent = symbol;
|
|
1813
1835
|
}
|
|
@@ -1833,8 +1855,8 @@ class Binder extends NodeVisitor {
|
|
|
1833
1855
|
const name = getName(node);
|
|
1834
1856
|
this.checkStrictModeEvalOrArguments(node, name);
|
|
1835
1857
|
if (name === undefined ||
|
|
1836
|
-
name.kind ===
|
|
1837
|
-
name.kind ===
|
|
1858
|
+
name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ ||
|
|
1859
|
+
name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)
|
|
1838
1860
|
return;
|
|
1839
1861
|
if (isVariableDeclarationInitializedToRequire(node))
|
|
1840
1862
|
this.declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
|
|
@@ -1851,7 +1873,7 @@ class Binder extends NodeVisitor {
|
|
|
1851
1873
|
if ((node.flags & 8388608 /* NodeFlags.Ambient */) === 0)
|
|
1852
1874
|
this.checkStrictModeEvalOrArguments(node, node.name);
|
|
1853
1875
|
const name = node.name;
|
|
1854
|
-
if (name.kind ===
|
|
1876
|
+
if (name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */) {
|
|
1855
1877
|
const index = getParameters(node.parent).nodes.indexOf(node);
|
|
1856
1878
|
this.bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, '__' + index);
|
|
1857
1879
|
}
|
|
@@ -1866,7 +1888,7 @@ class Binder extends NodeVisitor {
|
|
|
1866
1888
|
}
|
|
1867
1889
|
bindTypeParameter(node) {
|
|
1868
1890
|
const parent = node.parent;
|
|
1869
|
-
if (parent.kind !==
|
|
1891
|
+
if (parent.kind !== 197 /* SyntaxKind.InferType */) {
|
|
1870
1892
|
this.declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */);
|
|
1871
1893
|
return;
|
|
1872
1894
|
}
|
|
@@ -1874,7 +1896,7 @@ class Binder extends NodeVisitor {
|
|
|
1874
1896
|
let container;
|
|
1875
1897
|
for (let current = parent; current !== undefined; current = current.parent) {
|
|
1876
1898
|
const p = current.parent;
|
|
1877
|
-
if (p !== undefined && p.kind ===
|
|
1899
|
+
if (p !== undefined && p.kind === 196 /* SyntaxKind.ConditionalType */ && getExtendsType(p) === current) {
|
|
1878
1900
|
container = p;
|
|
1879
1901
|
break;
|
|
1880
1902
|
}
|
|
@@ -1990,8 +2012,8 @@ class Binder extends NodeVisitor {
|
|
|
1990
2012
|
else
|
|
1991
2013
|
this.declareSymbolEx(symbolTable, classSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, true, false);
|
|
1992
2014
|
}
|
|
1993
|
-
else if (thisContainer.kind !==
|
|
1994
|
-
thisContainer.kind !==
|
|
2015
|
+
else if (thisContainer.kind !== 264 /* SyntaxKind.FunctionDeclaration */ &&
|
|
2016
|
+
thisContainer.kind !== 220 /* SyntaxKind.FunctionExpression */)
|
|
1995
2017
|
throw new Error('Unhandled case in bindThisPropertyAssignment');
|
|
1996
2018
|
}
|
|
1997
2019
|
/** For `this.x` in a class member, the class's members, or exports if the member is static. */
|
|
@@ -2000,12 +2022,12 @@ class Binder extends NodeVisitor {
|
|
|
2000
2022
|
if (thisContainer === undefined)
|
|
2001
2023
|
return undefined;
|
|
2002
2024
|
switch (thisContainer.kind) {
|
|
2003
|
-
case
|
|
2004
|
-
case
|
|
2005
|
-
case
|
|
2006
|
-
case
|
|
2007
|
-
case
|
|
2008
|
-
case
|
|
2025
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
2026
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
2027
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
2028
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
2029
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
2030
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */: {
|
|
2009
2031
|
const classSymbol = getSymbol(thisContainer.parent);
|
|
2010
2032
|
return isStatic(thisContainer) ? getExports(classSymbol) : getMembers(classSymbol);
|
|
2011
2033
|
}
|
|
@@ -2066,7 +2088,7 @@ class Binder extends NodeVisitor {
|
|
|
2066
2088
|
}
|
|
2067
2089
|
checkPrivateIdentifier(node) {
|
|
2068
2090
|
if (getText(node) === '#constructor' && this.file.diagnostics.length === 0)
|
|
2069
|
-
this.errorOnNode(node,
|
|
2091
|
+
this.errorOnNode(node, 1854 /* Diagnostics.X_constructor_is_a_reserved_word */, [declarationNameToString(this.file, node)]);
|
|
2070
2092
|
}
|
|
2071
2093
|
getStrictModeIdentifierMessage(node) {
|
|
2072
2094
|
if (getContainingClass(node) !== undefined)
|
|
@@ -2125,21 +2147,21 @@ function isGeneratorFunctionExpression(node) {
|
|
|
2125
2147
|
return node instanceof FunctionExpression && node.asteriskToken !== undefined;
|
|
2126
2148
|
}
|
|
2127
2149
|
function isForInOrOfStatementKind(kind) {
|
|
2128
|
-
return kind ===
|
|
2150
|
+
return kind === 251 /* SyntaxKind.ForInStatement */ || kind === 252 /* SyntaxKind.ForOfStatement */;
|
|
2129
2151
|
}
|
|
2130
2152
|
function hasExportDeclarations(node) {
|
|
2131
2153
|
let statements;
|
|
2132
|
-
if (node.kind ===
|
|
2154
|
+
if (node.kind === 308 /* SyntaxKind.SourceFile */)
|
|
2133
2155
|
statements = node.statements;
|
|
2134
2156
|
else if (node instanceof ModuleDeclaration) {
|
|
2135
2157
|
const body = node.body;
|
|
2136
|
-
if (body !== undefined && body.kind ===
|
|
2158
|
+
if (body !== undefined && body.kind === 270 /* SyntaxKind.ModuleBlock */)
|
|
2137
2159
|
statements = getStatements(body);
|
|
2138
2160
|
}
|
|
2139
2161
|
if (statements === undefined)
|
|
2140
2162
|
return false;
|
|
2141
2163
|
for (const statement of statements.nodes)
|
|
2142
|
-
if (statement.kind ===
|
|
2164
|
+
if (statement.kind === 280 /* SyntaxKind.ExportDeclaration */ || statement.kind === 279 /* SyntaxKind.ExportAssignment */)
|
|
2143
2165
|
return true;
|
|
2144
2166
|
return false;
|
|
2145
2167
|
}
|
|
@@ -2168,8 +2190,8 @@ function getInitializerSymbol(symbol) {
|
|
|
2168
2190
|
const declaration = symbol.valueDeclaration;
|
|
2169
2191
|
if (declaration === undefined)
|
|
2170
2192
|
return undefined;
|
|
2171
|
-
if (declaration.kind ===
|
|
2172
|
-
(isInJSFile(declaration) && declaration.kind ===
|
|
2193
|
+
if (declaration.kind === 264 /* SyntaxKind.FunctionDeclaration */ ||
|
|
2194
|
+
(isInJSFile(declaration) && declaration.kind === 265 /* SyntaxKind.ClassDeclaration */))
|
|
2173
2195
|
return symbol;
|
|
2174
2196
|
if (declaration instanceof VariableDeclaration) {
|
|
2175
2197
|
if ((declaration.parent.flags & 2 /* NodeFlags.Const */) !== 0 || isInJSFile(declaration)) {
|
|
@@ -2198,13 +2220,13 @@ function combineFlowLists(head, tail) {
|
|
|
2198
2220
|
function isStatementCondition(node) {
|
|
2199
2221
|
const parent = node.parent;
|
|
2200
2222
|
switch (parent.kind) {
|
|
2201
|
-
case
|
|
2202
|
-
case
|
|
2203
|
-
case
|
|
2223
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
2224
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
2225
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
2204
2226
|
return getExpression(parent) === node;
|
|
2205
|
-
case
|
|
2227
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
2206
2228
|
return parent.condition === node;
|
|
2207
|
-
case
|
|
2229
|
+
case 229 /* SyntaxKind.ConditionalExpression */:
|
|
2208
2230
|
return parent.condition === node;
|
|
2209
2231
|
}
|
|
2210
2232
|
return false;
|
|
@@ -2213,7 +2235,7 @@ function isTopLevelLogicalExpression(node) {
|
|
|
2213
2235
|
let current = node;
|
|
2214
2236
|
for (;;) {
|
|
2215
2237
|
const parent = current.parent;
|
|
2216
|
-
if (parent.kind ===
|
|
2238
|
+
if (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */ ||
|
|
2217
2239
|
(parent instanceof PrefixUnaryExpression &&
|
|
2218
2240
|
parent.operator === 53 /* SyntaxKind.ExclamationToken */))
|
|
2219
2241
|
current = parent;
|
|
@@ -2231,18 +2253,18 @@ function isNarrowingExpression(expression) {
|
|
|
2231
2253
|
case 79 /* SyntaxKind.Identifier */:
|
|
2232
2254
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
2233
2255
|
return true;
|
|
2234
|
-
case
|
|
2235
|
-
case
|
|
2256
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
2257
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
2236
2258
|
return containsNarrowableReference(expression);
|
|
2237
|
-
case
|
|
2259
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
2238
2260
|
return hasNarrowableArgument(expression);
|
|
2239
|
-
case
|
|
2240
|
-
case
|
|
2241
|
-
case
|
|
2261
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
2262
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
2263
|
+
case 223 /* SyntaxKind.TypeOfExpression */:
|
|
2242
2264
|
return isNarrowingExpression(getExpression(expression));
|
|
2243
|
-
case
|
|
2265
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
2244
2266
|
return isNarrowingBinaryExpression(expression);
|
|
2245
|
-
case
|
|
2267
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */: {
|
|
2246
2268
|
const unary = expression;
|
|
2247
2269
|
return unary.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(unary.operand);
|
|
2248
2270
|
}
|
|
@@ -2254,10 +2276,10 @@ function containsNarrowableReference(expression) {
|
|
|
2254
2276
|
return true;
|
|
2255
2277
|
if ((expression.flags & 32 /* NodeFlags.OptionalChain */) !== 0) {
|
|
2256
2278
|
switch (expression.kind) {
|
|
2257
|
-
case
|
|
2258
|
-
case
|
|
2259
|
-
case
|
|
2260
|
-
case
|
|
2279
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
2280
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
2281
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
2282
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
2261
2283
|
return containsNarrowableReference(getExpression(expression));
|
|
2262
2284
|
}
|
|
2263
2285
|
}
|
|
@@ -2269,20 +2291,20 @@ export function isNarrowableReference(node) {
|
|
|
2269
2291
|
case 79 /* SyntaxKind.Identifier */:
|
|
2270
2292
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
2271
2293
|
case 107 /* SyntaxKind.SuperKeyword */:
|
|
2272
|
-
case
|
|
2294
|
+
case 238 /* SyntaxKind.MetaProperty */:
|
|
2273
2295
|
return true;
|
|
2274
|
-
case
|
|
2296
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
2275
2297
|
return isNarrowableReference(node.expression);
|
|
2276
|
-
case
|
|
2298
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
2277
2299
|
return isNarrowableReference(node.expression);
|
|
2278
|
-
case
|
|
2300
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
2279
2301
|
return isNarrowableReference(node.expression);
|
|
2280
|
-
case
|
|
2302
|
+
case 214 /* SyntaxKind.ElementAccessExpression */: {
|
|
2281
2303
|
const access = node;
|
|
2282
2304
|
return (isStringOrNumericLiteralLike(access.argumentExpression) ||
|
|
2283
2305
|
(isEntityNameExpression(access.argumentExpression, false) && isNarrowableReference(access.expression)));
|
|
2284
2306
|
}
|
|
2285
|
-
case
|
|
2307
|
+
case 228 /* SyntaxKind.BinaryExpression */: {
|
|
2286
2308
|
const binary = node;
|
|
2287
2309
|
const operator = binary.operatorToken.kind;
|
|
2288
2310
|
return ((operator === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(binary.right)) ||
|
|
@@ -2328,7 +2350,7 @@ function isNarrowingBinaryExpression(expression) {
|
|
|
2328
2350
|
return false;
|
|
2329
2351
|
}
|
|
2330
2352
|
function isNarrowableOperand(expression) {
|
|
2331
|
-
if (expression.kind ===
|
|
2353
|
+
if (expression.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
2332
2354
|
return isNarrowableOperand(getExpression(expression));
|
|
2333
2355
|
if (expression instanceof BinaryExpression) {
|
|
2334
2356
|
const binary = expression;
|
|
@@ -2341,7 +2363,7 @@ function isNarrowableOperand(expression) {
|
|
|
2341
2363
|
return containsNarrowableReference(expression);
|
|
2342
2364
|
}
|
|
2343
2365
|
function isNarrowingTypeOfOperands(expression1, expression2) {
|
|
2344
|
-
return (expression1.kind ===
|
|
2366
|
+
return (expression1.kind === 223 /* SyntaxKind.TypeOfExpression */ &&
|
|
2345
2367
|
isNarrowableOperand(getExpression(expression1)) &&
|
|
2346
2368
|
isStringLiteralLike(expression2));
|
|
2347
2369
|
}
|
|
@@ -2357,3 +2379,8 @@ export function findUseStrictPrologue(file, statements) {
|
|
|
2357
2379
|
}
|
|
2358
2380
|
return undefined;
|
|
2359
2381
|
}
|
|
2382
|
+
/** Whether a module name is a pattern with exactly one `*`. */
|
|
2383
|
+
function hasSingleStar(text) {
|
|
2384
|
+
const star = text.indexOf('*');
|
|
2385
|
+
return star >= 0 && text.indexOf('*', star + 1) < 0;
|
|
2386
|
+
}
|