tsc-ts 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +20 -15
- package/dist/api/compiler/ast.js +1023 -995
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +173 -123
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +134 -90
- package/dist/api/compiler/checker-contextual.js +64 -61
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +244 -211
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +469 -438
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -113
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +105 -88
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +210 -74
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +137 -34
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +93 -31
- package/dist/api/compiler/checker.js +143 -35
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +19 -4
- package/dist/api/compiler/compile-program.js +45 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +23 -23
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parser.d.ts +40 -19
- package/dist/api/compiler/parser.js +308 -216
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +3 -1
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +1 -0
- package/dist/api/compiler/printer/printer.js +303 -281
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +2 -0
- package/dist/api/compiler/program.js +69 -57
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +337 -180
- package/dist/api/compiler/reparser.js +60 -56
- package/dist/api/compiler/scanner.d.ts +19 -2
- package/dist/api/compiler/scanner.js +123 -108
- package/dist/api/compiler/shared-results.d.ts +463 -0
- package/dist/api/compiler/shared-results.js +2128 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +305 -238
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +55 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +78 -24
- package/src/compiler/checker-contextual.ts +6 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +79 -46
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +26 -4
- package/src/compiler/checker-members.ts +197 -55
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +120 -21
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +168 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +51 -25
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +86 -18
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +3 -1
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +197 -8
- package/src/compiler/parallel-emit.ts +1 -1
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +4 -1
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +35 -14
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -77
- package/src/compiler/reparser.ts +7 -2
- package/src/compiler/scanner.ts +109 -79
- package/src/compiler/shared-results.ts +2414 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +19 -2
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +134 -48
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +3 -0
- package/src/compiler/tsc-cli.ts +2 -0
- package/src/compiler/tsc-compile.ts +7 -2
- package/src/compiler/tsc-watch.ts +74 -45
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -71,16 +71,16 @@ class OverloadChecker {
|
|
|
71
71
|
const parent = node.parent;
|
|
72
72
|
const inAmbientContextOrInterface = inAmbientContext ||
|
|
73
73
|
(parent !== undefined &&
|
|
74
|
-
(parent.kind ===
|
|
74
|
+
(parent.kind === 266 /* SyntaxKind.InterfaceDeclaration */ || parent.kind === 189 /* SyntaxKind.TypeLiteral */));
|
|
75
75
|
// Only non-ambient declarations must be consecutive.
|
|
76
76
|
if (inAmbientContextOrInterface)
|
|
77
77
|
previousDeclaration = undefined;
|
|
78
78
|
if (isClassLike(node) && !inAmbientContext)
|
|
79
79
|
hasNonAmbientClass = true;
|
|
80
|
-
if (node.kind !==
|
|
81
|
-
node.kind !==
|
|
82
|
-
node.kind !==
|
|
83
|
-
node.kind !==
|
|
80
|
+
if (node.kind !== 264 /* SyntaxKind.FunctionDeclaration */ &&
|
|
81
|
+
node.kind !== 176 /* SyntaxKind.MethodDeclaration */ &&
|
|
82
|
+
node.kind !== 175 /* SyntaxKind.MethodSignature */ &&
|
|
83
|
+
node.kind !== 178 /* SyntaxKind.Constructor */)
|
|
84
84
|
continue;
|
|
85
85
|
functionDeclarations.push(node);
|
|
86
86
|
const currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck());
|
|
@@ -113,10 +113,10 @@ class OverloadChecker {
|
|
|
113
113
|
}
|
|
114
114
|
if (multipleConstructorImplementation)
|
|
115
115
|
for (const d of functionDeclarations)
|
|
116
|
-
c.error(d,
|
|
116
|
+
c.error(d, 570 /* Diagnostics.Multiple_constructor_implementations_are_not_allowed */);
|
|
117
117
|
if (duplicateFunctionDeclaration)
|
|
118
118
|
for (const d of functionDeclarations)
|
|
119
|
-
c.error(getNameOfDeclaration(d) ?? d,
|
|
119
|
+
c.error(getNameOfDeclaration(d) ?? d, 571 /* Diagnostics.Duplicate_function_implementation */);
|
|
120
120
|
if (hasNonAmbientClass &&
|
|
121
121
|
!this.isConstructor &&
|
|
122
122
|
(this.symbol.flags & 16 /* SymbolFlags.Function */) !== 0 &&
|
|
@@ -135,7 +135,7 @@ class OverloadChecker {
|
|
|
135
135
|
const canonical = isOptionalDeclaration(getCanonicalOverload(declarations, bodyDeclaration));
|
|
136
136
|
for (const d of declarations)
|
|
137
137
|
if (isOptionalDeclaration(d) !== canonical)
|
|
138
|
-
c.error(getNameOfDeclaration(d),
|
|
138
|
+
c.error(getNameOfDeclaration(d), 564 /* Diagnostics.Overload_signatures_must_all_be_optional_or_required */);
|
|
139
139
|
}
|
|
140
140
|
if (bodyDeclaration === undefined)
|
|
141
141
|
return;
|
|
@@ -143,7 +143,7 @@ class OverloadChecker {
|
|
|
143
143
|
for (const signature of getSignaturesOfSymbol(c, this.symbol)) {
|
|
144
144
|
if (isImplementationCompatibleWithOverload(c, bodySignature, signature))
|
|
145
145
|
continue;
|
|
146
|
-
c.error(signature.declaration,
|
|
146
|
+
c.error(signature.declaration, 572 /* Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature */).addRelatedInfo(createDiagnosticForNode(bodyDeclaration, 889 /* Diagnostics.The_implementation_signature_is_declared_here */, []));
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -151,19 +151,19 @@ class OverloadChecker {
|
|
|
151
151
|
const c = this.c;
|
|
152
152
|
const classes = [];
|
|
153
153
|
for (const d of getDeclarations(this.symbol))
|
|
154
|
-
if (d.kind ===
|
|
154
|
+
if (d.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
155
155
|
classes.push(d);
|
|
156
156
|
for (const d of getDeclarations(this.symbol)) {
|
|
157
157
|
let message;
|
|
158
|
-
if (d.kind ===
|
|
159
|
-
message =
|
|
160
|
-
else if (d.kind ===
|
|
161
|
-
message =
|
|
158
|
+
if (d.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
159
|
+
message = 951 /* Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 */;
|
|
160
|
+
else if (d.kind === 264 /* SyntaxKind.FunctionDeclaration */)
|
|
161
|
+
message = 952 /* Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient */;
|
|
162
162
|
else
|
|
163
163
|
continue;
|
|
164
164
|
const err = c.error(getNameOfDeclaration(d) ?? d, message, this.symbol.name);
|
|
165
165
|
for (const r of classes)
|
|
166
|
-
err.addRelatedInfo(createDiagnosticForNode(r,
|
|
166
|
+
err.addRelatedInfo(createDiagnosticForNode(r, 1532 /* Diagnostics.Consider_adding_a_declare_modifier_to_this_class */, []));
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
checkFlagAgreement(overloads, implementation, someOverloadFlags, allOverloadFlags) {
|
|
@@ -190,13 +190,13 @@ class OverloadChecker {
|
|
|
190
190
|
const deviation = flags ^ canonicalFlags;
|
|
191
191
|
const deviationInFile = flags ^ canonicalFlagsForFile;
|
|
192
192
|
if ((deviationInFile & 32 /* ModifierFlags.Export */) !== 0)
|
|
193
|
-
c.error(getNameOfDeclaration(o),
|
|
193
|
+
c.error(getNameOfDeclaration(o), 561 /* Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported */);
|
|
194
194
|
else if ((deviationInFile & 128 /* ModifierFlags.Ambient */) !== 0)
|
|
195
|
-
c.error(getNameOfDeclaration(o),
|
|
195
|
+
c.error(getNameOfDeclaration(o), 562 /* Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient */);
|
|
196
196
|
else if ((deviation & (2 /* ModifierFlags.Private */ | 4 /* ModifierFlags.Protected */)) !== 0)
|
|
197
|
-
c.error(getNameOfDeclaration(o) ?? o,
|
|
197
|
+
c.error(getNameOfDeclaration(o) ?? o, 563 /* Diagnostics.Overload_signatures_must_all_be_public_private_or_protected */);
|
|
198
198
|
else if ((deviation & 64 /* ModifierFlags.Abstract */) !== 0)
|
|
199
|
-
c.error(getNameOfDeclaration(o),
|
|
199
|
+
c.error(getNameOfDeclaration(o), 679 /* Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract */);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
@@ -212,25 +212,25 @@ class OverloadChecker {
|
|
|
212
212
|
const errorNode = subsequentName ?? subsequentNode;
|
|
213
213
|
if (name !== undefined && subsequentName !== undefined && isSameMemberName(c, name, subsequentName)) {
|
|
214
214
|
// Mixed static and instance members; other conflicts are reported by the binder.
|
|
215
|
-
if ((node.kind ===
|
|
215
|
+
if ((node.kind === 176 /* SyntaxKind.MethodDeclaration */ || node.kind === 175 /* SyntaxKind.MethodSignature */) &&
|
|
216
216
|
isStatic(node) !== isStatic(subsequentNode))
|
|
217
217
|
c.error(errorNode, isStatic(node)
|
|
218
|
-
?
|
|
219
|
-
:
|
|
218
|
+
? 565 /* Diagnostics.Function_overload_must_be_static */
|
|
219
|
+
: 566 /* Diagnostics.Function_overload_must_not_be_static */);
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
if (nodeIsPresent(getBody(subsequentNode))) {
|
|
223
|
-
c.error(errorNode,
|
|
223
|
+
c.error(errorNode, 567 /* Diagnostics.Function_implementation_name_must_be_0 */, declarationNameToString(getSourceFileOfNode(node), name));
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
const errorNode = name ?? node;
|
|
228
228
|
if (this.isConstructor)
|
|
229
|
-
c.error(errorNode,
|
|
229
|
+
c.error(errorNode, 568 /* Diagnostics.Constructor_implementation_is_missing */);
|
|
230
230
|
else if (hasSyntacticModifier(node, 64 /* ModifierFlags.Abstract */))
|
|
231
|
-
c.error(errorNode,
|
|
231
|
+
c.error(errorNode, 683 /* Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive */);
|
|
232
232
|
else
|
|
233
|
-
c.error(errorNode,
|
|
233
|
+
c.error(errorNode, 569 /* Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration */);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
@@ -253,7 +253,7 @@ function getNextSibling(node) {
|
|
|
253
253
|
function isSameMemberName(c, name, other) {
|
|
254
254
|
if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */ && other.kind === 80 /* SyntaxKind.PrivateIdentifier */)
|
|
255
255
|
return getText(name) === getText(other);
|
|
256
|
-
if (name.kind ===
|
|
256
|
+
if (name.kind === 169 /* SyntaxKind.ComputedPropertyName */ && other.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
257
257
|
return isTypeIdenticalTo(c, checkComputedPropertyName(c, name), checkComputedPropertyName(c, other));
|
|
258
258
|
return isPropertyNameLiteral(name) && isPropertyNameLiteral(other) && getText(name) === getText(other);
|
|
259
259
|
}
|
|
@@ -50,13 +50,13 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
50
50
|
if (assignmentKind !== 0 /* AssignmentKind.None */ &&
|
|
51
51
|
lexicallyScopedSymbol !== undefined &&
|
|
52
52
|
lexicallyScopedSymbol.valueDeclaration !== undefined &&
|
|
53
|
-
lexicallyScopedSymbol.valueDeclaration.kind ===
|
|
54
|
-
grammarErrorOnNode(c, right,
|
|
53
|
+
lexicallyScopedSymbol.valueDeclaration.kind === 176 /* SyntaxKind.MethodDeclaration */)
|
|
54
|
+
grammarErrorOnNode(c, right, 942 /* Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable */, name);
|
|
55
55
|
if (isAnyLike) {
|
|
56
56
|
if (lexicallyScopedSymbol !== undefined)
|
|
57
57
|
return isErrorType(c, apparentType) ? c.errorType : apparentType;
|
|
58
58
|
if (getContainingClassExcludingClassDecorators(right) === undefined) {
|
|
59
|
-
grammarErrorOnNode(c, right,
|
|
59
|
+
grammarErrorOnNode(c, right, 1858 /* Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies */);
|
|
60
60
|
return c.anyType;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -70,7 +70,7 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
70
70
|
else if ((prop.flags & 65536 /* SymbolFlags.SetAccessor */) !== 0 &&
|
|
71
71
|
(prop.flags & 32768 /* SymbolFlags.GetAccessor */) === 0 &&
|
|
72
72
|
assignmentKind !== 1 /* AssignmentKind.Definite */)
|
|
73
|
-
c.error(node,
|
|
73
|
+
c.error(node, 944 /* Diagnostics.Private_accessor_was_defined_without_a_getter */);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
if (isAnyLike) {
|
|
@@ -78,7 +78,7 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
78
78
|
markPropertyAliasReferenced(c, node, undefined, leftType);
|
|
79
79
|
return isErrorType(c, apparentType) ? c.errorType : apparentType;
|
|
80
80
|
}
|
|
81
|
-
prop = getPropertyOfTypeEx(c, apparentType, name, isConstEnumObjectType(apparentType), node.kind ===
|
|
81
|
+
prop = getPropertyOfTypeEx(c, apparentType, name, isConstEnumObjectType(apparentType), node.kind === 168 /* SyntaxKind.QualifiedName */);
|
|
82
82
|
}
|
|
83
83
|
markPropertyAliasReferenced(c, node, prop, leftType);
|
|
84
84
|
let propType;
|
|
@@ -93,23 +93,27 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
93
93
|
if (leftType.symbol === c.globalThisSymbol) {
|
|
94
94
|
const globalSymbol = c.globalThisSymbol.exports?.get(name);
|
|
95
95
|
if (globalSymbol !== undefined && (globalSymbol.flags & 418 /* SymbolFlags.BlockScoped */) !== 0)
|
|
96
|
-
c.error(right,
|
|
96
|
+
c.error(right, 523 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, name, typeToString(c, leftType));
|
|
97
97
|
else if (c.noImplicitAny)
|
|
98
|
-
c.error(right,
|
|
98
|
+
c.error(right, 1708 /* Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature */, typeToString(c, leftType));
|
|
99
99
|
return c.anyType;
|
|
100
100
|
}
|
|
101
|
-
if (name !== '')
|
|
102
|
-
|
|
101
|
+
if (name !== '') {
|
|
102
|
+
// Deferred, since printing the containing type can resolve it completely, and report circularities
|
|
103
|
+
// while it is being resolved.
|
|
104
|
+
const containingType = isThisTypeParameter(leftType) ? apparentType : leftType;
|
|
105
|
+
c.deferDiagnostic(right, () => reportNonexistentProperty(c, right, containingType));
|
|
106
|
+
}
|
|
103
107
|
return c.errorType;
|
|
104
108
|
}
|
|
105
109
|
if (indexInfo.isReadonly && (assignmentKind !== 0 /* AssignmentKind.None */ || isDeleteTarget(node)))
|
|
106
|
-
c.error(node,
|
|
110
|
+
c.error(node, 705 /* Diagnostics.Index_signature_in_type_0_only_permits_reading */, typeToString(c, apparentType));
|
|
107
111
|
propType = indexInfo.valueType;
|
|
108
112
|
if (c.noUncheckedIndexedAccess && assignmentKind !== 1 /* AssignmentKind.Definite */)
|
|
109
113
|
propType = getUnionType(c, [propType, c.missingType]);
|
|
110
114
|
if (c.compilerOptions.noPropertyAccessFromIndexSignature === true &&
|
|
111
|
-
node.kind ===
|
|
112
|
-
c.error(right,
|
|
115
|
+
node.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
116
|
+
c.error(right, 1104 /* Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0 */, name);
|
|
113
117
|
checkDeprecatedIndexSignature(c, right, indexInfo.declaration);
|
|
114
118
|
}
|
|
115
119
|
else {
|
|
@@ -121,7 +125,7 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
121
125
|
c.resolvedSymbols.set(node.id, prop);
|
|
122
126
|
checkPropertyAccessibility(c, node, left.kind === 107 /* SyntaxKind.SuperKeyword */, assignmentKind !== 0 /* AssignmentKind.None */, apparentType, prop);
|
|
123
127
|
if (isAssignmentToReadonlyEntity(c, node, prop, assignmentKind)) {
|
|
124
|
-
c.error(right,
|
|
128
|
+
c.error(right, 704 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property */, name);
|
|
125
129
|
return c.errorType;
|
|
126
130
|
}
|
|
127
131
|
if (isThisPropertyAccessInConstructor(c, node, prop))
|
|
@@ -136,15 +140,15 @@ export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, left
|
|
|
136
140
|
}
|
|
137
141
|
/** Whether `node` is a property of an object destructuring assignment from `this`. */
|
|
138
142
|
function isThisInitializedObjectBindingExpression(node) {
|
|
139
|
-
if (node.kind !==
|
|
143
|
+
if (node.kind !== 305 /* SyntaxKind.ShorthandPropertyAssignment */ && node.kind !== 304 /* SyntaxKind.PropertyAssignment */)
|
|
140
144
|
return false;
|
|
141
145
|
const binary = node.parent.parent;
|
|
142
|
-
return (binary.kind ===
|
|
146
|
+
return (binary.kind === 228 /* SyntaxKind.BinaryExpression */ &&
|
|
143
147
|
binary.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ &&
|
|
144
148
|
binary.right.kind === 109 /* SyntaxKind.ThisKeyword */);
|
|
145
149
|
}
|
|
146
150
|
function isThisInitializedDeclaration(node) {
|
|
147
|
-
if (node.kind !==
|
|
151
|
+
if (node.kind !== 262 /* SyntaxKind.VariableDeclaration */)
|
|
148
152
|
return false;
|
|
149
153
|
const initializer = getInitializer(node);
|
|
150
154
|
return initializer !== undefined && initializer.kind === 109 /* SyntaxKind.ThisKeyword */;
|
|
@@ -183,7 +187,7 @@ function getContainingClassExcludingClassDecorators(node) {
|
|
|
183
187
|
for (let current = node.parent; current !== undefined; current = current.parent) {
|
|
184
188
|
if (isClassLike(current))
|
|
185
189
|
break;
|
|
186
|
-
if (current.kind ===
|
|
190
|
+
if (current.kind === 172 /* SyntaxKind.Decorator */) {
|
|
187
191
|
if (current.parent !== undefined && isClassLike(current.parent))
|
|
188
192
|
return getContainingClass(current.parent);
|
|
189
193
|
break;
|
|
@@ -215,15 +219,15 @@ function checkPrivateIdentifierPropertyAccess(c, leftType, right, lexicallyScope
|
|
|
215
219
|
for (let n = getContainingClass(lexicalValueDecl); n !== undefined; n = n.parent) {
|
|
216
220
|
if (n !== typeClass)
|
|
217
221
|
continue;
|
|
218
|
-
const diagnostic = c.error(right,
|
|
219
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(lexicalValueDecl,
|
|
222
|
+
const diagnostic = c.error(right, 1856 /* Diagnostics.The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling */, diagName, typeToString(c, leftType));
|
|
223
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(lexicalValueDecl, 1859 /* Diagnostics.The_shadowing_declaration_of_0_is_defined_here */, [
|
|
220
224
|
diagName,
|
|
221
225
|
]));
|
|
222
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(typeValueDecl,
|
|
226
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(typeValueDecl, 1860 /* Diagnostics.The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here */, [diagName]));
|
|
223
227
|
return true;
|
|
224
228
|
}
|
|
225
229
|
}
|
|
226
|
-
c.error(right,
|
|
230
|
+
c.error(right, 1855 /* Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier */, diagName, symbolToString(c, getSymbol(typeClass)));
|
|
227
231
|
return true;
|
|
228
232
|
}
|
|
229
233
|
function isThisTypeParameter(t) {
|
|
@@ -236,10 +240,10 @@ function isConstEnumObjectType(t) {
|
|
|
236
240
|
}
|
|
237
241
|
export function isMethodAccessForCall(node) {
|
|
238
242
|
let current = node;
|
|
239
|
-
while (current.parent.kind ===
|
|
243
|
+
while (current.parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
240
244
|
current = current.parent;
|
|
241
245
|
const parent = current.parent;
|
|
242
|
-
return ((parent.kind ===
|
|
246
|
+
return ((parent.kind === 215 /* SyntaxKind.CallExpression */ || parent.kind === 216 /* SyntaxKind.NewExpression */) &&
|
|
243
247
|
getExpression(parent) === current);
|
|
244
248
|
}
|
|
245
249
|
/** Whether `node` is the operand of `delete`, through parentheses. */
|
|
@@ -247,9 +251,9 @@ export function isDeleteTarget(node) {
|
|
|
247
251
|
if (!isAccessExpression(node))
|
|
248
252
|
return false;
|
|
249
253
|
let current = node.parent;
|
|
250
|
-
while (current.kind ===
|
|
254
|
+
while (current.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
251
255
|
current = current.parent;
|
|
252
|
-
return current.kind ===
|
|
256
|
+
return current.kind === 222 /* SyntaxKind.DeleteExpression */;
|
|
253
257
|
}
|
|
254
258
|
/** Whether assigning through `expr` targets a readonly entity, outside of initialization. */
|
|
255
259
|
export function isAssignmentToReadonlyEntity(c, expr, symbol, assignmentKind) {
|
|
@@ -267,14 +271,14 @@ export function isAssignmentToReadonlyEntity(c, expr, symbol, assignmentKind) {
|
|
|
267
271
|
isAccessExpression(expr) &&
|
|
268
272
|
getExpression(expr).kind === 109 /* SyntaxKind.ThisKeyword */) {
|
|
269
273
|
const ctor = getControlFlowContainer(expr);
|
|
270
|
-
if (ctor.kind !==
|
|
274
|
+
if (ctor.kind !== 178 /* SyntaxKind.Constructor */)
|
|
271
275
|
return true;
|
|
272
276
|
const declaration = symbol.valueDeclaration;
|
|
273
277
|
if (declaration !== undefined) {
|
|
274
278
|
const isLocalPropertyDeclaration = ctor.parent === declaration.parent;
|
|
275
279
|
const isLocalParameterProperty = ctor === declaration.parent;
|
|
276
280
|
// A JavaScript `this.x = …` declaration of this class or constructor function.
|
|
277
|
-
const isAssignmentDeclaration = declaration.kind ===
|
|
281
|
+
const isAssignmentDeclaration = declaration.kind === 228 /* SyntaxKind.BinaryExpression */;
|
|
278
282
|
const parentDeclaration = symbol.parent?.valueDeclaration;
|
|
279
283
|
const isLocalThisPropertyAssignment = isAssignmentDeclaration && (parentDeclaration === ctor.parent || parentDeclaration === ctor);
|
|
280
284
|
return !isLocalPropertyDeclaration && !isLocalParameterProperty && !isLocalThisPropertyAssignment;
|
|
@@ -289,7 +293,7 @@ export function isAssignmentToReadonlyEntity(c, expr, symbol, assignmentKind) {
|
|
|
289
293
|
const expressionSymbol = getResolvedSymbol(c, node);
|
|
290
294
|
if ((expressionSymbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0) {
|
|
291
295
|
const declaration = getDeclarationOfAliasSymbol(expressionSymbol);
|
|
292
|
-
return declaration !== undefined && declaration.kind ===
|
|
296
|
+
return declaration !== undefined && declaration.kind === 276 /* SyntaxKind.NamespaceImport */;
|
|
293
297
|
}
|
|
294
298
|
}
|
|
295
299
|
}
|
|
@@ -299,13 +303,13 @@ export function isAssignmentToReadonlyEntity(c, expr, symbol, assignmentKind) {
|
|
|
299
303
|
/** Checks that `prop` of `containingType` may be accessed at `node`; reports and returns false otherwise. */
|
|
300
304
|
export function checkPropertyAccessibility(c, node, isSuper, writing, containingType, prop) {
|
|
301
305
|
let errorNode;
|
|
302
|
-
if (node.kind ===
|
|
306
|
+
if (node.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
303
307
|
errorNode = node.name;
|
|
304
|
-
else if (node.kind ===
|
|
308
|
+
else if (node.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
305
309
|
errorNode = node.right;
|
|
306
|
-
else if (node.kind ===
|
|
310
|
+
else if (node.kind === 207 /* SyntaxKind.ImportType */)
|
|
307
311
|
errorNode = node;
|
|
308
|
-
else if (node.kind ===
|
|
312
|
+
else if (node.kind === 210 /* SyntaxKind.BindingElement */)
|
|
309
313
|
errorNode = node.propertyName ?? node.name;
|
|
310
314
|
else
|
|
311
315
|
errorNode = getName(node) ?? node;
|
|
@@ -329,13 +333,13 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
329
333
|
// Abstract methods can't be reached through `super`.
|
|
330
334
|
if ((flags & 64 /* ModifierFlags.Abstract */) !== 0) {
|
|
331
335
|
if (errorNode !== undefined)
|
|
332
|
-
c.error(errorNode,
|
|
336
|
+
c.error(errorNode, 680 /* Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop)));
|
|
333
337
|
return false;
|
|
334
338
|
}
|
|
335
339
|
// Class fields of the parent aren't on the prototype.
|
|
336
340
|
if ((flags & 256 /* ModifierFlags.Static */) === 0 && hasClassInstancePropertyDeclaration(prop)) {
|
|
337
341
|
if (errorNode !== undefined)
|
|
338
|
-
c.error(errorNode,
|
|
342
|
+
c.error(errorNode, 982 /* Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super */, symbolToString(c, prop));
|
|
339
343
|
return false;
|
|
340
344
|
}
|
|
341
345
|
}
|
|
@@ -344,14 +348,14 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
344
348
|
symbolHasNonMethodDeclaration(c, prop) &&
|
|
345
349
|
(isThisProperty(location) ||
|
|
346
350
|
isThisInitializedObjectBindingExpression(location) ||
|
|
347
|
-
(location.parent.kind ===
|
|
351
|
+
(location.parent.kind === 208 /* SyntaxKind.ObjectBindingPattern */ &&
|
|
348
352
|
isThisInitializedDeclaration(location.parent.parent)))) {
|
|
349
353
|
const parentSymbol = getParentOfSymbol(c, prop);
|
|
350
354
|
if (parentSymbol !== undefined &&
|
|
351
355
|
(parentSymbol.flags & 32 /* SymbolFlags.Class */) !== 0 &&
|
|
352
356
|
isNodeUsedDuringClassInitialization(location)) {
|
|
353
357
|
if (errorNode !== undefined)
|
|
354
|
-
c.error(errorNode,
|
|
358
|
+
c.error(errorNode, 854 /* Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor */, symbolToString(c, prop), symbolToString(c, parentSymbol));
|
|
355
359
|
return false;
|
|
356
360
|
}
|
|
357
361
|
}
|
|
@@ -363,7 +367,7 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
363
367
|
const declaringClassDeclaration = parent !== undefined ? getClassLikeDeclarationOfSymbol(parent) : undefined;
|
|
364
368
|
if (!isNodeWithinClass(location, declaringClassDeclaration)) {
|
|
365
369
|
if (errorNode !== undefined)
|
|
366
|
-
c.error(errorNode,
|
|
370
|
+
c.error(errorNode, 525 /* Diagnostics.Property_0_is_private_and_only_accessible_within_class_1 */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop) ?? containingTypeIn));
|
|
367
371
|
return false;
|
|
368
372
|
}
|
|
369
373
|
return true;
|
|
@@ -390,7 +394,7 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
390
394
|
enclosingClass = thisClass;
|
|
391
395
|
if ((flags & 256 /* ModifierFlags.Static */) !== 0 || enclosingClass === undefined) {
|
|
392
396
|
if (errorNode !== undefined)
|
|
393
|
-
c.error(errorNode,
|
|
397
|
+
c.error(errorNode, 620 /* Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop) ?? containingTypeIn));
|
|
394
398
|
return false;
|
|
395
399
|
}
|
|
396
400
|
}
|
|
@@ -403,7 +407,7 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
403
407
|
: getBaseConstraintOfType(c, containingType);
|
|
404
408
|
if (containingType === undefined || !hasBaseType(c, containingType, enclosingClass)) {
|
|
405
409
|
if (containingType !== undefined && errorNode !== undefined)
|
|
406
|
-
c.error(errorNode,
|
|
410
|
+
c.error(errorNode, 621 /* Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2 */, symbolToString(c, prop), typeToString(c, enclosingClass), typeToString(c, containingType));
|
|
407
411
|
return false;
|
|
408
412
|
}
|
|
409
413
|
return true;
|
|
@@ -423,7 +427,7 @@ function isClassInstanceProperty(node) {
|
|
|
423
427
|
}
|
|
424
428
|
return (node.parent !== undefined &&
|
|
425
429
|
isClassLike(node.parent) &&
|
|
426
|
-
node.kind ===
|
|
430
|
+
node.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
|
|
427
431
|
!isStatic(node) &&
|
|
428
432
|
!hasSyntacticModifier(node, 512 /* ModifierFlags.Accessor */));
|
|
429
433
|
}
|
|
@@ -438,8 +442,8 @@ function isThisProperty(node) {
|
|
|
438
442
|
}
|
|
439
443
|
function isNodeUsedDuringClassInitialization(node) {
|
|
440
444
|
for (let element = node.parent; element !== undefined; element = element.parent) {
|
|
441
|
-
if ((element.kind ===
|
|
442
|
-
element.kind ===
|
|
445
|
+
if ((element.kind === 178 /* SyntaxKind.Constructor */ && getBody(element) !== undefined) ||
|
|
446
|
+
element.kind === 174 /* SyntaxKind.PropertyDeclaration */)
|
|
443
447
|
return true;
|
|
444
448
|
if (isClassLike(element) || isFunctionLike(element))
|
|
445
449
|
return false;
|
|
@@ -537,7 +541,7 @@ export function reportNonexistentProperty(c, propNode, containingType) {
|
|
|
537
541
|
for (const subtype of typesOf(containingType)) {
|
|
538
542
|
if (getPropertyOfType(c, subtype, name) === undefined &&
|
|
539
543
|
getApplicableIndexInfoForName(c, subtype, name) === undefined) {
|
|
540
|
-
chain = createDiagnosticForNode(propNode,
|
|
544
|
+
chain = createDiagnosticForNode(propNode, 523 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [
|
|
541
545
|
missingProperty,
|
|
542
546
|
typeToString(c, subtype),
|
|
543
547
|
]);
|
|
@@ -547,35 +551,35 @@ export function reportNonexistentProperty(c, propNode, containingType) {
|
|
|
547
551
|
}
|
|
548
552
|
let diagnostic;
|
|
549
553
|
if (typeHasStaticProperty(c, name, containingType))
|
|
550
|
-
diagnostic = createDiagnosticForNode(propNode,
|
|
554
|
+
diagnostic = createDiagnosticForNode(propNode, 734 /* Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead */, [missingProperty, container, container + '.' + missingProperty]);
|
|
551
555
|
else {
|
|
552
556
|
const promisedType = getPromisedTypeOfPromise(c, containingType);
|
|
553
557
|
if (promisedType !== undefined && getPropertyOfType(c, promisedType, name) !== undefined) {
|
|
554
|
-
diagnostic = createDiagnosticForNode(propNode,
|
|
558
|
+
diagnostic = createDiagnosticForNode(propNode, 523 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [
|
|
555
559
|
missingProperty,
|
|
556
560
|
container,
|
|
557
561
|
]);
|
|
558
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(propNode,
|
|
562
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(propNode, 912 /* Diagnostics.Did_you_forget_to_use_await */, []));
|
|
559
563
|
}
|
|
560
564
|
else {
|
|
561
565
|
const libSuggestion = getSuggestedLibForNonExistentProperty(c, missingProperty, containingType);
|
|
562
566
|
const suggestion = libSuggestion === '' ? getSuggestedSymbolForNonexistentProperty(c, propNode, containingType) : undefined;
|
|
563
567
|
if (libSuggestion !== '')
|
|
564
|
-
diagnostic = createDiagnosticForNode(propNode,
|
|
568
|
+
diagnostic = createDiagnosticForNode(propNode, 712 /* Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later */, [missingProperty, container, libSuggestion]);
|
|
565
569
|
else if (suggestion !== undefined) {
|
|
566
|
-
diagnostic = createDiagnosticForNode(propNode,
|
|
570
|
+
diagnostic = createDiagnosticForNode(propNode, 713 /* Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2 */, [
|
|
567
571
|
missingProperty,
|
|
568
572
|
container,
|
|
569
573
|
suggestion.name,
|
|
570
574
|
]);
|
|
571
575
|
if (suggestion.valueDeclaration !== undefined)
|
|
572
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(suggestion.valueDeclaration,
|
|
576
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(suggestion.valueDeclaration, 867 /* Diagnostics.X_0_is_declared_here */, [suggestion.name]));
|
|
573
577
|
}
|
|
574
578
|
else {
|
|
575
579
|
chain = elaborateNeverIntersection(c, chain, propNode, containingType);
|
|
576
580
|
diagnostic = createDiagnosticForNode(propNode, containerSeemsToBeEmptyDomElement(c, containingType)
|
|
577
|
-
?
|
|
578
|
-
:
|
|
581
|
+
? 950 /* Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom */
|
|
582
|
+
: 523 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [missingProperty, container]);
|
|
579
583
|
}
|
|
580
584
|
}
|
|
581
585
|
}
|
|
@@ -591,11 +595,11 @@ export function elaborateNeverIntersection(c, chain, node, t) {
|
|
|
591
595
|
if ((t.flags & 268435456 /* TypeFlags.Intersection */) === 0 || (lazyObjectFlags(c, t) & 67108864 /* ObjectFlags.IsNeverIntersection */) === 0)
|
|
592
596
|
return chain;
|
|
593
597
|
const props = getPropertiesOfUnionOrIntersectionType(c, t);
|
|
594
|
-
let message =
|
|
598
|
+
let message = 1868 /* Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents */;
|
|
595
599
|
let prop = props.find((p) => isDiscriminantWithNeverType(c, p));
|
|
596
600
|
if (prop === undefined) {
|
|
597
601
|
message =
|
|
598
|
-
|
|
602
|
+
1869 /* Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some */;
|
|
599
603
|
prop = props.find(isConflictingPrivateProperty);
|
|
600
604
|
}
|
|
601
605
|
if (prop === undefined)
|
|
@@ -644,7 +648,7 @@ export function typeHasStaticProperty(c, name, containingType) {
|
|
|
644
648
|
export function getSuggestedSymbolForNonexistentProperty(c, name, containingType) {
|
|
645
649
|
let props = getPropertiesOfType(c, containingType);
|
|
646
650
|
const parent = name.parent;
|
|
647
|
-
if (parent.kind ===
|
|
651
|
+
if (parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */) {
|
|
648
652
|
const valid = [];
|
|
649
653
|
for (const prop of props)
|
|
650
654
|
if (isValidPropertyAccessForCompletions(c, parent, containingType, prop))
|
|
@@ -659,7 +663,7 @@ export function getSuggestionForNonexistentProperty(c, name, containingType) {
|
|
|
659
663
|
}
|
|
660
664
|
/** Whether `property` of `t` may be accessed at `node` without an error, as completions decide. */
|
|
661
665
|
function isValidPropertyAccessForCompletions(c, node, t, property) {
|
|
662
|
-
const isSuper = node.kind ===
|
|
666
|
+
const isSuper = node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
|
|
663
667
|
if ((t.flags & 1 /* TypeFlags.Any */) !== 0)
|
|
664
668
|
return true;
|
|
665
669
|
// `#private` access in an optional chain is a parse error.
|
|
@@ -8,6 +8,7 @@ export declare function getSymbolAtLocation(c: Checker, node: Node): Symbol | un
|
|
|
8
8
|
export declare function getSymbolAtLocationWorker(c: Checker, node: Node, ignoreErrors: boolean): Symbol | undefined;
|
|
9
9
|
/** The type of the expression, type node or declaration at `node`. */
|
|
10
10
|
export declare function getTypeAtLocation(c: Checker, node: Node): Type;
|
|
11
|
+
export declare function getTypeOfNode(c: Checker, node: Node): Type;
|
|
11
12
|
/** The narrowed type of `symbol` at `location`, or its declared type when `location` doesn't reference it. */
|
|
12
13
|
export declare function getTypeOfSymbolAtLocation(c: Checker, symbolIn: Symbol, locationIn: Node | undefined): Type;
|
|
13
14
|
/** The value symbol of a shorthand property assignment's name. */
|