tsc-ts 0.0.9 → 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 +2 -2
- 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 +22 -15
- package/dist/api/compiler/ast.js +1026 -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 +178 -124
- 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 +472 -440
- 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 -107
- 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 +212 -75
- 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 +145 -36
- 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 +104 -31
- package/dist/api/compiler/checker.js +181 -33
- 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 +42 -3
- package/dist/api/compiler/compile-program.js +139 -27
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.d.ts +22 -0
- package/dist/api/compiler/diagnostics.js +93 -11
- 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 +21 -1
- package/dist/api/compiler/file-loader.js +201 -48
- 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/parallel-parse.d.ts +3 -2
- package/dist/api/compiler/parallel-parse.js +17 -5
- 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 +5 -1
- package/dist/api/compiler/printer/emit-context.js +20 -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 +49 -2
- package/dist/api/compiler/printer/printer.js +539 -293
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +12 -2
- package/dist/api/compiler/program-checker.js +88 -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 +4 -6
- package/dist/api/compiler/program.js +74 -87
- 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 +347 -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 +23 -14
- package/dist/api/compiler/symbol.js +23 -11
- 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 +58 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +79 -9
- 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 +136 -62
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -82
- 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 +200 -56
- 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 +124 -23
- 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 +203 -39
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +167 -27
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/diagnostics.ts +84 -3
- 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 +197 -38
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +165 -30
- 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 +326 -52
- package/src/compiler/parallel-emit.ts +320 -0
- package/src/compiler/parallel-parse.ts +16 -5
- package/src/compiler/parse-thread.ts +3 -0
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +21 -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 +266 -30
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +57 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +18 -26
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +240 -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 +46 -24
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +64 -4
- 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 +66 -9
- package/src/compiler/tsc-cli.ts +7 -0
- package/src/compiler/tsc-compile.ts +284 -4
- 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
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// overloads and enum values exactly; types from annotations and the isolatedDeclarations
|
|
3
3
|
// rules (literals, `as const`, annotated function expressions). Types that need inference
|
|
4
4
|
// are reported to the tracker and written as `any`.
|
|
5
|
-
import { AsExpression, BigIntLiteral, ObjectLiteralExpression, BindingElement, BindingPattern, ComputedPropertyName, ElementAccessExpression, ExportDeclaration, ExportSpecifier, ExternalModuleReference, FunctionTypeNode, Identifier,
|
|
5
|
+
import { AsExpression, BigIntLiteral, ObjectLiteralExpression, BindingElement, BindingPattern, ComputedPropertyName, ElementAccessExpression, ExportDeclaration, ExportSpecifier, ExternalModuleReference, FunctionTypeNode, Identifier, ImportEqualsDeclaration, KeywordTypeNode, LiteralTypeNode, MethodSignatureDeclaration, ModuleDeclaration, NodeVisitor, NumericLiteral, ParameterDeclaration, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertySignatureDeclaration, QualifiedName, SetAccessorDeclaration, GetAccessorDeclaration, HeritageClause, StringLiteral, NoSubstitutionTemplateLiteral, TemplateMiddle, TemplateTail, TypePredicateNode, TupleTypeNode, TypeLiteralNode, TypeOperatorNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, getAsteriskToken, getBody, getExpression, getInitializer, getMembers, getName, getParameters, getSymbol, getType, } from '../ast.js';
|
|
6
6
|
import { isAmbientModule, isFunctionLike, nodeIsPresent } from '../ast-utilities.js';
|
|
7
7
|
import { getContainerFlags } from '../binder.js';
|
|
8
8
|
import { getCombinedModifierFlags, getCombinedNodeFlags, getRootDeclaration, getSourceFileOfNode, hasSyntacticModifier, isEntityNameExpression, isExternalOrCommonJSModule, isGlobalSourceFile, isIdentifierNamed, isModuleAugmentationExternal, isParameterPropertyDeclaration, isStringOrNumericLiteralLike, skipParentheses, } from '../binder-utilities.js';
|
|
9
9
|
import { NameResolver } from '../name-resolver.js';
|
|
10
|
-
import { ModuleKind as ModuleKinds } from '../options.js';
|
|
11
10
|
import { combinePaths, getDirectoryPath, getNormalizedAbsolutePath, normalizePath } from '../path.js';
|
|
12
11
|
import { isIdentifierText } from '../scanner.js';
|
|
13
12
|
import { DeclarationEmitResolver, SymbolAccessibilityResult, accessible, } from './declarations-resolver.js';
|
|
@@ -125,7 +124,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
125
124
|
const meaning = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */;
|
|
126
125
|
const parent = node.parent;
|
|
127
126
|
let symbol = undefined;
|
|
128
|
-
if (node.kind !== 10 /* SyntaxKind.StringLiteral */ && parent.kind ===
|
|
127
|
+
if (node.kind !== 10 /* SyntaxKind.StringLiteral */ && parent.kind === 279 /* SyntaxKind.ExportAssignment */)
|
|
129
128
|
symbol = this.resolveName(node, getIdentifierText(node), meaning);
|
|
130
129
|
else if (parent instanceof ExportSpecifier) {
|
|
131
130
|
const declaration = parent.parent.parent;
|
|
@@ -163,23 +162,23 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
163
162
|
}
|
|
164
163
|
determineIfDeclarationIsVisible(node) {
|
|
165
164
|
switch (node.kind) {
|
|
166
|
-
case
|
|
167
|
-
case
|
|
165
|
+
case 332 /* SyntaxKind.JSDocCallbackTag */:
|
|
166
|
+
case 339 /* SyntaxKind.JSDocTypedefTag */: {
|
|
168
167
|
// Top-level JSDoc type aliases are exported.
|
|
169
168
|
const host = node.parent?.parent?.parent;
|
|
170
|
-
return host !== undefined && host.kind ===
|
|
169
|
+
return host !== undefined && host.kind === 308 /* SyntaxKind.SourceFile */;
|
|
171
170
|
}
|
|
172
|
-
case
|
|
171
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
173
172
|
return this.isDeclarationVisible(node.parent.parent);
|
|
174
|
-
case
|
|
175
|
-
case
|
|
176
|
-
case
|
|
177
|
-
case
|
|
178
|
-
case
|
|
179
|
-
case
|
|
180
|
-
case
|
|
181
|
-
case
|
|
182
|
-
case
|
|
173
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
174
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
175
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
176
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
177
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
178
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
179
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
180
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
181
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */: {
|
|
183
182
|
if (node instanceof VariableDeclaration &&
|
|
184
183
|
node.name instanceof BindingPattern &&
|
|
185
184
|
node.name.elements.nodes.length === 0)
|
|
@@ -189,50 +188,50 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
189
188
|
const parent = getDeclarationContainer(node);
|
|
190
189
|
// Unexported declarations are visible only in global files; ambient module members are exported.
|
|
191
190
|
if ((getCombinedModifierFlags(node) & 32 /* ModifierFlags.Export */) === 0 &&
|
|
192
|
-
!(node.kind !==
|
|
193
|
-
parent.kind !==
|
|
191
|
+
!(node.kind !== 273 /* SyntaxKind.ImportEqualsDeclaration */ &&
|
|
192
|
+
parent.kind !== 308 /* SyntaxKind.SourceFile */ &&
|
|
194
193
|
(parent.flags & 8388608 /* NodeFlags.Ambient */) !== 0))
|
|
195
194
|
return isGlobalSourceFile(parent);
|
|
196
195
|
return this.isDeclarationVisible(parent);
|
|
197
196
|
}
|
|
198
|
-
case
|
|
199
|
-
case
|
|
200
|
-
case
|
|
201
|
-
case
|
|
202
|
-
case
|
|
203
|
-
case
|
|
197
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
198
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
199
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
200
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
201
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
202
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
204
203
|
if (this.getEffectiveDeclarationFlags(node, 2 /* ModifierFlags.Private */ | 4 /* ModifierFlags.Protected */) !== 0)
|
|
205
204
|
return false;
|
|
206
205
|
return this.isDeclarationVisible(node.parent);
|
|
207
|
-
case
|
|
208
|
-
case
|
|
209
|
-
case
|
|
210
|
-
case
|
|
211
|
-
case
|
|
212
|
-
case
|
|
213
|
-
case
|
|
214
|
-
case
|
|
215
|
-
case
|
|
216
|
-
case
|
|
217
|
-
case
|
|
218
|
-
case
|
|
219
|
-
case
|
|
220
|
-
case
|
|
221
|
-
case
|
|
222
|
-
case
|
|
206
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
207
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
208
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
209
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
210
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
211
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
212
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
213
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
214
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
215
|
+
case 185 /* SyntaxKind.TypeReference */:
|
|
216
|
+
case 190 /* SyntaxKind.ArrayType */:
|
|
217
|
+
case 191 /* SyntaxKind.TupleType */:
|
|
218
|
+
case 194 /* SyntaxKind.UnionType */:
|
|
219
|
+
case 195 /* SyntaxKind.IntersectionType */:
|
|
220
|
+
case 198 /* SyntaxKind.ParenthesizedType */:
|
|
221
|
+
case 204 /* SyntaxKind.NamedTupleMember */:
|
|
223
222
|
return this.isDeclarationVisible(node.parent);
|
|
224
223
|
// Imports are visible only once something refers to them.
|
|
225
|
-
case
|
|
226
|
-
case
|
|
227
|
-
case
|
|
224
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
225
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
226
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
228
227
|
return false;
|
|
229
|
-
case
|
|
230
|
-
case
|
|
231
|
-
case
|
|
228
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
229
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
230
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
232
231
|
return true;
|
|
233
|
-
case
|
|
232
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
234
233
|
return false;
|
|
235
|
-
case
|
|
234
|
+
case 283 /* SyntaxKind.ExportSpecifier */: {
|
|
236
235
|
const declaration = node.parent.parent;
|
|
237
236
|
if (declaration instanceof ExportDeclaration && declaration.moduleSpecifier === undefined)
|
|
238
237
|
return this.isDeclarationVisible(declaration.parent);
|
|
@@ -281,7 +280,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
281
280
|
this.isDeclarationVisible(anyImport.parent))
|
|
282
281
|
statement = anyImport;
|
|
283
282
|
else if (declaration instanceof VariableDeclaration &&
|
|
284
|
-
declaration.parent.parent.kind ===
|
|
283
|
+
declaration.parent.parent.kind === 245 /* SyntaxKind.VariableStatement */ &&
|
|
285
284
|
!hasSyntacticModifier(declaration.parent.parent, 32 /* ModifierFlags.Export */) &&
|
|
286
285
|
this.isDeclarationVisible(declaration.parent.parent.parent))
|
|
287
286
|
statement = declaration.parent.parent;
|
|
@@ -291,10 +290,10 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
291
290
|
statement = declaration;
|
|
292
291
|
else if (declaration instanceof BindingElement && (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) {
|
|
293
292
|
const root = getRootDeclaration(declaration);
|
|
294
|
-
if (root.kind ===
|
|
293
|
+
if (root.kind === 171 /* SyntaxKind.Parameter */)
|
|
295
294
|
return undefined;
|
|
296
295
|
const variableStatement = root.parent?.parent;
|
|
297
|
-
if (variableStatement === undefined || variableStatement.kind !==
|
|
296
|
+
if (variableStatement === undefined || variableStatement.kind !== 245 /* SyntaxKind.VariableStatement */)
|
|
298
297
|
return undefined;
|
|
299
298
|
// Already exported: nothing to keep.
|
|
300
299
|
if (hasSyntacticModifier(variableStatement, 32 /* ModifierFlags.Export */))
|
|
@@ -326,15 +325,15 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
326
325
|
const parent = node.parent;
|
|
327
326
|
// Class and interface members are never implicitly exported or ambient.
|
|
328
327
|
if (parent !== undefined &&
|
|
329
|
-
parent.kind !==
|
|
330
|
-
parent.kind !==
|
|
331
|
-
parent.kind !==
|
|
328
|
+
parent.kind !== 266 /* SyntaxKind.InterfaceDeclaration */ &&
|
|
329
|
+
parent.kind !== 265 /* SyntaxKind.ClassDeclaration */ &&
|
|
330
|
+
parent.kind !== 233 /* SyntaxKind.ClassExpression */ &&
|
|
332
331
|
(node.flags & 8388608 /* NodeFlags.Ambient */) !== 0) {
|
|
333
332
|
const container = getEnclosingContainer(node);
|
|
334
333
|
if (container !== undefined &&
|
|
335
334
|
(container.flags & 64 /* NodeFlags.ExportContext */) !== 0 &&
|
|
336
335
|
(result & 128 /* ModifierFlags.Ambient */) === 0 &&
|
|
337
|
-
!(parent.kind ===
|
|
336
|
+
!(parent.kind === 270 /* SyntaxKind.ModuleBlock */ && isGlobalScopeAugmentation(parent.parent)))
|
|
338
337
|
result |= 32 /* ModifierFlags.Export */;
|
|
339
338
|
result |= 128 /* ModifierFlags.Ambient */;
|
|
340
339
|
}
|
|
@@ -343,7 +342,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
343
342
|
isImplementationOfOverload(node) {
|
|
344
343
|
if ((node.flags & 16 /* NodeFlags.Synthesized */) !== 0 || !nodeIsPresent(getBody(node)))
|
|
345
344
|
return false;
|
|
346
|
-
if (node.kind ===
|
|
345
|
+
if (node.kind === 179 /* SyntaxKind.GetAccessor */ || node.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
347
346
|
return false;
|
|
348
347
|
const symbol = this.getSymbolOfDeclaration(node);
|
|
349
348
|
if (symbol === undefined)
|
|
@@ -394,7 +393,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
394
393
|
return undefined;
|
|
395
394
|
const name = node.name.text;
|
|
396
395
|
const left = node.expression;
|
|
397
|
-
if (left.kind === 79 /* SyntaxKind.Identifier */ || left.kind ===
|
|
396
|
+
if (left.kind === 79 /* SyntaxKind.Identifier */ || left.kind === 213 /* SyntaxKind.PropertyAccessExpression */) {
|
|
398
397
|
const symbol = this.resolveEntityNameExpression(left, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */);
|
|
399
398
|
if (symbol !== undefined && (symbol.flags & 2097152 /* SymbolFlags.Alias */) === 0) {
|
|
400
399
|
const member = (symbol.exports ?? emptyTable).get(name);
|
|
@@ -489,14 +488,14 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
489
488
|
case 132 /* SyntaxKind.AnyKeyword */:
|
|
490
489
|
case 159 /* SyntaxKind.UnknownKeyword */:
|
|
491
490
|
return true;
|
|
492
|
-
case
|
|
491
|
+
case 198 /* SyntaxKind.ParenthesizedType */:
|
|
493
492
|
return this.typeContainsUndefined(getType(type), location);
|
|
494
|
-
case
|
|
493
|
+
case 194 /* SyntaxKind.UnionType */:
|
|
495
494
|
for (const member of typesOf(type))
|
|
496
495
|
if (this.typeContainsUndefined(member, location))
|
|
497
496
|
return true;
|
|
498
497
|
return false;
|
|
499
|
-
case
|
|
498
|
+
case 185 /* SyntaxKind.TypeReference */: {
|
|
500
499
|
// An unresolved name or import is an error type, which counts as containing `undefined`.
|
|
501
500
|
const symbol = this.resolveName(location, getIdentifierText(getFirstIdentifier(type.typeName)), 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */);
|
|
502
501
|
return symbol === undefined || (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0;
|
|
@@ -513,7 +512,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
513
512
|
// Properties assigned to a function-valued variable are bound to the function.
|
|
514
513
|
if (node instanceof VariableDeclaration)
|
|
515
514
|
host = node.initializer;
|
|
516
|
-
else if (node.kind !==
|
|
515
|
+
else if (node.kind !== 264 /* SyntaxKind.FunctionDeclaration */)
|
|
517
516
|
host = undefined;
|
|
518
517
|
if (host === undefined || !isFunctionLike(host))
|
|
519
518
|
return result;
|
|
@@ -556,27 +555,6 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
556
555
|
getTypeReferenceSerializationKind(typeName, location) {
|
|
557
556
|
return this.emitResolver.getTypeReferenceSerializationKind(typeName, location);
|
|
558
557
|
}
|
|
559
|
-
getResolutionModeOverride(node) {
|
|
560
|
-
if (!(node instanceof ImportAttributes))
|
|
561
|
-
return undefined;
|
|
562
|
-
for (const element of node.attributes.nodes) {
|
|
563
|
-
if (!(element instanceof ImportAttribute))
|
|
564
|
-
continue;
|
|
565
|
-
const name = element.name;
|
|
566
|
-
if (name === undefined || (name.kind !== 10 /* SyntaxKind.StringLiteral */ && name.kind !== 79 /* SyntaxKind.Identifier */))
|
|
567
|
-
continue;
|
|
568
|
-
if (getText(name) !== 'resolution-mode')
|
|
569
|
-
continue;
|
|
570
|
-
const value = element.value;
|
|
571
|
-
if (!(value instanceof StringLiteral))
|
|
572
|
-
return undefined;
|
|
573
|
-
if (value.text === 'import')
|
|
574
|
-
return ModuleKinds.ESNext;
|
|
575
|
-
if (value.text === 'require')
|
|
576
|
-
return ModuleKinds.CommonJS;
|
|
577
|
-
}
|
|
578
|
-
return undefined;
|
|
579
|
-
}
|
|
580
558
|
getSourceFileFromReference(file, reference) {
|
|
581
559
|
const path = normalizePath(combinePaths(getDirectoryPath(file.fileName), reference.fileName));
|
|
582
560
|
for (const candidate of [path, path + '.ts', path + '.tsx', path + '.d.ts']) {
|
|
@@ -605,10 +583,10 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
605
583
|
if ((declaration.flags & 16 /* NodeFlags.Synthesized */) !== 0)
|
|
606
584
|
return undefined;
|
|
607
585
|
const writer = new PseudoTypeWriter(this, context, tracker, enclosingDeclaration, flags);
|
|
608
|
-
const isAccessor = declaration.kind ===
|
|
586
|
+
const isAccessor = declaration.kind === 179 /* SyntaxKind.GetAccessor */ || declaration.kind === 180 /* SyntaxKind.SetAccessor */;
|
|
609
587
|
this.pseudo.uncertain = 0;
|
|
610
588
|
let type = isAccessor ? this.pseudo.getTypeOfAccessor(declaration) : this.pseudo.getTypeOfDeclaration(declaration);
|
|
611
|
-
if (declaration.kind ===
|
|
589
|
+
if (declaration.kind === 171 /* SyntaxKind.Parameter */ &&
|
|
612
590
|
this.requiresAddingImplicitUndefined(declaration, enclosingDeclaration) &&
|
|
613
591
|
!this.pseudoContainsUndefined(type))
|
|
614
592
|
type = new UnionType([type, undefinedType]);
|
|
@@ -631,7 +609,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
631
609
|
return false;
|
|
632
610
|
}
|
|
633
611
|
if (type instanceof DirectType)
|
|
634
|
-
return couldAlreadyReferToUndefined(type) && type.typeNode.kind !==
|
|
612
|
+
return couldAlreadyReferToUndefined(type) && type.typeNode.kind !== 185 /* SyntaxKind.TypeReference */;
|
|
635
613
|
return type.kind === 5 /* PseudoTypeKind.Undefined */;
|
|
636
614
|
}
|
|
637
615
|
createReturnTypeOfSignatureDeclaration(context, signature, enclosingDeclaration, flags, tracker) {
|
|
@@ -647,7 +625,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
647
625
|
return context.factory.created(new KeywordTypeNode(115 /* SyntaxKind.VoidKeyword */));
|
|
648
626
|
}
|
|
649
627
|
}
|
|
650
|
-
if (type instanceof NoResultType && getBody(signature) === undefined && signature.kind !==
|
|
628
|
+
if (type instanceof NoResultType && getBody(signature) === undefined && signature.kind !== 179 /* SyntaxKind.GetAccessor */) {
|
|
651
629
|
// A signature without a body or annotation returns `any`.
|
|
652
630
|
writer.reportFallback(type, false);
|
|
653
631
|
return undefined;
|
|
@@ -659,7 +637,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
659
637
|
return undefined;
|
|
660
638
|
}
|
|
661
639
|
createLiteralConstValue(context, node, _tracker) {
|
|
662
|
-
const initializer = node.kind ===
|
|
640
|
+
const initializer = node.kind === 279 /* SyntaxKind.ExportAssignment */ ? getExpression(node) : getInitializer(node);
|
|
663
641
|
if (initializer === undefined)
|
|
664
642
|
return undefined;
|
|
665
643
|
const literal = literalOf(skipParentheses(initializer));
|
|
@@ -679,7 +657,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
679
657
|
return factory.created(new BigIntLiteral(literal.text, 0 /* TokenFlags.None */));
|
|
680
658
|
case 8 /* SyntaxKind.NumericLiteral */:
|
|
681
659
|
return createNumberExpression(context, Number(literal.text));
|
|
682
|
-
case
|
|
660
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */: {
|
|
683
661
|
const unary = literal;
|
|
684
662
|
const operand = unary.operand;
|
|
685
663
|
if (operand instanceof BigIntLiteral)
|
|
@@ -711,9 +689,9 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
711
689
|
if (this.isLateBindableExpression(name.expression))
|
|
712
690
|
continue;
|
|
713
691
|
this.countFallback(member, true);
|
|
714
|
-
if (isFunctionLike(member) && getType(member) === undefined && member.kind !==
|
|
692
|
+
if (isFunctionLike(member) && getType(member) === undefined && member.kind !== 180 /* SyntaxKind.SetAccessor */)
|
|
715
693
|
writer.write(this.pseudo.getReturnTypeOfSignature(member));
|
|
716
|
-
else if (member.kind ===
|
|
694
|
+
else if (member.kind === 174 /* SyntaxKind.PropertyDeclaration */ && getType(member) === undefined)
|
|
717
695
|
writer.write(this.pseudo.getTypeOfDeclaration(member));
|
|
718
696
|
}
|
|
719
697
|
return [];
|
|
@@ -940,7 +918,7 @@ class PseudoTypeWriter {
|
|
|
940
918
|
return undefined;
|
|
941
919
|
const result = factory.created(new ParameterDeclaration(undefined, parameter.rest ? factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, this.cloneParameterName(parameter.name), parameter.optional ? factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, type, undefined));
|
|
942
920
|
const original = parameter.name.parent;
|
|
943
|
-
if (original !== undefined && original.kind ===
|
|
921
|
+
if (original !== undefined && original.kind === 171 /* SyntaxKind.Parameter */)
|
|
944
922
|
this.context.assignCommentRange(result, original);
|
|
945
923
|
return result;
|
|
946
924
|
}
|
|
@@ -1094,7 +1072,7 @@ class PseudoTypeWriter {
|
|
|
1094
1072
|
}
|
|
1095
1073
|
/** JSDoc types such as `?T` can't be reused as written. */
|
|
1096
1074
|
markJSDocType(node) {
|
|
1097
|
-
if (node.kind >=
|
|
1075
|
+
if (node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 344 /* SyntaxKind.LastJSDocNode */)
|
|
1098
1076
|
this.reuseFailed = true;
|
|
1099
1077
|
return true;
|
|
1100
1078
|
}
|
|
@@ -1104,7 +1082,7 @@ class PseudoTypeWriter {
|
|
|
1104
1082
|
name = node.typeName;
|
|
1105
1083
|
else if (node instanceof TypeQueryNode)
|
|
1106
1084
|
name = node.exprName;
|
|
1107
|
-
else if (node.kind ===
|
|
1085
|
+
else if (node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */)
|
|
1108
1086
|
name = node.expression;
|
|
1109
1087
|
if (name === undefined || !(isEntityNameExpression(name, false) || name instanceof QualifiedName))
|
|
1110
1088
|
return false;
|
|
@@ -1137,7 +1115,7 @@ class PseudoTypeWriter {
|
|
|
1137
1115
|
function isSignatureLocal(symbol) {
|
|
1138
1116
|
const declaration = symbol.valueDeclaration ?? (declarationCount(symbol) > 0 ? symbol.declaration : undefined);
|
|
1139
1117
|
return (declaration !== undefined &&
|
|
1140
|
-
(declaration.kind ===
|
|
1118
|
+
(declaration.kind === 171 /* SyntaxKind.Parameter */ || declaration.kind === 170 /* SyntaxKind.TypeParameter */));
|
|
1141
1119
|
}
|
|
1142
1120
|
class EntityNameTracker extends NodeVisitor {
|
|
1143
1121
|
writer;
|
|
@@ -1154,7 +1132,7 @@ class EntityNameTracker extends NodeVisitor {
|
|
|
1154
1132
|
/** Single-line tuples and mapped types, and string literals without escapes, as tsgo's node reuse. */
|
|
1155
1133
|
function styleReusedNodes(context, node) {
|
|
1156
1134
|
const kind = node.kind;
|
|
1157
|
-
if (kind ===
|
|
1135
|
+
if (kind === 191 /* SyntaxKind.TupleType */ || kind === 202 /* SyntaxKind.MappedType */)
|
|
1158
1136
|
context.addEmitFlags(node, 1 /* EmitFlags.SingleLine */);
|
|
1159
1137
|
else if (kind === 10 /* SyntaxKind.StringLiteral */ || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */)
|
|
1160
1138
|
context.addEmitFlags(node, 131072 /* EmitFlags.NoAsciiEscaping */);
|
|
@@ -1224,7 +1202,7 @@ export function tryGetTextOfPropertyName(name) {
|
|
|
1224
1202
|
case 8 /* SyntaxKind.NumericLiteral */:
|
|
1225
1203
|
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
|
|
1226
1204
|
return literalText(name);
|
|
1227
|
-
case
|
|
1205
|
+
case 169 /* SyntaxKind.ComputedPropertyName */: {
|
|
1228
1206
|
const expression = name.expression;
|
|
1229
1207
|
return isStringOrNumericLiteralLike(expression) ? literalText(expression) : undefined;
|
|
1230
1208
|
}
|
|
@@ -1233,12 +1211,12 @@ export function tryGetTextOfPropertyName(name) {
|
|
|
1233
1211
|
}
|
|
1234
1212
|
/** Whether a declaration's type is a literal or `unique symbol`: a computed name it names is late-bound. */
|
|
1235
1213
|
function hasLiteralOrUniqueSymbolType(declaration) {
|
|
1236
|
-
if (declaration.kind ===
|
|
1214
|
+
if (declaration.kind === 307 /* SyntaxKind.EnumMember */)
|
|
1237
1215
|
return true;
|
|
1238
1216
|
const type = getType(declaration);
|
|
1239
1217
|
if (type !== undefined)
|
|
1240
1218
|
return ((type instanceof TypeOperatorNode && type.operator === 158 /* SyntaxKind.UniqueKeyword */) ||
|
|
1241
|
-
type.kind ===
|
|
1219
|
+
type.kind === 203 /* SyntaxKind.LiteralType */);
|
|
1242
1220
|
const initializer = getInitializer(declaration);
|
|
1243
1221
|
if (initializer === undefined)
|
|
1244
1222
|
return false;
|
|
@@ -1250,13 +1228,13 @@ function hasLiteralOrUniqueSymbolType(declaration) {
|
|
|
1250
1228
|
if ((getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) === 0)
|
|
1251
1229
|
return false;
|
|
1252
1230
|
// `const sym = Symbol()` is a unique symbol.
|
|
1253
|
-
if (value.kind ===
|
|
1231
|
+
if (value.kind === 215 /* SyntaxKind.CallExpression */ && isIdentifierNamed(getExpression(value), 'Symbol'))
|
|
1254
1232
|
return true;
|
|
1255
1233
|
return isStringOrNumericLiteralLike(value);
|
|
1256
1234
|
}
|
|
1257
|
-
if (declaration.kind ===
|
|
1235
|
+
if (declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */)
|
|
1258
1236
|
return hasSyntacticModifier(declaration, 8 /* ModifierFlags.Readonly */) && isStringOrNumericLiteralLike(value);
|
|
1259
|
-
if (declaration.kind ===
|
|
1237
|
+
if (declaration.kind === 304 /* SyntaxKind.PropertyAssignment */)
|
|
1260
1238
|
return isInConstContext(value) && isStringOrNumericLiteralLike(value);
|
|
1261
1239
|
return false;
|
|
1262
1240
|
}
|
|
@@ -1270,7 +1248,7 @@ function objectLiteralProperties(node) {
|
|
|
1270
1248
|
/** Whether a function's body returns no values, so its inferred return type is `void`. */
|
|
1271
1249
|
function isTriviallyVoid(fn) {
|
|
1272
1250
|
const body = getBody(fn);
|
|
1273
|
-
if (body === undefined || body.kind !==
|
|
1251
|
+
if (body === undefined || body.kind !== 243 /* SyntaxKind.Block */)
|
|
1274
1252
|
return false;
|
|
1275
1253
|
if (hasSyntacticModifier(fn, 1024 /* ModifierFlags.Async */) || getAsteriskToken(fn) !== undefined)
|
|
1276
1254
|
return false;
|
|
@@ -1278,11 +1256,11 @@ function isTriviallyVoid(fn) {
|
|
|
1278
1256
|
if (statement.expression !== undefined)
|
|
1279
1257
|
return false;
|
|
1280
1258
|
switch (fn.kind) {
|
|
1281
|
-
case
|
|
1282
|
-
case
|
|
1259
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
1260
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
1283
1261
|
return true;
|
|
1284
|
-
case
|
|
1285
|
-
case
|
|
1262
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
1263
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
1286
1264
|
// Without an implicit return, function expressions return `never`.
|
|
1287
1265
|
return (fn.flags & 256 /* NodeFlags.HasImplicitReturn */) !== 0;
|
|
1288
1266
|
}
|
|
@@ -1310,7 +1288,7 @@ function literalOf(node) {
|
|
|
1310
1288
|
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
|
|
1311
1289
|
case 9 /* SyntaxKind.BigIntLiteral */:
|
|
1312
1290
|
return node;
|
|
1313
|
-
case
|
|
1291
|
+
case 226 /* SyntaxKind.PrefixUnaryExpression */: {
|
|
1314
1292
|
const unary = node;
|
|
1315
1293
|
const operand = unary.operand.kind;
|
|
1316
1294
|
if (unary.operator === 40 /* SyntaxKind.MinusToken */ &&
|
|
@@ -1359,15 +1337,15 @@ function getFirstIdentifier(node) {
|
|
|
1359
1337
|
/** What a reference to an entity name means: a value, a namespace or a type. */
|
|
1360
1338
|
export function getMeaningOfEntityNameReference(entityName) {
|
|
1361
1339
|
const parent = entityName.parent;
|
|
1362
|
-
if (parent.kind ===
|
|
1363
|
-
(parent.kind ===
|
|
1364
|
-
parent.kind ===
|
|
1365
|
-
(parent.kind ===
|
|
1366
|
-
parent.kind ===
|
|
1340
|
+
if (parent.kind === 188 /* SyntaxKind.TypeQuery */ ||
|
|
1341
|
+
(parent.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */ && !isPartOfTypeNode(parent)) ||
|
|
1342
|
+
parent.kind === 169 /* SyntaxKind.ComputedPropertyName */ ||
|
|
1343
|
+
(parent.kind === 184 /* SyntaxKind.TypePredicate */ && getTypePredicateParameterName(parent) === entityName) ||
|
|
1344
|
+
parent.kind === 228 /* SyntaxKind.BinaryExpression */)
|
|
1367
1345
|
return 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */;
|
|
1368
|
-
if (entityName.kind ===
|
|
1369
|
-
entityName.kind ===
|
|
1370
|
-
parent.kind ===
|
|
1346
|
+
if (entityName.kind === 168 /* SyntaxKind.QualifiedName */ ||
|
|
1347
|
+
entityName.kind === 213 /* SyntaxKind.PropertyAccessExpression */ ||
|
|
1348
|
+
parent.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */ ||
|
|
1371
1349
|
(parent instanceof QualifiedName && parent.left === entityName) ||
|
|
1372
1350
|
(parent instanceof PropertyAccessExpression && parent.expression === entityName) ||
|
|
1373
1351
|
(parent instanceof ElementAccessExpression && parent.expression === entityName))
|
|
@@ -1383,52 +1361,52 @@ function isPartOfTypeNode(node) {
|
|
|
1383
1361
|
if (parent === undefined)
|
|
1384
1362
|
return false;
|
|
1385
1363
|
if (parent instanceof HeritageClause)
|
|
1386
|
-
return (!(parent.parent.kind ===
|
|
1364
|
+
return (!(parent.parent.kind === 265 /* SyntaxKind.ClassDeclaration */ || parent.parent.kind === 233 /* SyntaxKind.ClassExpression */) ||
|
|
1387
1365
|
parent.token === 118 /* SyntaxKind.ImplementsKeyword */);
|
|
1388
1366
|
return (parent !== undefined &&
|
|
1389
|
-
(parent.kind ===
|
|
1367
|
+
(parent.kind === 325 /* SyntaxKind.JSDocImplementsTag */ || parent.kind === 324 /* SyntaxKind.JSDocAugmentsTag */));
|
|
1390
1368
|
}
|
|
1391
1369
|
function isDeclarationKind(kind) {
|
|
1392
1370
|
switch (kind) {
|
|
1393
|
-
case
|
|
1394
|
-
case
|
|
1395
|
-
case
|
|
1396
|
-
case
|
|
1397
|
-
case
|
|
1398
|
-
case
|
|
1399
|
-
case
|
|
1400
|
-
case
|
|
1401
|
-
case
|
|
1371
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
1372
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
1373
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
1374
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
1375
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
1376
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
1377
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
1378
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
1379
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
1402
1380
|
return true;
|
|
1403
1381
|
}
|
|
1404
1382
|
return false;
|
|
1405
1383
|
}
|
|
1406
1384
|
export function getAnyImportSyntax(node) {
|
|
1407
1385
|
switch (node.kind) {
|
|
1408
|
-
case
|
|
1386
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
1409
1387
|
return node;
|
|
1410
|
-
case
|
|
1388
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
1411
1389
|
return node.parent;
|
|
1412
|
-
case
|
|
1390
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
1413
1391
|
return node.parent?.parent;
|
|
1414
|
-
case
|
|
1392
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
1415
1393
|
return node.parent?.parent?.parent;
|
|
1416
1394
|
}
|
|
1417
1395
|
return undefined;
|
|
1418
1396
|
}
|
|
1419
1397
|
export function isLateVisibilityPaintedStatement(node) {
|
|
1420
1398
|
switch (node.kind) {
|
|
1421
|
-
case
|
|
1422
|
-
case
|
|
1423
|
-
case
|
|
1424
|
-
case
|
|
1425
|
-
case
|
|
1426
|
-
case
|
|
1427
|
-
case
|
|
1428
|
-
case
|
|
1429
|
-
case
|
|
1430
|
-
case
|
|
1431
|
-
case
|
|
1399
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
1400
|
+
case 347 /* SyntaxKind.JSImportDeclaration */:
|
|
1401
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
1402
|
+
case 245 /* SyntaxKind.VariableStatement */:
|
|
1403
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
1404
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
1405
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
1406
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
1407
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
1408
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
1409
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
1432
1410
|
return true;
|
|
1433
1411
|
}
|
|
1434
1412
|
return false;
|
|
@@ -1438,12 +1416,12 @@ export function getDeclarationContainer(node) {
|
|
|
1438
1416
|
let current = getRootDeclaration(node);
|
|
1439
1417
|
while (current !== undefined) {
|
|
1440
1418
|
switch (current.kind) {
|
|
1441
|
-
case
|
|
1442
|
-
case
|
|
1443
|
-
case
|
|
1444
|
-
case
|
|
1445
|
-
case
|
|
1446
|
-
case
|
|
1419
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
1420
|
+
case 263 /* SyntaxKind.VariableDeclarationList */:
|
|
1421
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
1422
|
+
case 277 /* SyntaxKind.NamedImports */:
|
|
1423
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
1424
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
1447
1425
|
current = current.parent;
|
|
1448
1426
|
continue;
|
|
1449
1427
|
}
|
|
@@ -1465,13 +1443,13 @@ export function isExternalModuleAugmentation(node) {
|
|
|
1465
1443
|
}
|
|
1466
1444
|
function isImplicitlyExportedJSDocDeclaration(node) {
|
|
1467
1445
|
const parent = node.parent;
|
|
1468
|
-
if (parent === undefined || parent.kind !==
|
|
1446
|
+
if (parent === undefined || parent.kind !== 308 /* SyntaxKind.SourceFile */)
|
|
1469
1447
|
return false;
|
|
1470
1448
|
if (!isExternalOrCommonJSModule(parent))
|
|
1471
1449
|
return false;
|
|
1472
|
-
if (node.kind ===
|
|
1450
|
+
if (node.kind === 346 /* SyntaxKind.JSTypeAliasDeclaration */)
|
|
1473
1451
|
return true;
|
|
1474
|
-
return node.kind ===
|
|
1452
|
+
return node.kind === 269 /* SyntaxKind.ModuleDeclaration */ && (node.flags & 8 /* NodeFlags.Reparsed */) !== 0;
|
|
1475
1453
|
}
|
|
1476
1454
|
/** Merges global symbol tables as the checker does; conflicting declarations stay apart. */
|
|
1477
1455
|
function mergeInto(target, source, mergedSymbols) {
|
|
@@ -1560,21 +1538,21 @@ class AliasMarker extends NodeVisitor {
|
|
|
1560
1538
|
}
|
|
1561
1539
|
visitNode(node) {
|
|
1562
1540
|
switch (node.kind) {
|
|
1563
|
-
case
|
|
1541
|
+
case 279 /* SyntaxKind.ExportAssignment */: {
|
|
1564
1542
|
const expression = getExpression(node);
|
|
1565
1543
|
if (expression instanceof Identifier)
|
|
1566
1544
|
this.resolver.markLinkedAliases(expression);
|
|
1567
1545
|
return false;
|
|
1568
1546
|
}
|
|
1569
|
-
case
|
|
1547
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
1570
1548
|
if (node instanceof ExportSpecifier)
|
|
1571
1549
|
this.resolver.markLinkedAliases(node.propertyName ?? node.name);
|
|
1572
1550
|
return false;
|
|
1573
1551
|
// Exports are statements of files and namespaces.
|
|
1574
|
-
case
|
|
1575
|
-
case
|
|
1576
|
-
case
|
|
1577
|
-
case
|
|
1552
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
1553
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
1554
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
1555
|
+
case 281 /* SyntaxKind.NamedExports */:
|
|
1578
1556
|
return node.forEachChild(this);
|
|
1579
1557
|
}
|
|
1580
1558
|
return false;
|