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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Node } from './ast.js';
|
|
1
|
+
import { ModifierFlags, type Node } from './ast.js';
|
|
2
2
|
import { type DiagnosticMessage } from './diagnostics.js';
|
|
3
3
|
import type { Checker } from './checker.js';
|
|
4
4
|
import { type Signature, type Type } from './checker-types.js';
|
|
@@ -25,6 +25,17 @@ export declare function getFlowTypeOfProperty(c: Checker, reference: Node, prop:
|
|
|
25
25
|
export declare function isAutoTypedProperty(c: Checker, symbol: Symbol): boolean;
|
|
26
26
|
/** The type of the property in the first base class, if it has one. */
|
|
27
27
|
export declare function getTypeOfPropertyInBaseClass(c: Checker, property: Symbol): Type | undefined;
|
|
28
|
-
/**
|
|
29
|
-
export declare
|
|
28
|
+
/** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
|
|
29
|
+
export declare class ConstructorAccessibilityError {
|
|
30
|
+
readonly kind: ModifierFlags;
|
|
31
|
+
readonly declaringClass: Type;
|
|
32
|
+
constructor(kind: ModifierFlags, declaringClass: Type);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
|
|
36
|
+
* private and protected constructors are only callable within their class, or subclasses if protected.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getConstructorAccessibilityError(c: Checker, node: Node, signatures: readonly Signature[], modifiersMask: ModifierFlags): ConstructorAccessibilityError | undefined;
|
|
39
|
+
/** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
|
|
40
|
+
export declare function isConstructorAccessible(c: Checker, node: Node, signatures: readonly Signature[]): boolean;
|
|
30
41
|
export declare function checkInterfaceDeclaration(c: Checker, node: Node): void;
|
|
@@ -6,7 +6,7 @@ import { isOuterExpression } from './transformers/utilities.js';
|
|
|
6
6
|
import { checkExternalEmitHelpers } from './checker-emit-helpers.js';
|
|
7
7
|
import { Identifier, PrivateIdentifier, getType, getSymbol, ElementAccessExpression, KeywordExpression, NodeVisitor, PropertyAccessExpression, getBody, getName, getStatements, getExpression, getTypeArguments, getHeritageClauses, getMembers, getText, getTypeParameters, getInitializer, getParameters, getModifiers, } from './ast.js';
|
|
8
8
|
import { declarationNameToString, findConstructorDeclaration, getContainingClass, getDeclarationOfKind, getModifierFlags, getSourceFileOfNode, hasSyntacticModifier, isClassLike, isPrivateIdentifierClassElementDeclaration, isStatic, } from './binder-utilities.js';
|
|
9
|
-
import { isFunctionLike, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
|
|
9
|
+
import { isFunctionLike, isInJSFile, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
|
|
10
10
|
import { ScriptTarget, getEmitScriptTarget, getUseDefineForClassFields } from './options.js';
|
|
11
11
|
import { hasDynamicName, hasLateBindableName } from './checker-utilities.js';
|
|
12
12
|
import { everyType, getTargetType, typesOf } from './checker-type-factory.js';
|
|
@@ -17,15 +17,17 @@ import { getSymbolOfDeclaration } from './checker-symbols.js';
|
|
|
17
17
|
import { getOptionalType, getTypeOfSymbol } from './checker-symbol-types.js';
|
|
18
18
|
import { convertAutoToAny, getFlowTypeOfReference } from './checker-narrowing.js';
|
|
19
19
|
import { hasTypeFacts } from './checker-flow.js';
|
|
20
|
-
import { getIndexInfosOfType, getSignaturesOfType, getTypeOfPropertyOfType } from './checker-members.js';
|
|
20
|
+
import { getIndexInfosOfType, getPropertiesOfType, getSignaturesOfType, getTypeOfPropertyOfType, } from './checker-members.js';
|
|
21
|
+
import { isConstructorDeclaredThisProperty } from './checker-javascript.js';
|
|
21
22
|
import { checkJSDocLinksOfNode, checkNodeDeferred, checkSourceElement, checkTypeNodeIfPresent, } from './checker-source-file.js';
|
|
22
23
|
import { checkVariableLikeDeclaration, checkTypeParameters, checkExportsOnMergedDeclarations, } from './checker-declarations.js';
|
|
23
24
|
import { checkFunctionLikeBody } from './checker-functions.js';
|
|
24
|
-
import { checkJSDocFullSignature } from './checker-jsdoc.js';
|
|
25
|
+
import { checkJSDocFullSignature, checkJSDocFullSignatureType } from './checker-jsdoc.js';
|
|
25
26
|
import { checkComputedPropertyName } from './checker-expressions.js';
|
|
26
27
|
import { checkFunctionOrConstructorSymbol, checkFunctionOrMethodSymbols } from './checker-overloads.js';
|
|
27
28
|
import { checkClassHeritage, checkClassOrInterfaceForDuplicateIndexSignatures, checkInterfaceHeritage, } from './checker-heritage.js';
|
|
28
29
|
import { checkDecorators, getFirstTransformableStaticClassElement } from './checker-decorators.js';
|
|
30
|
+
import { getTypeOfNode } from './checker-services.js';
|
|
29
31
|
export function checkClassDeclaration(c, node) {
|
|
30
32
|
checkClassLikeDeclaration(c, node);
|
|
31
33
|
checkClassMembers(c, node);
|
|
@@ -52,7 +54,7 @@ function checkClassExpressionExternalHelpers(c, node) {
|
|
|
52
54
|
if (willTransformESDecorators && classOrConstructorParameterIsDecorated(false, node)) {
|
|
53
55
|
location = node;
|
|
54
56
|
for (const modifier of getModifiers(node)?.nodes ?? [])
|
|
55
|
-
if (modifier.kind ===
|
|
57
|
+
if (modifier.kind === 172 /* SyntaxKind.Decorator */) {
|
|
56
58
|
location = modifier;
|
|
57
59
|
break;
|
|
58
60
|
}
|
|
@@ -62,10 +64,10 @@ function checkClassExpressionExternalHelpers(c, node) {
|
|
|
62
64
|
if (location === undefined)
|
|
63
65
|
return;
|
|
64
66
|
checkExternalEmitHelpers(c, location, 65536 /* ExternalEmitHelpers.SetFunctionName */);
|
|
65
|
-
if ((parent.kind ===
|
|
66
|
-
parent.kind ===
|
|
67
|
-
parent.kind ===
|
|
68
|
-
getName(parent).kind ===
|
|
67
|
+
if ((parent.kind === 304 /* SyntaxKind.PropertyAssignment */ ||
|
|
68
|
+
parent.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
|
|
69
|
+
parent.kind === 210 /* SyntaxKind.BindingElement */) &&
|
|
70
|
+
getName(parent).kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
69
71
|
checkExternalEmitHelpers(c, location, 131072 /* ExternalEmitHelpers.PropKey */);
|
|
70
72
|
}
|
|
71
73
|
export function checkClassLikeDeferred(c, node) {
|
|
@@ -74,11 +76,27 @@ export function checkClassLikeDeferred(c, node) {
|
|
|
74
76
|
function checkClassMembers(c, node) {
|
|
75
77
|
for (const member of getMembers(node).nodes)
|
|
76
78
|
checkClassMember(c, member);
|
|
79
|
+
checkConstructorDeclaredProperties(c, node);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolves the types of a JavaScript class's properties declared by `this.x` assignments in its
|
|
83
|
+
* constructor, so the diagnostics of their initializers don't depend on which use is checked first.
|
|
84
|
+
*/
|
|
85
|
+
function checkConstructorDeclaredProperties(c, node) {
|
|
86
|
+
if (!isInJSFile(node))
|
|
87
|
+
return;
|
|
88
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
89
|
+
if (symbol === undefined)
|
|
90
|
+
return;
|
|
91
|
+
for (const property of getPropertiesOfType(c, getDeclaredTypeOfSymbol(c, symbol)))
|
|
92
|
+
if (isConstructorDeclaredThisProperty(c, property) &&
|
|
93
|
+
c.symbolLinks(property).thisAssignmentLocation.parent === node)
|
|
94
|
+
getTypeOfSymbol(c, property);
|
|
77
95
|
}
|
|
78
96
|
function checkClassLikeDeclaration(c, node) {
|
|
79
97
|
checkDecorators(c, node);
|
|
80
98
|
checkCollisionsForDeclarationName(c, node, getName(node));
|
|
81
|
-
if (node.kind ===
|
|
99
|
+
if (node.kind === 265 /* SyntaxKind.ClassDeclaration */)
|
|
82
100
|
checkExportsOnMergedDeclarations(c, node);
|
|
83
101
|
const typeParameters = getTypeParameters(node);
|
|
84
102
|
checkTypeParameters(c, typeParameters);
|
|
@@ -93,7 +111,7 @@ function checkClassLikeDeclaration(c, node) {
|
|
|
93
111
|
}
|
|
94
112
|
const name = getName(node);
|
|
95
113
|
if (name !== undefined)
|
|
96
|
-
checkTypeNameIsReserved(c, name,
|
|
114
|
+
checkTypeNameIsReserved(c, name, 592 /* Diagnostics.Class_name_cannot_be_0 */);
|
|
97
115
|
const heritageClauses = getHeritageClauses(node);
|
|
98
116
|
if (heritageClauses !== undefined)
|
|
99
117
|
checkHeritageClauses(c, heritageClauses.nodes, true);
|
|
@@ -144,36 +162,37 @@ function checkHeritageClauses(c, clauses, isClass) {
|
|
|
144
162
|
}
|
|
145
163
|
function checkClassMember(c, member) {
|
|
146
164
|
checkJSDocLinksOfNode(c, member);
|
|
147
|
-
if (member.kind ===
|
|
148
|
-
member.kind ===
|
|
149
|
-
member.kind ===
|
|
150
|
-
member.kind ===
|
|
165
|
+
if (member.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
|
|
166
|
+
member.kind === 176 /* SyntaxKind.MethodDeclaration */ ||
|
|
167
|
+
member.kind === 179 /* SyntaxKind.GetAccessor */ ||
|
|
168
|
+
member.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
151
169
|
markPrivateIdentifierScope(c, member);
|
|
152
170
|
switch (member.kind) {
|
|
153
|
-
case
|
|
171
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
154
172
|
checkVariableLikeDeclaration(c, member);
|
|
155
173
|
if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getInitializer(member) !== undefined)
|
|
156
174
|
c.error(member, 216 /* Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), getName(member)));
|
|
157
175
|
return;
|
|
158
|
-
case
|
|
159
|
-
case
|
|
160
|
-
case
|
|
161
|
-
case
|
|
176
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
177
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
178
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
179
|
+
case 180 /* SyntaxKind.SetAccessor */: {
|
|
162
180
|
checkDecorators(c, member);
|
|
163
181
|
const name = getName(member);
|
|
164
|
-
if (name !== undefined && name.kind ===
|
|
182
|
+
if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
165
183
|
checkComputedPropertyName(c, name);
|
|
166
184
|
const symbol = getSymbolOfDeclaration(c, member);
|
|
167
|
-
if (symbol !== undefined && member.kind !==
|
|
185
|
+
if (symbol !== undefined && member.kind !== 178 /* SyntaxKind.Constructor */)
|
|
168
186
|
getTypeOfSymbol(c, symbol);
|
|
169
187
|
checkFunctionLikeBody(c, member);
|
|
170
|
-
if (member.kind ===
|
|
188
|
+
if (member.kind === 176 /* SyntaxKind.MethodDeclaration */) {
|
|
189
|
+
checkJSDocFullSignatureType(c, member);
|
|
171
190
|
checkJSDocFullSignature(c, member);
|
|
172
191
|
checkFunctionOrMethodSymbols(c, member);
|
|
173
192
|
if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getBody(member) !== undefined)
|
|
174
193
|
c.error(member, 195 /* Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), name));
|
|
175
194
|
}
|
|
176
|
-
else if (member.kind ===
|
|
195
|
+
else if (member.kind === 178 /* SyntaxKind.Constructor */) {
|
|
177
196
|
if (symbol !== undefined)
|
|
178
197
|
checkFunctionOrConstructorSymbol(c, symbol);
|
|
179
198
|
checkConstructorSuperCall(c, member);
|
|
@@ -182,10 +201,10 @@ function checkClassMember(c, member) {
|
|
|
182
201
|
checkAccessorDeclaration(c, member);
|
|
183
202
|
return;
|
|
184
203
|
}
|
|
185
|
-
case
|
|
204
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
186
205
|
checkSignatureDeclarationTypes(c, member);
|
|
187
206
|
return;
|
|
188
|
-
case
|
|
207
|
+
case 177 /* SyntaxKind.ClassStaticBlockDeclaration */: {
|
|
189
208
|
const body = getBody(member);
|
|
190
209
|
if (body !== undefined)
|
|
191
210
|
for (const s of getStatements(body).nodes)
|
|
@@ -199,20 +218,20 @@ export function checkAccessorDeclaration(c, node) {
|
|
|
199
218
|
const name = getName(node);
|
|
200
219
|
if (name.kind === 79 /* SyntaxKind.Identifier */ && getText(name) === 'constructor' && isClassLike(node.parent))
|
|
201
220
|
c.error(name, 276 /* Diagnostics.Class_constructor_may_not_be_an_accessor */);
|
|
202
|
-
if (node.kind ===
|
|
221
|
+
if (node.kind === 179 /* SyntaxKind.GetAccessor */ &&
|
|
203
222
|
(node.flags & 8388608 /* NodeFlags.Ambient */) === 0 &&
|
|
204
223
|
nodeIsPresent(getBody(node)) &&
|
|
205
224
|
(node.flags & 256 /* NodeFlags.HasImplicitReturn */) !== 0 &&
|
|
206
225
|
(node.flags & 512 /* NodeFlags.HasExplicitReturn */) === 0)
|
|
207
|
-
c.error(name,
|
|
226
|
+
c.error(name, 559 /* Diagnostics.A_get_accessor_must_return_a_value */);
|
|
208
227
|
if (hasDynamicName(node) && !hasLateBindableName(c, node))
|
|
209
228
|
return;
|
|
210
229
|
// Accessors of one member must agree on accessibility and abstractness; checked once, at the getter.
|
|
211
230
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
212
231
|
if (symbol === undefined)
|
|
213
232
|
return;
|
|
214
|
-
const getter = getDeclarationOfKind(symbol,
|
|
215
|
-
const setter = getDeclarationOfKind(symbol,
|
|
233
|
+
const getter = getDeclarationOfKind(symbol, 179 /* SyntaxKind.GetAccessor */);
|
|
234
|
+
const setter = getDeclarationOfKind(symbol, 180 /* SyntaxKind.SetAccessor */);
|
|
216
235
|
if (getter === undefined || setter === undefined)
|
|
217
236
|
return;
|
|
218
237
|
const links = c.nodeLinks(getter);
|
|
@@ -222,14 +241,14 @@ export function checkAccessorDeclaration(c, node) {
|
|
|
222
241
|
const getterFlags = getModifierFlags(getter);
|
|
223
242
|
const setterFlags = getModifierFlags(setter);
|
|
224
243
|
if ((getterFlags & 64 /* ModifierFlags.Abstract */) !== (setterFlags & 64 /* ModifierFlags.Abstract */)) {
|
|
225
|
-
c.error(getName(getter),
|
|
226
|
-
c.error(getName(setter),
|
|
244
|
+
c.error(getName(getter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
|
|
245
|
+
c.error(getName(setter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
|
|
227
246
|
}
|
|
228
247
|
if (((getterFlags & 4 /* ModifierFlags.Protected */) !== 0 &&
|
|
229
248
|
(setterFlags & (4 /* ModifierFlags.Protected */ | 2 /* ModifierFlags.Private */)) === 0) ||
|
|
230
249
|
((getterFlags & 2 /* ModifierFlags.Private */) !== 0 && (setterFlags & 2 /* ModifierFlags.Private */) === 0)) {
|
|
231
|
-
c.error(getName(getter),
|
|
232
|
-
c.error(getName(setter),
|
|
250
|
+
c.error(getName(getter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
|
|
251
|
+
c.error(getName(setter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
|
|
233
252
|
}
|
|
234
253
|
}
|
|
235
254
|
/** Derived class constructors must call `super`, at the root when properties are initialized. */
|
|
@@ -250,11 +269,11 @@ function checkConstructorSuperCall(c, node) {
|
|
|
250
269
|
const superCall = finder.superCall;
|
|
251
270
|
if (superCall === undefined) {
|
|
252
271
|
if (!classExtendsNull)
|
|
253
|
-
c.error(node,
|
|
272
|
+
c.error(node, 558 /* Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call */);
|
|
254
273
|
return;
|
|
255
274
|
}
|
|
256
275
|
if (classExtendsNull)
|
|
257
|
-
c.error(superCall,
|
|
276
|
+
c.error(superCall, 1828 /* Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null */);
|
|
258
277
|
const emitStandardClassFields = getUseDefineForClassFields(c.compilerOptions) && getEmitScriptTarget(c.compilerOptions) >= ScriptTarget.ES2022;
|
|
259
278
|
if (emitStandardClassFields)
|
|
260
279
|
return;
|
|
@@ -262,31 +281,31 @@ function checkConstructorSuperCall(c, node) {
|
|
|
262
281
|
if (!needsRootLevelSuperCall(classDecl, node))
|
|
263
282
|
return;
|
|
264
283
|
let parent = superCall.parent;
|
|
265
|
-
while (parent.kind ===
|
|
284
|
+
while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
266
285
|
parent = parent.parent;
|
|
267
|
-
if (parent.kind !==
|
|
268
|
-
c.error(superCall,
|
|
286
|
+
if (parent.kind !== 246 /* SyntaxKind.ExpressionStatement */ || parent.parent !== body) {
|
|
287
|
+
c.error(superCall, 579 /* Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers */);
|
|
269
288
|
return;
|
|
270
289
|
}
|
|
271
290
|
for (const statement of getStatements(body).nodes) {
|
|
272
|
-
if (statement.kind ===
|
|
291
|
+
if (statement.kind === 246 /* SyntaxKind.ExpressionStatement */ &&
|
|
273
292
|
isSuperCall(skipOuterExpressions(getExpression(statement))))
|
|
274
293
|
return;
|
|
275
294
|
if (nodeImmediatelyReferencesSuperOrThis(statement))
|
|
276
295
|
break;
|
|
277
296
|
}
|
|
278
|
-
c.error(node,
|
|
297
|
+
c.error(node, 557 /* Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers */);
|
|
279
298
|
}
|
|
280
299
|
function isSuperCall(node) {
|
|
281
|
-
return node.kind ===
|
|
300
|
+
return node.kind === 215 /* SyntaxKind.CallExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
|
|
282
301
|
}
|
|
283
302
|
function skipOuterExpressions(node) {
|
|
284
303
|
let n = node;
|
|
285
|
-
while (n.kind ===
|
|
286
|
-
n.kind ===
|
|
287
|
-
n.kind ===
|
|
288
|
-
n.kind ===
|
|
289
|
-
n.kind ===
|
|
304
|
+
while (n.kind === 219 /* SyntaxKind.ParenthesizedExpression */ ||
|
|
305
|
+
n.kind === 236 /* SyntaxKind.AsExpression */ ||
|
|
306
|
+
n.kind === 240 /* SyntaxKind.SatisfiesExpression */ ||
|
|
307
|
+
n.kind === 218 /* SyntaxKind.TypeAssertionExpression */ ||
|
|
308
|
+
n.kind === 237 /* SyntaxKind.NonNullExpression */)
|
|
290
309
|
n = getExpression(n);
|
|
291
310
|
return n;
|
|
292
311
|
}
|
|
@@ -301,7 +320,7 @@ function needsRootLevelSuperCall(classDecl, constructor) {
|
|
|
301
320
|
}
|
|
302
321
|
function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
|
|
303
322
|
return (isPrivateIdentifierClassElementDeclaration(n) ||
|
|
304
|
-
(n.kind ===
|
|
323
|
+
(n.kind === 174 /* SyntaxKind.PropertyDeclaration */ && !isStatic(n) && getInitializer(n) !== undefined));
|
|
305
324
|
}
|
|
306
325
|
/** Finds the first `super(...)` call outside nested functions. */
|
|
307
326
|
class SuperCallFinder extends NodeVisitor {
|
|
@@ -323,17 +342,17 @@ class SuperOrThisReferenceFinder extends NodeVisitor {
|
|
|
323
342
|
case 107 /* SyntaxKind.SuperKeyword */:
|
|
324
343
|
case 109 /* SyntaxKind.ThisKeyword */:
|
|
325
344
|
return true;
|
|
326
|
-
case
|
|
327
|
-
case
|
|
328
|
-
case
|
|
329
|
-
case
|
|
345
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
346
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
347
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
348
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
330
349
|
return false;
|
|
331
|
-
case
|
|
350
|
+
case 243 /* SyntaxKind.Block */:
|
|
332
351
|
switch (node.parent.kind) {
|
|
333
|
-
case
|
|
334
|
-
case
|
|
335
|
-
case
|
|
336
|
-
case
|
|
352
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
353
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
354
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
355
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
337
356
|
return false;
|
|
338
357
|
}
|
|
339
358
|
}
|
|
@@ -352,7 +371,7 @@ function checkPropertyInitialization(c, node) {
|
|
|
352
371
|
return;
|
|
353
372
|
const constructor = findConstructorDeclaration(node);
|
|
354
373
|
for (const member of getMembers(node).nodes) {
|
|
355
|
-
if (member.kind !==
|
|
374
|
+
if (member.kind !== 174 /* SyntaxKind.PropertyDeclaration */)
|
|
356
375
|
continue;
|
|
357
376
|
if (hasSyntacticModifier(member, 128 /* ModifierFlags.Ambient */) ||
|
|
358
377
|
hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) ||
|
|
@@ -364,7 +383,7 @@ function checkPropertyInitialization(c, node) {
|
|
|
364
383
|
const propName = prop.name;
|
|
365
384
|
if (propName.kind !== 79 /* SyntaxKind.Identifier */ &&
|
|
366
385
|
propName.kind !== 80 /* SyntaxKind.PrivateIdentifier */ &&
|
|
367
|
-
propName.kind !==
|
|
386
|
+
propName.kind !== 169 /* SyntaxKind.ComputedPropertyName */)
|
|
368
387
|
continue;
|
|
369
388
|
const symbol = getSymbolOfDeclaration(c, member);
|
|
370
389
|
if (symbol === undefined)
|
|
@@ -374,7 +393,7 @@ function checkPropertyInitialization(c, node) {
|
|
|
374
393
|
continue;
|
|
375
394
|
if (constructor !== undefined && isPropertyInitializedInConstructor(c, propName, t, constructor))
|
|
376
395
|
continue;
|
|
377
|
-
c.error(propName,
|
|
396
|
+
c.error(propName, 725 /* Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor */, declarationNameToString(getSourceFileOfNode(propName), propName));
|
|
378
397
|
}
|
|
379
398
|
}
|
|
380
399
|
/** Whether `this.name` is definitely assigned at the end of the constructor, by control flow. */
|
|
@@ -382,7 +401,7 @@ export function isPropertyInitializedInConstructor(c, propName, propType, constr
|
|
|
382
401
|
const thisExpression = new KeywordExpression(109 /* SyntaxKind.ThisKeyword */);
|
|
383
402
|
const returnFlowNode = constructor.returnFlowNode;
|
|
384
403
|
let reference;
|
|
385
|
-
if (propName.kind ===
|
|
404
|
+
if (propName.kind === 169 /* SyntaxKind.ComputedPropertyName */) {
|
|
386
405
|
const access = new ElementAccessExpression(thisExpression, undefined, getExpression(propName), 0 /* NodeFlags.None */);
|
|
387
406
|
access.flowNode = returnFlowNode;
|
|
388
407
|
reference = access;
|
|
@@ -419,7 +438,7 @@ export function getFlowTypeInConstructor(c, symbol, constructor) {
|
|
|
419
438
|
const reference = newThisPropertyReference(symbol, constructor, constructor.returnFlowNode);
|
|
420
439
|
const flowType = getFlowTypeOfProperty(c, reference, symbol);
|
|
421
440
|
if (c.noImplicitAny && (flowType === c.autoType || flowType === c.autoArrayType))
|
|
422
|
-
c.error(symbol.valueDeclaration,
|
|
441
|
+
c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
|
|
423
442
|
// Assignments of only null or undefined infer nothing.
|
|
424
443
|
if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
|
|
425
444
|
return undefined;
|
|
@@ -431,7 +450,7 @@ export function getFlowTypeInStaticBlocks(c, symbol, staticBlocks) {
|
|
|
431
450
|
const reference = newThisPropertyReference(symbol, staticBlock, staticBlock.returnFlowNode);
|
|
432
451
|
const flowType = getFlowTypeOfProperty(c, reference, symbol);
|
|
433
452
|
if (c.noImplicitAny && (flowType === c.autoType || flowType === c.autoArrayType))
|
|
434
|
-
c.error(symbol.valueDeclaration,
|
|
453
|
+
c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
|
|
435
454
|
if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
|
|
436
455
|
continue;
|
|
437
456
|
return convertAutoToAny(c, flowType);
|
|
@@ -470,7 +489,7 @@ export function getFlowTypeOfProperty(c, reference, prop) {
|
|
|
470
489
|
export function isAutoTypedProperty(c, symbol) {
|
|
471
490
|
const declaration = symbol.valueDeclaration;
|
|
472
491
|
return (declaration !== undefined &&
|
|
473
|
-
declaration.kind ===
|
|
492
|
+
declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
|
|
474
493
|
getType(declaration) === undefined &&
|
|
475
494
|
getInitializer(declaration) === undefined &&
|
|
476
495
|
c.noImplicitAny);
|
|
@@ -487,32 +506,57 @@ function containsUndefinedType(t) {
|
|
|
487
506
|
const first = (t.flags & 134217728 /* TypeFlags.Union */) !== 0 ? typesOf(t)[0] : t;
|
|
488
507
|
return (first.flags & 4 /* TypeFlags.Undefined */) !== 0;
|
|
489
508
|
}
|
|
490
|
-
/**
|
|
491
|
-
export
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
509
|
+
/** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
|
|
510
|
+
export class ConstructorAccessibilityError {
|
|
511
|
+
kind;
|
|
512
|
+
declaringClass;
|
|
513
|
+
constructor(kind, declaringClass) {
|
|
514
|
+
this.kind = kind;
|
|
515
|
+
this.declaringClass = declaringClass;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
|
|
520
|
+
* private and protected constructors are only callable within their class, or subclasses if protected.
|
|
521
|
+
*/
|
|
522
|
+
export function getConstructorAccessibilityError(c, node, signatures, modifiersMask) {
|
|
523
|
+
for (const signature of signatures) {
|
|
524
|
+
const declaration = signature.declaration;
|
|
525
|
+
if (declaration === undefined)
|
|
526
|
+
continue;
|
|
527
|
+
const modifiers = getModifierFlags(declaration) & modifiersMask;
|
|
528
|
+
// Public constructors and constructor functions are always accessible.
|
|
529
|
+
if (modifiers === 0 || declaration.kind !== 178 /* SyntaxKind.Constructor */)
|
|
530
|
+
continue;
|
|
531
|
+
const classSymbol = getSymbol(declaration.parent);
|
|
532
|
+
const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
|
|
533
|
+
let withinClass = false;
|
|
534
|
+
for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
|
|
535
|
+
if (container === declaringClassDeclaration) {
|
|
536
|
+
withinClass = true;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
if (withinClass)
|
|
540
|
+
continue;
|
|
541
|
+
const containingClass = getContainingClass(node);
|
|
542
|
+
if (containingClass !== undefined && (modifiers & 4 /* ModifierFlags.Protected */) !== 0) {
|
|
543
|
+
const containingType = getTypeOfNode(c, containingClass);
|
|
544
|
+
if (typeHasProtectedAccessibleBase(c, classSymbol, containingType))
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
return new ConstructorAccessibilityError(modifiers, getDeclaredTypeOfSymbol(c, classSymbol));
|
|
511
548
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
/** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
|
|
552
|
+
export function isConstructorAccessible(c, node, signatures) {
|
|
553
|
+
const error = getConstructorAccessibilityError(c, node, signatures, 6 /* ModifierFlags.NonPublicAccessibilityModifier */);
|
|
554
|
+
if (error === undefined)
|
|
555
|
+
return true;
|
|
556
|
+
if ((error.kind & 2 /* ModifierFlags.Private */) !== 0)
|
|
557
|
+
c.error(node, 814 /* Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
|
|
558
|
+
if ((error.kind & 4 /* ModifierFlags.Protected */) !== 0)
|
|
559
|
+
c.error(node, 815 /* Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
|
|
516
560
|
return false;
|
|
517
561
|
}
|
|
518
562
|
/** Whether `target` is a base class of `t`, through bases that aren't mixins. */
|
|
@@ -560,7 +604,7 @@ function findMixins(c, types) {
|
|
|
560
604
|
export function checkInterfaceDeclaration(c, node) {
|
|
561
605
|
const decl = node;
|
|
562
606
|
checkTypeParameters(c, decl.typeParameters);
|
|
563
|
-
checkTypeNameIsReserved(c, decl.name,
|
|
607
|
+
checkTypeNameIsReserved(c, decl.name, 603 /* Diagnostics.Interface_name_cannot_be_0 */);
|
|
564
608
|
checkExportsOnMergedDeclarations(c, node);
|
|
565
609
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
566
610
|
if (symbol !== undefined) {
|
|
@@ -573,7 +617,7 @@ export function checkInterfaceDeclaration(c, node) {
|
|
|
573
617
|
checkHeritageClauses(c, decl.heritageClauses.nodes, false);
|
|
574
618
|
for (const member of decl.members.nodes) {
|
|
575
619
|
checkJSDocLinksOfNode(c, member);
|
|
576
|
-
if (member.kind ===
|
|
620
|
+
if (member.kind === 173 /* SyntaxKind.PropertySignature */)
|
|
577
621
|
checkVariableLikeDeclaration(c, member);
|
|
578
622
|
else
|
|
579
623
|
checkTypeNodeIfPresent(c, member);
|