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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Declaration emit errors: names that can't be written in a declaration file, and types that
|
|
2
2
|
// `isolatedDeclarations` can't write without inference.
|
|
3
3
|
import { CallExpression, HeritageClause, ParameterDeclaration, SetAccessorDeclaration, getInitializer, getName, getParameters, getSymbol, getType, } from '../ast.js';
|
|
4
|
-
import { declarationNameToString, getErrorRangeForNode, getNameOfDeclaration, getSourceFileOfNode, getSourceTextOfNode, hasSyntacticModifier, isEntityNameExpression, isStatic,
|
|
4
|
+
import { declarationNameToString, getErrorRangeForNode, getNameOfDeclaration, getSourceFileOfNode, getSourceTextOfNode, hasSyntacticModifier, isEntityNameExpression, isStatic, } from '../binder-utilities.js';
|
|
5
5
|
import { isFunctionLikeDeclarationKind } from '../ast-utilities.js';
|
|
6
6
|
import { Diagnostic } from '../diagnostics.js';
|
|
7
7
|
import { isStatement } from '../printer/utilities.js';
|
|
8
|
+
import { isPartOfTypeNode } from './alias-references.js';
|
|
8
9
|
import { isParameterPropertyDeclaration } from './utilities.js';
|
|
9
10
|
import { getDeclarations } from '../symbol.js';
|
|
10
11
|
export function createDiagnosticForNode(node, message, args) {
|
|
@@ -52,29 +53,29 @@ export class SymbolAccessibilityDiagnostic {
|
|
|
52
53
|
/** Whether a declaration of this kind can report inaccessible names in its type. */
|
|
53
54
|
export function canProduceDiagnostics(node) {
|
|
54
55
|
switch (node.kind) {
|
|
55
|
-
case
|
|
56
|
-
case
|
|
57
|
-
case
|
|
58
|
-
case
|
|
59
|
-
case
|
|
60
|
-
case
|
|
61
|
-
case
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
68
|
-
case
|
|
69
|
-
case
|
|
70
|
-
case
|
|
71
|
-
case
|
|
72
|
-
case
|
|
73
|
-
case
|
|
74
|
-
case
|
|
75
|
-
case
|
|
76
|
-
case
|
|
77
|
-
case
|
|
56
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
57
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
58
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
59
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
60
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
61
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
62
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
63
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
64
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
65
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
66
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
67
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
68
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
69
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
70
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
71
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
72
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
73
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
74
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
75
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
76
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
77
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
78
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
78
79
|
return true;
|
|
79
80
|
}
|
|
80
81
|
return false;
|
|
@@ -86,13 +87,13 @@ export function getSymbolAccessibilityDiagnostic(context, result) {
|
|
|
86
87
|
case 0 /* DiagnosticContextKind.None */:
|
|
87
88
|
throw new Error('Diagnostic emitted without context');
|
|
88
89
|
case 3 /* DiagnosticContextKind.DefaultExport */:
|
|
89
|
-
return new SymbolAccessibilityDiagnostic(node,
|
|
90
|
+
return new SymbolAccessibilityDiagnostic(node, 1081 /* Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0 */, undefined);
|
|
90
91
|
case 4 /* DiagnosticContextKind.ExtendsExpression */:
|
|
91
|
-
return new SymbolAccessibilityDiagnostic(node,
|
|
92
|
+
return new SymbolAccessibilityDiagnostic(node, 1021 /* Diagnostics.X_extends_clause_of_exported_class_0_has_or_is_using_private_name_1 */, context.typeName);
|
|
92
93
|
case 2 /* DiagnosticContextKind.DeclarationName */:
|
|
93
|
-
if (node.kind ===
|
|
94
|
+
if (node.kind === 179 /* SyntaxKind.GetAccessor */ || node.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
94
95
|
return simple(node, accessorNameMessage(node, result));
|
|
95
|
-
if (node.kind ===
|
|
96
|
+
if (node.kind === 176 /* SyntaxKind.MethodDeclaration */ || node.kind === 175 /* SyntaxKind.MethodSignature */)
|
|
96
97
|
return simple(node, methodNameMessage(node, result));
|
|
97
98
|
return forDeclaration(node, result);
|
|
98
99
|
case 1 /* DiagnosticContextKind.Declaration */:
|
|
@@ -106,53 +107,53 @@ function simple(node, message) {
|
|
|
106
107
|
}
|
|
107
108
|
function forDeclaration(node, result) {
|
|
108
109
|
switch (node.kind) {
|
|
109
|
-
case
|
|
110
|
-
case
|
|
111
|
-
case
|
|
112
|
-
case
|
|
113
|
-
case
|
|
114
|
-
case
|
|
115
|
-
case
|
|
116
|
-
case
|
|
110
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
111
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
112
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
113
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
114
|
+
case 214 /* SyntaxKind.ElementAccessExpression */:
|
|
115
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
116
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
117
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
117
118
|
return simple(node, variableTypeMessage(node, result));
|
|
118
|
-
case
|
|
119
|
-
case
|
|
119
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
120
|
+
case 179 /* SyntaxKind.GetAccessor */: {
|
|
120
121
|
const name = getNameOfDeclaration(node);
|
|
121
122
|
const message = accessorTypeMessage(node, result);
|
|
122
123
|
return name === undefined ? undefined : new SymbolAccessibilityDiagnostic(name, message, name);
|
|
123
124
|
}
|
|
124
|
-
case
|
|
125
|
-
case
|
|
126
|
-
case
|
|
127
|
-
case
|
|
128
|
-
case
|
|
129
|
-
case
|
|
125
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
126
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
127
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
128
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
129
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
130
|
+
case 183 /* SyntaxKind.IndexSignature */: {
|
|
130
131
|
const name = getNameOfDeclaration(node);
|
|
131
132
|
return new SymbolAccessibilityDiagnostic(name ?? node, returnTypeMessage(node, result), undefined);
|
|
132
133
|
}
|
|
133
|
-
case
|
|
134
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
134
135
|
if (isParameterPropertyDeclaration(node, node.parent) &&
|
|
135
136
|
hasSyntacticModifier(node.parent, 2 /* ModifierFlags.Private */))
|
|
136
137
|
return simple(node, variableTypeMessage(node, result));
|
|
137
138
|
return simple(node, parameterTypeMessage(node, result));
|
|
138
|
-
case
|
|
139
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
139
140
|
return simple(node, typeParameterConstraintMessage(node));
|
|
140
|
-
case
|
|
141
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
141
142
|
return heritageDiagnostic(node);
|
|
142
|
-
case
|
|
143
|
-
return simple(node,
|
|
144
|
-
case
|
|
145
|
-
case
|
|
143
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
144
|
+
return simple(node, 1011 /* Diagnostics.Import_declaration_0_is_using_private_name_1 */);
|
|
145
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
146
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */: {
|
|
146
147
|
const message = result.errorModuleName !== ''
|
|
147
|
-
?
|
|
148
|
-
:
|
|
148
|
+
? 1083 /* Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 */
|
|
149
|
+
: 1080 /* Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1 */;
|
|
149
150
|
const type = getType(node);
|
|
150
151
|
return new SymbolAccessibilityDiagnostic(type ?? node, message, getName(node));
|
|
151
152
|
}
|
|
152
|
-
case
|
|
153
|
+
case 215 /* SyntaxKind.CallExpression */: {
|
|
153
154
|
// `Object.defineProperty(exports, "name", …)` in JavaScript.
|
|
154
155
|
const name = node instanceof CallExpression ? node.arguments.nodes[1] : node;
|
|
155
|
-
return new SymbolAccessibilityDiagnostic(name, byModuleName(result,
|
|
156
|
+
return new SymbolAccessibilityDiagnostic(name, byModuleName(result, 1024 /* Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1025 /* Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 */, 1026 /* Diagnostics.Exported_variable_0_has_or_is_using_private_name_1 */), name);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
throw new Error('Attempted to set a declaration diagnostic context for unhandled node kind');
|
|
@@ -161,16 +162,16 @@ function heritageDiagnostic(node) {
|
|
|
161
162
|
const clause = node.parent;
|
|
162
163
|
const declaration = clause.parent;
|
|
163
164
|
let message;
|
|
164
|
-
if (declaration.kind ===
|
|
165
|
+
if (declaration.kind === 265 /* SyntaxKind.ClassDeclaration */) {
|
|
165
166
|
if (clause instanceof HeritageClause && clause.token === 118 /* SyntaxKind.ImplementsKeyword */)
|
|
166
|
-
message =
|
|
167
|
+
message = 1020 /* Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 */;
|
|
167
168
|
else if (getName(declaration) !== undefined)
|
|
168
|
-
message =
|
|
169
|
+
message = 1021 /* Diagnostics.X_extends_clause_of_exported_class_0_has_or_is_using_private_name_1 */;
|
|
169
170
|
else
|
|
170
|
-
message =
|
|
171
|
+
message = 1022 /* Diagnostics.X_extends_clause_of_exported_class_has_or_is_using_private_name_0 */;
|
|
171
172
|
}
|
|
172
173
|
else
|
|
173
|
-
message =
|
|
174
|
+
message = 1023 /* Diagnostics.X_extends_clause_of_exported_interface_0_has_or_is_using_private_name_1 */;
|
|
174
175
|
return new SymbolAccessibilityDiagnostic(node, message, getNameOfDeclaration(declaration));
|
|
175
176
|
}
|
|
176
177
|
function byModuleName(result, cannotBeNamed, privateModule, nonModule) {
|
|
@@ -183,208 +184,210 @@ function byModuleNameOnly(result, privateModule, nonModule) {
|
|
|
183
184
|
}
|
|
184
185
|
function accessorNameMessage(node, result) {
|
|
185
186
|
if (isStatic(node))
|
|
186
|
-
return byModuleName(result,
|
|
187
|
-
if (node.parent.kind ===
|
|
188
|
-
return byModuleName(result,
|
|
189
|
-
return byModuleNameOnly(result,
|
|
187
|
+
return byModuleName(result, 1027 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1028 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1029 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
188
|
+
if (node.parent.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
189
|
+
return byModuleName(result, 1030 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1031 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1032 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
190
|
+
return byModuleNameOnly(result, 1033 /* Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1034 /* Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1 */);
|
|
190
191
|
}
|
|
191
192
|
function methodNameMessage(node, result) {
|
|
192
193
|
if (isStatic(node))
|
|
193
|
-
return byModuleName(result,
|
|
194
|
-
if (node.parent.kind ===
|
|
195
|
-
return byModuleName(result,
|
|
196
|
-
return byModuleNameOnly(result,
|
|
194
|
+
return byModuleName(result, 1088 /* Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1089 /* Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1090 /* Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
195
|
+
if (node.parent.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
196
|
+
return byModuleName(result, 1091 /* Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1092 /* Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1093 /* Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
197
|
+
return byModuleNameOnly(result, 1094 /* Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1095 /* Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1 */);
|
|
197
198
|
}
|
|
198
199
|
function variableTypeMessage(node, result) {
|
|
199
|
-
if (node.kind ===
|
|
200
|
-
return byModuleName(result,
|
|
200
|
+
if (node.kind === 262 /* SyntaxKind.VariableDeclaration */ || node.kind === 210 /* SyntaxKind.BindingElement */)
|
|
201
|
+
return byModuleName(result, 1024 /* Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1025 /* Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 */, 1026 /* Diagnostics.Exported_variable_0_has_or_is_using_private_name_1 */);
|
|
201
202
|
// Constructor parameter properties report as parameters, unless the constructor is private.
|
|
202
|
-
if (node.kind ===
|
|
203
|
-
node.kind ===
|
|
204
|
-
node.kind ===
|
|
205
|
-
node.kind ===
|
|
206
|
-
node.kind ===
|
|
207
|
-
(node.kind ===
|
|
203
|
+
if (node.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
|
|
204
|
+
node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ ||
|
|
205
|
+
node.kind === 214 /* SyntaxKind.ElementAccessExpression */ ||
|
|
206
|
+
node.kind === 228 /* SyntaxKind.BinaryExpression */ ||
|
|
207
|
+
node.kind === 173 /* SyntaxKind.PropertySignature */ ||
|
|
208
|
+
(node.kind === 171 /* SyntaxKind.Parameter */ && hasSyntacticModifier(node.parent, 2 /* ModifierFlags.Private */))) {
|
|
208
209
|
if (isStatic(node))
|
|
209
|
-
return byModuleName(result,
|
|
210
|
-
if (node.parent.kind ===
|
|
211
|
-
return byModuleName(result,
|
|
212
|
-
return byModuleNameOnly(result,
|
|
210
|
+
return byModuleName(result, 1027 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1028 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1029 /* Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
211
|
+
if (node.parent.kind === 265 /* SyntaxKind.ClassDeclaration */ || node.kind === 171 /* SyntaxKind.Parameter */)
|
|
212
|
+
return byModuleName(result, 1030 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1031 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1032 /* Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1 */);
|
|
213
|
+
return byModuleNameOnly(result, 1033 /* Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1034 /* Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1 */);
|
|
213
214
|
}
|
|
214
215
|
return undefined;
|
|
215
216
|
}
|
|
216
217
|
function accessorTypeMessage(node, result) {
|
|
217
|
-
if (node.kind ===
|
|
218
|
+
if (node.kind === 180 /* SyntaxKind.SetAccessor */) {
|
|
218
219
|
// A setter's parameter type is written by the user, so it can always be named.
|
|
219
220
|
if (isStatic(node))
|
|
220
|
-
return byModuleNameOnly(result,
|
|
221
|
-
return byModuleNameOnly(result,
|
|
221
|
+
return byModuleNameOnly(result, 1035 /* Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1036 /* Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1 */);
|
|
222
|
+
return byModuleNameOnly(result, 1037 /* Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1038 /* Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1 */);
|
|
222
223
|
}
|
|
223
224
|
if (isStatic(node))
|
|
224
|
-
return byModuleName(result,
|
|
225
|
-
return byModuleName(result,
|
|
225
|
+
return byModuleName(result, 1039 /* Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1040 /* Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1041 /* Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1 */);
|
|
226
|
+
return byModuleName(result, 1042 /* Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1043 /* Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1044 /* Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1 */);
|
|
226
227
|
}
|
|
227
228
|
function returnTypeMessage(node, result) {
|
|
228
229
|
switch (node.kind) {
|
|
229
|
-
case
|
|
230
|
-
return byModuleNameOnly(result,
|
|
231
|
-
case
|
|
232
|
-
return byModuleNameOnly(result,
|
|
233
|
-
case
|
|
234
|
-
return byModuleNameOnly(result,
|
|
235
|
-
case
|
|
236
|
-
case
|
|
230
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
231
|
+
return byModuleNameOnly(result, 1045 /* Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 */, 1046 /* Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0 */);
|
|
232
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
233
|
+
return byModuleNameOnly(result, 1047 /* Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 */, 1048 /* Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0 */);
|
|
234
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
235
|
+
return byModuleNameOnly(result, 1049 /* Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 */, 1050 /* Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0 */);
|
|
236
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
237
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
237
238
|
if (isStatic(node))
|
|
238
|
-
return byModuleName(result,
|
|
239
|
-
if (node.parent.kind ===
|
|
240
|
-
return byModuleName(result,
|
|
241
|
-
return byModuleNameOnly(result,
|
|
242
|
-
case
|
|
243
|
-
return byModuleName(result,
|
|
239
|
+
return byModuleName(result, 1051 /* Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named */, 1052 /* Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 */, 1053 /* Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0 */);
|
|
240
|
+
if (node.parent.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
241
|
+
return byModuleName(result, 1054 /* Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named */, 1055 /* Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 */, 1056 /* Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0 */);
|
|
242
|
+
return byModuleNameOnly(result, 1057 /* Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 */, 1058 /* Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0 */);
|
|
243
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
244
|
+
return byModuleName(result, 1059 /* Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named */, 1060 /* Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 */, 1061 /* Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0 */);
|
|
244
245
|
}
|
|
245
246
|
throw new Error('This is unknown kind for signature');
|
|
246
247
|
}
|
|
247
248
|
function parameterTypeMessage(node, result) {
|
|
248
249
|
const parent = node.parent;
|
|
249
250
|
switch (parent.kind) {
|
|
250
|
-
case
|
|
251
|
-
return byModuleName(result,
|
|
252
|
-
case
|
|
253
|
-
case
|
|
254
|
-
return byModuleNameOnly(result,
|
|
255
|
-
case
|
|
256
|
-
return byModuleNameOnly(result,
|
|
257
|
-
case
|
|
258
|
-
return byModuleNameOnly(result,
|
|
259
|
-
case
|
|
260
|
-
case
|
|
251
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
252
|
+
return byModuleName(result, 1062 /* Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1063 /* Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1064 /* Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1 */);
|
|
253
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
254
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
255
|
+
return byModuleNameOnly(result, 1065 /* Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1066 /* Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1 */);
|
|
256
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
257
|
+
return byModuleNameOnly(result, 1067 /* Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1068 /* Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1 */);
|
|
258
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
259
|
+
return byModuleNameOnly(result, 1085 /* Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1086 /* Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1 */);
|
|
260
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
261
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
261
262
|
if (isStatic(parent))
|
|
262
|
-
return byModuleName(result,
|
|
263
|
-
if (parent.parent.kind ===
|
|
264
|
-
return byModuleName(result,
|
|
265
|
-
return byModuleNameOnly(result,
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
|
|
269
|
-
case
|
|
270
|
-
|
|
271
|
-
|
|
263
|
+
return byModuleName(result, 1069 /* Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1070 /* Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1071 /* Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 */);
|
|
264
|
+
if (parent.parent.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
265
|
+
return byModuleName(result, 1072 /* Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1073 /* Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 */, 1074 /* Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1 */);
|
|
266
|
+
return byModuleNameOnly(result, 1075 /* Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 */, 1076 /* Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1 */);
|
|
267
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
268
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
269
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
270
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
271
|
+
return byModuleName(result, 1077 /* Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1078 /* Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 */, 1079 /* Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1 */);
|
|
272
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
273
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
274
|
+
return byModuleName(result, 1101 /* Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named */, 1100 /* Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 */, 1099 /* Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1 */);
|
|
272
275
|
}
|
|
273
276
|
throw new Error('Unknown parent for parameter');
|
|
274
277
|
}
|
|
275
278
|
function typeParameterConstraintMessage(node) {
|
|
276
279
|
const parent = node.parent;
|
|
277
280
|
switch (parent.kind) {
|
|
278
|
-
case
|
|
279
|
-
return
|
|
280
|
-
case
|
|
281
|
-
return
|
|
282
|
-
case
|
|
283
|
-
return
|
|
284
|
-
case
|
|
285
|
-
case
|
|
286
|
-
return
|
|
287
|
-
case
|
|
288
|
-
return
|
|
289
|
-
case
|
|
290
|
-
case
|
|
281
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
282
|
+
return 1012 /* Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1 */;
|
|
283
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
284
|
+
return 1013 /* Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1 */;
|
|
285
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
286
|
+
return 1096 /* Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1 */;
|
|
287
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
288
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
289
|
+
return 1014 /* Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1 */;
|
|
290
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
291
|
+
return 1015 /* Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1 */;
|
|
292
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
293
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
291
294
|
if (isStatic(parent))
|
|
292
|
-
return
|
|
293
|
-
if (parent.parent.kind ===
|
|
294
|
-
return
|
|
295
|
-
return
|
|
296
|
-
case
|
|
297
|
-
case
|
|
298
|
-
return
|
|
299
|
-
case
|
|
300
|
-
return
|
|
301
|
-
case
|
|
302
|
-
case
|
|
303
|
-
return
|
|
295
|
+
return 1016 /* Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 */;
|
|
296
|
+
if (parent.parent.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
297
|
+
return 1017 /* Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1 */;
|
|
298
|
+
return 1018 /* Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1 */;
|
|
299
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
300
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
301
|
+
return 1019 /* Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1 */;
|
|
302
|
+
case 197 /* SyntaxKind.InferType */:
|
|
303
|
+
return 1084 /* Diagnostics.Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1 */;
|
|
304
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
305
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
306
|
+
return 1082 /* Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1 */;
|
|
304
307
|
}
|
|
305
308
|
throw new Error('This is unknown parent for type parameter');
|
|
306
309
|
}
|
|
307
310
|
// isolatedDeclarations
|
|
308
311
|
function relatedSuggestion(kind) {
|
|
309
312
|
switch (kind) {
|
|
310
|
-
case
|
|
311
|
-
case
|
|
312
|
-
return
|
|
313
|
-
case
|
|
314
|
-
return
|
|
315
|
-
case
|
|
316
|
-
return
|
|
317
|
-
case
|
|
318
|
-
return
|
|
319
|
-
case
|
|
320
|
-
case
|
|
321
|
-
return
|
|
322
|
-
case
|
|
323
|
-
return
|
|
324
|
-
case
|
|
325
|
-
return
|
|
326
|
-
case
|
|
327
|
-
case
|
|
328
|
-
return
|
|
329
|
-
case
|
|
330
|
-
return
|
|
313
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
314
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
315
|
+
return 1814 /* Diagnostics.Add_a_return_type_to_the_function_expression */;
|
|
316
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
317
|
+
return 1818 /* Diagnostics.Add_a_return_type_to_the_method */;
|
|
318
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
319
|
+
return 1816 /* Diagnostics.Add_a_return_type_to_the_get_accessor_declaration */;
|
|
320
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
321
|
+
return 1817 /* Diagnostics.Add_a_type_to_parameter_of_the_set_accessor_declaration */;
|
|
322
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
323
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
324
|
+
return 1815 /* Diagnostics.Add_a_return_type_to_the_function_declaration */;
|
|
325
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
326
|
+
return 1812 /* Diagnostics.Add_a_type_annotation_to_the_parameter_0 */;
|
|
327
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
328
|
+
return 1811 /* Diagnostics.Add_a_type_annotation_to_the_variable_0 */;
|
|
329
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
330
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
331
|
+
return 1813 /* Diagnostics.Add_a_type_annotation_to_the_property_0 */;
|
|
332
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
333
|
+
return 1820 /* Diagnostics.Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it */;
|
|
331
334
|
}
|
|
332
335
|
return undefined;
|
|
333
336
|
}
|
|
334
337
|
function errorByDeclarationKind(kind) {
|
|
335
338
|
switch (kind) {
|
|
336
|
-
case
|
|
337
|
-
case
|
|
338
|
-
case
|
|
339
|
-
return
|
|
340
|
-
case
|
|
341
|
-
case
|
|
342
|
-
return
|
|
343
|
-
case
|
|
344
|
-
case
|
|
345
|
-
return
|
|
346
|
-
case
|
|
347
|
-
return
|
|
348
|
-
case
|
|
349
|
-
return
|
|
350
|
-
case
|
|
351
|
-
case
|
|
352
|
-
return
|
|
353
|
-
case
|
|
354
|
-
return
|
|
355
|
-
case
|
|
356
|
-
return
|
|
357
|
-
case
|
|
358
|
-
return
|
|
359
|
-
case
|
|
360
|
-
return
|
|
361
|
-
case
|
|
362
|
-
return
|
|
363
|
-
case
|
|
364
|
-
return
|
|
339
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
340
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
341
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
342
|
+
return 1792 /* Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations */;
|
|
343
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
344
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
345
|
+
return 1793 /* Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations */;
|
|
346
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
347
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
348
|
+
return 1794 /* Diagnostics.At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations */;
|
|
349
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
350
|
+
return 1796 /* Diagnostics.Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations */;
|
|
351
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
352
|
+
return 1795 /* Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations */;
|
|
353
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
354
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
355
|
+
return 1797 /* Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations */;
|
|
356
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
357
|
+
return 1822 /* Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations */;
|
|
358
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
359
|
+
return 1800 /* Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations */;
|
|
360
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
361
|
+
return 1801 /* Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations */;
|
|
362
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
363
|
+
return 1802 /* Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations */;
|
|
364
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
365
|
+
return 1821 /* Diagnostics.Default_exports_can_t_be_inferred_with_isolatedDeclarations */;
|
|
366
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
367
|
+
return 1803 /* Diagnostics.Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations */;
|
|
365
368
|
}
|
|
366
|
-
return
|
|
369
|
+
return 1798 /* Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations */;
|
|
367
370
|
}
|
|
368
371
|
function related(node, kind, name) {
|
|
369
372
|
const message = relatedSuggestion(kind);
|
|
370
373
|
return message === undefined ? undefined : createDiagnosticForNode(node, message, [name]);
|
|
371
374
|
}
|
|
372
375
|
function isDeclarationEnoughForErrors(node) {
|
|
373
|
-
return (node.kind ===
|
|
376
|
+
return (node.kind === 279 /* SyntaxKind.ExportAssignment */ ||
|
|
374
377
|
isStatement(node) ||
|
|
375
|
-
node.kind ===
|
|
376
|
-
node.kind ===
|
|
377
|
-
node.kind ===
|
|
378
|
+
node.kind === 262 /* SyntaxKind.VariableDeclaration */ ||
|
|
379
|
+
node.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
|
|
380
|
+
node.kind === 171 /* SyntaxKind.Parameter */);
|
|
378
381
|
}
|
|
379
382
|
function findNearestDeclaration(node) {
|
|
380
383
|
let result = node;
|
|
381
384
|
while (result !== undefined && !isDeclarationEnoughForErrors(result))
|
|
382
385
|
result = result.parent;
|
|
383
|
-
if (result === undefined || result.kind ===
|
|
386
|
+
if (result === undefined || result.kind === 279 /* SyntaxKind.ExportAssignment */)
|
|
384
387
|
return result;
|
|
385
|
-
if (result.kind ===
|
|
388
|
+
if (result.kind === 255 /* SyntaxKind.ReturnStatement */) {
|
|
386
389
|
let fn = result;
|
|
387
|
-
while (fn !== undefined && !(isFunctionLikeDeclarationKind(fn.kind) && fn.kind !==
|
|
390
|
+
while (fn !== undefined && !(isFunctionLikeDeclarationKind(fn.kind) && fn.kind !== 178 /* SyntaxKind.Constructor */))
|
|
388
391
|
fn = fn.parent;
|
|
389
392
|
return fn;
|
|
390
393
|
}
|
|
@@ -393,7 +396,7 @@ function findNearestDeclaration(node) {
|
|
|
393
396
|
return result;
|
|
394
397
|
}
|
|
395
398
|
function declarationNameText(declaration) {
|
|
396
|
-
if (declaration.kind ===
|
|
399
|
+
if (declaration.kind === 279 /* SyntaxKind.ExportAssignment */)
|
|
397
400
|
return '';
|
|
398
401
|
const name = getName(declaration);
|
|
399
402
|
return name === undefined ? '' : textOfNode(name);
|
|
@@ -406,10 +409,10 @@ function addParentDeclarationRelatedInfo(node, diagnostic) {
|
|
|
406
409
|
}
|
|
407
410
|
function isOuterExpressionForErrors(node) {
|
|
408
411
|
switch (node.kind) {
|
|
409
|
-
case
|
|
410
|
-
case
|
|
411
|
-
case
|
|
412
|
-
case
|
|
412
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
413
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
414
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
415
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
413
416
|
return true;
|
|
414
417
|
}
|
|
415
418
|
return false;
|
|
@@ -417,12 +420,12 @@ function isOuterExpressionForErrors(node) {
|
|
|
417
420
|
function expressionError(node, message) {
|
|
418
421
|
const declaration = findNearestDeclaration(node);
|
|
419
422
|
if (declaration === undefined)
|
|
420
|
-
return createDiagnosticForNode(node, message ??
|
|
423
|
+
return createDiagnosticForNode(node, message ?? 1798 /* Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations */, []);
|
|
421
424
|
const name = declarationNameText(declaration);
|
|
422
425
|
// The nearest ancestor that isn't a parenthesis or assertion, unless a statement comes first.
|
|
423
426
|
let parent = node.parent;
|
|
424
427
|
while (parent !== undefined) {
|
|
425
|
-
if (parent.kind ===
|
|
428
|
+
if (parent.kind === 279 /* SyntaxKind.ExportAssignment */)
|
|
426
429
|
break;
|
|
427
430
|
if (isStatement(parent)) {
|
|
428
431
|
parent = undefined;
|
|
@@ -436,9 +439,9 @@ function expressionError(node, message) {
|
|
|
436
439
|
const diagnostic = createDiagnosticForNode(node, message ?? errorByDeclarationKind(declaration.kind), []);
|
|
437
440
|
return diagnostic.addRelatedInfo(related(declaration, declaration.kind, name));
|
|
438
441
|
}
|
|
439
|
-
const diagnostic = createDiagnosticForNode(node, message ??
|
|
442
|
+
const diagnostic = createDiagnosticForNode(node, message ?? 1798 /* Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations */, []);
|
|
440
443
|
diagnostic.addRelatedInfo(related(declaration, declaration.kind, name));
|
|
441
|
-
return diagnostic.addRelatedInfo(createDiagnosticForNode(node,
|
|
444
|
+
return diagnostic.addRelatedInfo(createDiagnosticForNode(node, 1819 /* Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit */, []));
|
|
442
445
|
}
|
|
443
446
|
function accessorTypeError(node) {
|
|
444
447
|
const accessors = getAllAccessorDeclarations(node);
|
|
@@ -448,63 +451,63 @@ function accessorTypeError(node) {
|
|
|
448
451
|
: node;
|
|
449
452
|
const diagnostic = createDiagnosticForNode(target, errorByDeclarationKind(node.kind), []);
|
|
450
453
|
if (accessors.setAccessor !== undefined)
|
|
451
|
-
diagnostic.addRelatedInfo(related(accessors.setAccessor,
|
|
454
|
+
diagnostic.addRelatedInfo(related(accessors.setAccessor, 180 /* SyntaxKind.SetAccessor */, ''));
|
|
452
455
|
if (accessors.getAccessor !== undefined)
|
|
453
|
-
diagnostic.addRelatedInfo(related(accessors.getAccessor,
|
|
456
|
+
diagnostic.addRelatedInfo(related(accessors.getAccessor, 179 /* SyntaxKind.GetAccessor */, ''));
|
|
454
457
|
return diagnostic;
|
|
455
458
|
}
|
|
456
459
|
/** The isolatedDeclarations error for a type that needs inference at `node`. */
|
|
457
460
|
export function createIsolatedDeclarationError(node, requiresAddingUndefined) {
|
|
458
461
|
for (let current = node; current !== undefined; current = current.parent)
|
|
459
|
-
if (current.kind ===
|
|
460
|
-
return createDiagnosticForNode(node,
|
|
461
|
-
if (
|
|
462
|
-
return addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node,
|
|
462
|
+
if (current.kind === 300 /* SyntaxKind.HeritageClause */)
|
|
463
|
+
return createDiagnosticForNode(node, 1806 /* Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations */, []);
|
|
464
|
+
if (isPartOfTypeNode(node) || node.kind === 188 /* SyntaxKind.TypeQuery */ || isEntityNameExpression(node, false))
|
|
465
|
+
return addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node, 1823 /* Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations */, [textOfNode(node)]));
|
|
463
466
|
switch (node.kind) {
|
|
464
|
-
case
|
|
465
|
-
return addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node,
|
|
466
|
-
case
|
|
467
|
-
case
|
|
467
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
468
|
+
return addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node, 1823 /* Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations */, [textOfNode(node)]));
|
|
469
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
470
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
468
471
|
return accessorTypeError(node);
|
|
469
|
-
case
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
case
|
|
473
|
-
case
|
|
472
|
+
case 169 /* SyntaxKind.ComputedPropertyName */:
|
|
473
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
474
|
+
case 306 /* SyntaxKind.SpreadAssignment */:
|
|
475
|
+
case 211 /* SyntaxKind.ArrayLiteralExpression */:
|
|
476
|
+
case 232 /* SyntaxKind.SpreadElement */:
|
|
474
477
|
return addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node, errorByDeclarationKind(node.kind), []));
|
|
475
|
-
case
|
|
476
|
-
case
|
|
477
|
-
case
|
|
478
|
-
case
|
|
479
|
-
case
|
|
478
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
479
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
480
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
481
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
482
|
+
case 264 /* SyntaxKind.FunctionDeclaration */: {
|
|
480
483
|
const diagnostic = addParentDeclarationRelatedInfo(node, createDiagnosticForNode(node, errorByDeclarationKind(node.kind), []));
|
|
481
484
|
return diagnostic.addRelatedInfo(related(node, node.kind, ''));
|
|
482
485
|
}
|
|
483
|
-
case
|
|
484
|
-
return createDiagnosticForNode(node,
|
|
485
|
-
case
|
|
486
|
-
case
|
|
486
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
487
|
+
return createDiagnosticForNode(node, 1804 /* Diagnostics.Binding_elements_with_initializers_can_t_be_exported_directly_with_isolatedDeclarations */, []);
|
|
488
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
489
|
+
case 262 /* SyntaxKind.VariableDeclaration */: {
|
|
487
490
|
const diagnostic = createDiagnosticForNode(node, errorByDeclarationKind(node.kind), []);
|
|
488
491
|
const name = getName(node);
|
|
489
492
|
return diagnostic.addRelatedInfo(related(node, node.kind, name === undefined ? '' : textOfNode(name)));
|
|
490
493
|
}
|
|
491
|
-
case
|
|
494
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
492
495
|
return parameterError(node, requiresAddingUndefined);
|
|
493
|
-
case
|
|
496
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
494
497
|
return expressionError(getInitializer(node), undefined);
|
|
495
|
-
case
|
|
496
|
-
return expressionError(node,
|
|
498
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
499
|
+
return expressionError(node, 1807 /* Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations */);
|
|
497
500
|
}
|
|
498
501
|
return expressionError(node, undefined);
|
|
499
502
|
}
|
|
500
503
|
function parameterError(node, requiresAddingUndefined) {
|
|
501
|
-
if (node.parent !== undefined && node.parent.kind ===
|
|
504
|
+
if (node.parent !== undefined && node.parent.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
502
505
|
return accessorTypeError(node.parent);
|
|
503
506
|
const initializer = getInitializer(node);
|
|
504
507
|
if (!requiresAddingUndefined && initializer !== undefined)
|
|
505
508
|
return expressionError(initializer, undefined);
|
|
506
509
|
const message = requiresAddingUndefined
|
|
507
|
-
?
|
|
510
|
+
? 1809 /* Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_supported_with_isolatedDeclarations */
|
|
508
511
|
: errorByDeclarationKind(node.kind);
|
|
509
512
|
const diagnostic = createDiagnosticForNode(node, message, []);
|
|
510
513
|
const name = node instanceof ParameterDeclaration ? textOfNode(node.name) : '';
|
|
@@ -524,7 +527,7 @@ export class AllAccessorDeclarations {
|
|
|
524
527
|
}
|
|
525
528
|
/** The get and set accessors declaring the same property as `accessor`. */
|
|
526
529
|
export function getAllAccessorDeclarations(accessor) {
|
|
527
|
-
const otherKind = accessor.kind ===
|
|
530
|
+
const otherKind = accessor.kind === 180 /* SyntaxKind.SetAccessor */ ? 179 /* SyntaxKind.GetAccessor */ : 180 /* SyntaxKind.SetAccessor */;
|
|
528
531
|
let other = undefined;
|
|
529
532
|
const symbol = getSymbol(accessor);
|
|
530
533
|
if (symbol !== undefined)
|
|
@@ -534,6 +537,6 @@ export function getAllAccessorDeclarations(accessor) {
|
|
|
534
537
|
break;
|
|
535
538
|
}
|
|
536
539
|
const otherFirst = other !== undefined && other.pos < accessor.pos;
|
|
537
|
-
const isSet = accessor.kind ===
|
|
540
|
+
const isSet = accessor.kind === 180 /* SyntaxKind.SetAccessor */;
|
|
538
541
|
return new AllAccessorDeclarations(otherFirst ? other : accessor, otherFirst ? accessor : other, isSet ? other : accessor, isSet ? accessor : other);
|
|
539
542
|
}
|