tsc-ts 0.0.10 → 0.1.1
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 +29 -18
- package/dist/api/compiler/ast.js +1040 -1007
- 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 +136 -91
- package/dist/api/compiler/checker-contextual.d.ts +20 -0
- package/dist/api/compiler/checker-contextual.js +175 -62
- 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 +258 -212
- 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 +107 -89
- 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 +190 -46
- 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 +97 -31
- package/dist/api/compiler/checker.js +149 -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 +24 -4
- package/dist/api/compiler/compile-program.js +53 -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/expr-record.d.ts +11 -0
- package/dist/api/compiler/expr-record.js +53 -0
- 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/identifier-name.d.ts +9 -0
- package/dist/api/compiler/identifier-name.js +10 -0
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +27 -25
- 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 +42 -20
- package/dist/api/compiler/parser.js +318 -224
- 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 +6 -3
- 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 +306 -283
- 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 +64 -59
- package/dist/api/compiler/scanner.d.ts +27 -2
- package/dist/api/compiler/scanner.js +181 -150
- package/dist/api/compiler/shared-results.d.ts +696 -0
- package/dist/api/compiler/shared-results.js +2905 -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 +307 -239
- 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 +74 -38
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/cgroup.ts +157 -0
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +80 -25
- package/src/compiler/checker-contextual.ts +110 -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 +95 -47
- 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 +28 -5
- 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 +173 -35
- 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 +175 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +59 -25
- package/src/compiler/decoder.ts +15 -5
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/doctor-report.ts +133 -0
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/expr-record.ts +59 -0
- 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/identifier-name.ts +13 -0
- 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 +7 -3
- 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 +543 -147
- package/src/compiler/parallel-emit.ts +4 -4
- package/src/compiler/parser.ts +166 -47
- 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 +7 -3
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +39 -16
- 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 +14 -5
- package/src/compiler/run-config.ts +1383 -0
- package/src/compiler/run-record-read.ts +87 -0
- package/src/compiler/run-records.ts +575 -0
- package/src/compiler/scanner.ts +166 -120
- package/src/compiler/shared-results.ts +3144 -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 +22 -3
- 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 +136 -49
- 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 +67 -6
- package/src/compiler/tsc-cli.ts +35 -4
- package/src/compiler/tsc-compile.ts +220 -10
- package/src/compiler/tsc-watch.ts +97 -47
- 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
|
@@ -28,14 +28,22 @@ import { getTypeWithFacts, hasTypeFacts, getNonNullableType } from './checker-fl
|
|
|
28
28
|
import { getTypeOfModuleExportsSymbol, getWidenedTypeForAssignmentDeclaration } from './checker-javascript.js';
|
|
29
29
|
import { copyDeclarations, declarationAt, declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
|
|
30
30
|
export function getTypeOfSymbol(c, symbol) {
|
|
31
|
+
// TSC_TS_SHARE: checker threads share the value types of variables and properties (shared-results.ts).
|
|
32
|
+
if (c.threadSharing !== undefined && isSharedValueSymbol(symbol)) {
|
|
33
|
+
const sharing = c.threadSharing;
|
|
34
|
+
if (sharing.computing === symbol)
|
|
35
|
+
sharing.computing = undefined;
|
|
36
|
+
else
|
|
37
|
+
return threadTypeOfSymbol(c, symbol);
|
|
38
|
+
}
|
|
31
39
|
const checkFlags = symbol.checkFlags;
|
|
32
|
-
if ((checkFlags &
|
|
40
|
+
if ((checkFlags & 524288 /* CheckFlags.DeferredType */) !== 0)
|
|
33
41
|
return getTypeOfSymbolWithDeferredType(c, symbol);
|
|
34
42
|
if ((checkFlags & 1 /* CheckFlags.Instantiated */) !== 0)
|
|
35
43
|
return getTypeOfInstantiatedSymbol(c, symbol);
|
|
36
|
-
if ((checkFlags &
|
|
44
|
+
if ((checkFlags & 2097152 /* CheckFlags.Mapped */) !== 0)
|
|
37
45
|
return getTypeOfMappedSymbol(c, symbol);
|
|
38
|
-
if ((checkFlags &
|
|
46
|
+
if ((checkFlags & 65536 /* CheckFlags.ReverseMapped */) !== 0)
|
|
39
47
|
return getTypeOfReverseMappedSymbol(c, symbol);
|
|
40
48
|
const flags = symbol.flags;
|
|
41
49
|
if ((flags & 98304 /* SymbolFlags.Accessor */) !== 0)
|
|
@@ -94,7 +102,7 @@ function getTypeOfInstantiatedSymbol(c, symbol) {
|
|
|
94
102
|
}
|
|
95
103
|
export function getWriteTypeOfSymbol(c, symbol) {
|
|
96
104
|
if ((symbol.checkFlags & 2 /* CheckFlags.SyntheticProperty */) !== 0) {
|
|
97
|
-
if ((symbol.checkFlags &
|
|
105
|
+
if ((symbol.checkFlags & 524288 /* CheckFlags.DeferredType */) !== 0)
|
|
98
106
|
return getWriteTypeOfSymbolWithDeferredType(c, symbol);
|
|
99
107
|
const id = getSymbolId(symbol);
|
|
100
108
|
return c.symbolLinkTable.get(id)?.writeType ?? c.symbolTypes.get(id) ?? getTypeOfSymbol(c, symbol);
|
|
@@ -129,9 +137,9 @@ function isParameterOfContextSensitiveSignature(c, symbol) {
|
|
|
129
137
|
let decl = symbol.valueDeclaration;
|
|
130
138
|
if (decl === undefined)
|
|
131
139
|
return false;
|
|
132
|
-
if (decl.kind ===
|
|
140
|
+
if (decl.kind === 210 /* SyntaxKind.BindingElement */)
|
|
133
141
|
decl = getRootDeclaration(decl);
|
|
134
|
-
return decl.kind ===
|
|
142
|
+
return decl.kind === 171 /* SyntaxKind.Parameter */ && isContextSensitiveFunctionLikeLazy(c, decl.parent);
|
|
135
143
|
}
|
|
136
144
|
import { isContextSensitiveFunctionOrObjectLiteralMethod as isContextSensitiveFunctionLikeLazy } from './checker-expressions.js';
|
|
137
145
|
function getTypeOfVariableOrParameterOrPropertyWorker(c, symbol) {
|
|
@@ -143,7 +151,7 @@ function getTypeOfVariableOrParameterOrPropertyWorker(c, symbol) {
|
|
|
143
151
|
if (declaration === undefined)
|
|
144
152
|
return c.errorType;
|
|
145
153
|
// The `export=` symbol of a JSON file has the type of its value.
|
|
146
|
-
if (declaration.kind ===
|
|
154
|
+
if (declaration.kind === 308 /* SyntaxKind.SourceFile */ && isJsonSourceFile(declaration)) {
|
|
147
155
|
const statements = declaration.statements.nodes;
|
|
148
156
|
if (statements.length === 0)
|
|
149
157
|
return c.emptyObjectType;
|
|
@@ -157,28 +165,30 @@ function getTypeOfVariableOrParameterOrPropertyWorker(c, symbol) {
|
|
|
157
165
|
return getTypeOfModuleExportsSymbol(c, symbol);
|
|
158
166
|
let result;
|
|
159
167
|
switch (declaration.kind) {
|
|
160
|
-
case
|
|
161
|
-
case
|
|
162
|
-
case
|
|
163
|
-
case
|
|
164
|
-
case
|
|
165
|
-
|
|
168
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
169
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
170
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
171
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
172
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
173
|
+
// A parameter of a context sensitive function may get another type when its context is known, so
|
|
174
|
+
// its widening errors are left to that.
|
|
175
|
+
result = getWidenedTypeForVariableLikeDeclaration(c, declaration, !isParameterOfContextSensitiveSignature(c, symbol));
|
|
166
176
|
break;
|
|
167
|
-
case
|
|
168
|
-
case
|
|
169
|
-
case
|
|
177
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
178
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
179
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
170
180
|
// The declared symbol of an object literal member, as opposed to the checked literal's property.
|
|
171
|
-
if (declaration.kind ===
|
|
181
|
+
if (declaration.kind === 304 /* SyntaxKind.PropertyAssignment */)
|
|
172
182
|
result = checkPropertyAssignment(c, declaration, 0 /* CheckMode.Normal */);
|
|
173
|
-
else if (declaration.kind ===
|
|
183
|
+
else if (declaration.kind === 305 /* SyntaxKind.ShorthandPropertyAssignment */)
|
|
174
184
|
result = checkShorthandPropertyAssignment(c, declaration, true, 0 /* CheckMode.Normal */);
|
|
175
185
|
else
|
|
176
186
|
result = getTypeOfObjectLiteralMethod(c, declaration, 0 /* CheckMode.Normal */);
|
|
177
187
|
break;
|
|
178
|
-
case
|
|
188
|
+
case 293 /* SyntaxKind.JsxAttribute */:
|
|
179
189
|
result = checkJsxAttribute(c, declaration, 0 /* CheckMode.Normal */);
|
|
180
190
|
break;
|
|
181
|
-
case
|
|
191
|
+
case 279 /* SyntaxKind.ExportAssignment */: {
|
|
182
192
|
const typeNode = getType(declaration);
|
|
183
193
|
result =
|
|
184
194
|
typeNode !== undefined
|
|
@@ -186,11 +196,11 @@ function getTypeOfVariableOrParameterOrPropertyWorker(c, symbol) {
|
|
|
186
196
|
: widenTypeForVariableLikeDeclaration(c, checkExpressionCached(c, getExpression(declaration)), declaration, false);
|
|
187
197
|
break;
|
|
188
198
|
}
|
|
189
|
-
case
|
|
199
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
190
200
|
result = getTypeOfEnumMember(c, symbol);
|
|
191
201
|
break;
|
|
192
|
-
case
|
|
193
|
-
case
|
|
202
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
203
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
194
204
|
result = getWidenedTypeForAssignmentDeclaration(c, symbol);
|
|
195
205
|
break;
|
|
196
206
|
default:
|
|
@@ -212,23 +222,23 @@ export function isOptionalDeclaration(node) {
|
|
|
212
222
|
return postfix !== undefined && postfix.kind === 57 /* SyntaxKind.QuestionToken */;
|
|
213
223
|
}
|
|
214
224
|
function isEmptyArrayLiteral(node) {
|
|
215
|
-
return node.kind ===
|
|
225
|
+
return node.kind === 211 /* SyntaxKind.ArrayLiteralExpression */ && getElements(node).nodes.length === 0;
|
|
216
226
|
}
|
|
217
227
|
function isNullOrUndefined(node) {
|
|
218
228
|
let n = node;
|
|
219
|
-
while (n.kind ===
|
|
229
|
+
while (n.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
220
230
|
n = getExpression(n);
|
|
221
231
|
return n.kind === 105 /* SyntaxKind.NullKeyword */ || (n.kind === 79 /* SyntaxKind.Identifier */ && getText(n) === 'undefined');
|
|
222
232
|
}
|
|
223
233
|
function isBindingPattern(node) {
|
|
224
234
|
return (node !== undefined &&
|
|
225
|
-
(node.kind ===
|
|
235
|
+
(node.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 209 /* SyntaxKind.ArrayBindingPattern */));
|
|
226
236
|
}
|
|
227
237
|
/** The declared or inferred type of a variable-like declaration; undefined when nothing can be inferred. */
|
|
228
238
|
export function getTypeForVariableLikeDeclaration(c, declaration, includeOptionality, checkMode = 0 /* CheckMode.Normal */) {
|
|
229
|
-
if (declaration.kind ===
|
|
239
|
+
if (declaration.kind === 262 /* SyntaxKind.VariableDeclaration */) {
|
|
230
240
|
const grandParent = declaration.parent.parent;
|
|
231
|
-
if (grandParent.kind ===
|
|
241
|
+
if (grandParent.kind === 251 /* SyntaxKind.ForInStatement */) {
|
|
232
242
|
// `for (k in x)` declares k as string, or keyof T for generic x.
|
|
233
243
|
let objectType = checkExpressionEx(c, getExpression(grandParent), checkMode);
|
|
234
244
|
if (hasTypeFacts(c, objectType, 50331648 /* TypeFacts.IsUndefinedOrNull */))
|
|
@@ -238,14 +248,14 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
238
248
|
? getExtractStringType(c, indexType)
|
|
239
249
|
: c.stringType;
|
|
240
250
|
}
|
|
241
|
-
if (grandParent.kind ===
|
|
251
|
+
if (grandParent.kind === 252 /* SyntaxKind.ForOfStatement */)
|
|
242
252
|
return checkRightHandSideOfForOf(c, grandParent);
|
|
243
253
|
}
|
|
244
|
-
else if (declaration.kind ===
|
|
254
|
+
else if (declaration.kind === 210 /* SyntaxKind.BindingElement */)
|
|
245
255
|
return getTypeForBindingElement(c, declaration);
|
|
246
|
-
const isProperty = (declaration.kind ===
|
|
256
|
+
const isProperty = (declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
|
|
247
257
|
(getCombinedModifierFlags(declaration) & 512 /* ModifierFlags.Accessor */) === 0) ||
|
|
248
|
-
declaration.kind ===
|
|
258
|
+
declaration.kind === 173 /* SyntaxKind.PropertySignature */;
|
|
249
259
|
const isOptional = includeOptionality && isOptionalDeclaration(declaration);
|
|
250
260
|
const typeNode = getType(declaration);
|
|
251
261
|
const declaredType = typeNode !== undefined ? getTypeFromTypeNode(c, typeNode) : undefined;
|
|
@@ -257,7 +267,7 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
257
267
|
if (declaredType !== undefined)
|
|
258
268
|
return addOptionality(c, declaredType, isProperty, isOptional);
|
|
259
269
|
if (c.noImplicitAny &&
|
|
260
|
-
declaration.kind ===
|
|
270
|
+
declaration.kind === 262 /* SyntaxKind.VariableDeclaration */ &&
|
|
261
271
|
!isBindingPattern(getName(declaration)) &&
|
|
262
272
|
(getCombinedModifierFlags(declaration) & 32 /* ModifierFlags.Export */) === 0 &&
|
|
263
273
|
(declaration.flags & 8388608 /* NodeFlags.Ambient */) === 0) {
|
|
@@ -269,14 +279,14 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
269
279
|
if (initializer !== undefined && isEmptyArrayLiteral(initializer))
|
|
270
280
|
return c.autoArrayType;
|
|
271
281
|
}
|
|
272
|
-
if (declaration.kind ===
|
|
282
|
+
if (declaration.kind === 171 /* SyntaxKind.Parameter */) {
|
|
273
283
|
if (getSymbol(declaration) === undefined)
|
|
274
284
|
return undefined;
|
|
275
285
|
const fn = declaration.parent;
|
|
276
286
|
// A set accessor parameter takes the getter's type.
|
|
277
|
-
if (fn.kind ===
|
|
287
|
+
if (fn.kind === 180 /* SyntaxKind.SetAccessor */) {
|
|
278
288
|
const fnSymbol = getSymbolOfDeclaration(c, fn);
|
|
279
|
-
const getter = fnSymbol !== undefined ? getDeclarations(fnSymbol).find((d) => d.kind ===
|
|
289
|
+
const getter = fnSymbol !== undefined ? getDeclarations(fnSymbol).find((d) => d.kind === 179 /* SyntaxKind.GetAccessor */) : undefined;
|
|
280
290
|
if (getter !== undefined) {
|
|
281
291
|
const getterSignature = getSignatureFromDeclaration(c, getter);
|
|
282
292
|
// An unannotated `this` of a setter takes the getter's `this` type.
|
|
@@ -302,7 +312,7 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
302
312
|
const t = widenTypeInferredFromInitializer(c, declaration, checkDeclarationInitializer(c, declaration, checkMode));
|
|
303
313
|
return addOptionality(c, t, isProperty, isOptional);
|
|
304
314
|
}
|
|
305
|
-
if (c.noImplicitAny && declaration.kind ===
|
|
315
|
+
if (c.noImplicitAny && declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */) {
|
|
306
316
|
// Without an annotation or initializer, the type comes from `this` assignments in the
|
|
307
317
|
// constructor or static blocks.
|
|
308
318
|
const symbol = getSymbol(declaration);
|
|
@@ -318,7 +328,7 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
318
328
|
else {
|
|
319
329
|
const staticBlocks = [];
|
|
320
330
|
for (const member of getMembers(declaration.parent).nodes)
|
|
321
|
-
if (member.kind ===
|
|
331
|
+
if (member.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */)
|
|
322
332
|
staticBlocks.push(member);
|
|
323
333
|
if (staticBlocks.length !== 0)
|
|
324
334
|
t = getFlowTypeInStaticBlocks(c, symbol, staticBlocks);
|
|
@@ -327,7 +337,7 @@ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptiona
|
|
|
327
337
|
}
|
|
328
338
|
return t !== undefined ? addOptionality(c, t, true, isOptional) : undefined;
|
|
329
339
|
}
|
|
330
|
-
if (declaration.kind ===
|
|
340
|
+
if (declaration.kind === 293 /* SyntaxKind.JsxAttribute */)
|
|
331
341
|
return c.trueType;
|
|
332
342
|
if (isBindingPattern(getName(declaration)))
|
|
333
343
|
return getTypeFromBindingPattern(c, getName(declaration), false, true);
|
|
@@ -354,7 +364,7 @@ export function getWidenedLiteralTypeForInitializer(c, declaration, t) {
|
|
|
354
364
|
return getWidenedLiteralType(c, t);
|
|
355
365
|
}
|
|
356
366
|
function isDeclarationReadonly(declaration) {
|
|
357
|
-
return ((getCombinedModifierFlags(declaration) & 8 /* ModifierFlags.Readonly */) !== 0 && declaration.kind !==
|
|
367
|
+
return ((getCombinedModifierFlags(declaration) & 8 /* ModifierFlags.Readonly */) !== 0 && declaration.kind !== 171 /* SyntaxKind.Parameter */);
|
|
358
368
|
}
|
|
359
369
|
function isGlobalSymbolConstructor(c, node) {
|
|
360
370
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
@@ -370,13 +380,13 @@ export function widenTypeForVariableLikeDeclaration(c, t, declaration, reportErr
|
|
|
370
380
|
reportErrorsFromWidening(c, declaration, t, 0 /* WideningKind.Normal */);
|
|
371
381
|
// A unique symbol type from another declaration widens.
|
|
372
382
|
if ((t.flags & 16384 /* TypeFlags.UniqueESSymbol */) !== 0 &&
|
|
373
|
-
(declaration.kind ===
|
|
383
|
+
(declaration.kind === 210 /* SyntaxKind.BindingElement */ || getType(declaration) === undefined) &&
|
|
374
384
|
t.symbol !== getSymbolOfDeclaration(c, declaration))
|
|
375
385
|
t = c.esSymbolType;
|
|
376
386
|
return getWidenedType(c, t);
|
|
377
387
|
}
|
|
378
388
|
// Rest parameters default to any[], others to any.
|
|
379
|
-
const isRest = declaration.kind ===
|
|
389
|
+
const isRest = declaration.kind === 171 /* SyntaxKind.Parameter */ && getDotDotDotToken(declaration) !== undefined;
|
|
380
390
|
const result = isRest ? c.anyArrayType : c.anyType;
|
|
381
391
|
if (reportErrors && !declarationBelongsToPrivateAmbientMember(declaration))
|
|
382
392
|
reportImplicitAny(c, declaration, result);
|
|
@@ -384,7 +394,7 @@ export function widenTypeForVariableLikeDeclaration(c, t, declaration, reportErr
|
|
|
384
394
|
}
|
|
385
395
|
export function declarationBelongsToPrivateAmbientMember(declaration) {
|
|
386
396
|
const root = getRootDeclaration(declaration);
|
|
387
|
-
const member = root.kind ===
|
|
397
|
+
const member = root.kind === 171 /* SyntaxKind.Parameter */ ? root.parent : root;
|
|
388
398
|
return isPrivateWithinAmbient(member);
|
|
389
399
|
}
|
|
390
400
|
export function isPrivateWithinAmbient(node) {
|
|
@@ -443,7 +453,7 @@ function reportWideningErrorsInType(c, t) {
|
|
|
443
453
|
}
|
|
444
454
|
}
|
|
445
455
|
if (valueDeclaration !== undefined) {
|
|
446
|
-
c.error(valueDeclaration,
|
|
456
|
+
c.error(valueDeclaration, 1709 /* Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type */, symbolToString(c, p), typeToString(c, getWidenedType(c, s)));
|
|
447
457
|
errorReported = true;
|
|
448
458
|
}
|
|
449
459
|
}
|
|
@@ -458,29 +468,29 @@ export function reportImplicitAny(c, declaration, t, wideningKind = 0 /* Widenin
|
|
|
458
468
|
const typeAsString = typeToString(c, getWidenedType(c, t));
|
|
459
469
|
let message;
|
|
460
470
|
switch (declaration.kind) {
|
|
461
|
-
case
|
|
462
|
-
case
|
|
463
|
-
case
|
|
471
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
472
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
473
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
464
474
|
message = c.noImplicitAny
|
|
465
|
-
?
|
|
466
|
-
:
|
|
475
|
+
? 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */
|
|
476
|
+
: 1735 /* Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
|
|
467
477
|
break;
|
|
468
|
-
case
|
|
478
|
+
case 171 /* SyntaxKind.Parameter */: {
|
|
469
479
|
const isRest = getDotDotDotToken(declaration) !== undefined;
|
|
470
480
|
// `(string) => void` most likely meant a parameter of type `string`.
|
|
471
481
|
const name = getName(declaration);
|
|
472
482
|
const parent = declaration.parent;
|
|
473
483
|
if (name !== undefined &&
|
|
474
484
|
name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
475
|
-
(parent.kind ===
|
|
476
|
-
parent.kind ===
|
|
477
|
-
parent.kind ===
|
|
485
|
+
(parent.kind === 181 /* SyntaxKind.CallSignature */ ||
|
|
486
|
+
parent.kind === 175 /* SyntaxKind.MethodSignature */ ||
|
|
487
|
+
parent.kind === 186 /* SyntaxKind.FunctionType */)) {
|
|
478
488
|
const index = getParameters(parent).nodes.indexOf(declaration);
|
|
479
489
|
const text = getText(name);
|
|
480
490
|
if (index >= 0 &&
|
|
481
491
|
(isTypeNodeKind(identifierToKeywordKind(text)) ||
|
|
482
492
|
resolveName(c, declaration, text, 788968 /* SymbolFlags.Type */, undefined, true, false) !== undefined)) {
|
|
483
|
-
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(declaration,
|
|
493
|
+
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(declaration, 1741 /* Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1 */, [
|
|
484
494
|
'arg' + index,
|
|
485
495
|
declarationNameToString(file, name) + (isRest ? '[]' : ''),
|
|
486
496
|
]));
|
|
@@ -489,51 +499,56 @@ export function reportImplicitAny(c, declaration, t, wideningKind = 0 /* Widenin
|
|
|
489
499
|
}
|
|
490
500
|
if (isRest)
|
|
491
501
|
message = c.noImplicitAny
|
|
492
|
-
?
|
|
493
|
-
:
|
|
502
|
+
? 1710 /* Diagnostics.Rest_parameter_0_implicitly_has_an_any_type */
|
|
503
|
+
: 1737 /* Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage */;
|
|
494
504
|
else
|
|
495
505
|
message = c.noImplicitAny
|
|
496
|
-
?
|
|
497
|
-
:
|
|
506
|
+
? 1698 /* Diagnostics.Parameter_0_implicitly_has_an_1_type */
|
|
507
|
+
: 1734 /* Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
|
|
498
508
|
break;
|
|
499
509
|
}
|
|
500
|
-
case
|
|
510
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
501
511
|
if (!c.noImplicitAny)
|
|
502
512
|
return;
|
|
503
|
-
message =
|
|
513
|
+
message = 1721 /* Diagnostics.Binding_element_0_implicitly_has_an_1_type */;
|
|
504
514
|
break;
|
|
505
|
-
case
|
|
506
|
-
case
|
|
507
|
-
case
|
|
508
|
-
case
|
|
509
|
-
case
|
|
510
|
-
case
|
|
511
|
-
case
|
|
515
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
516
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
517
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
518
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
519
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
520
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
521
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
512
522
|
if (c.noImplicitAny && getName(declaration) === undefined) {
|
|
513
523
|
c.error(declaration, wideningKind === 3 /* WideningKind.GeneratorYield */
|
|
514
|
-
?
|
|
515
|
-
:
|
|
524
|
+
? 1715 /* Diagnostics.Generator_implicitly_has_yield_type_0_Consider_supplying_a_return_type_annotation */
|
|
525
|
+
: 1702 /* Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type */, typeAsString);
|
|
516
526
|
return;
|
|
517
527
|
}
|
|
518
528
|
if (c.noImplicitAny && (declaration.flags & 8 /* NodeFlags.Reparsed */) !== 0) {
|
|
519
|
-
|
|
529
|
+
// A JSDoc `@overload`.
|
|
530
|
+
const nameText = declarationNameToString(file, getNameOfDeclaration(declaration));
|
|
531
|
+
if (nameText !== '')
|
|
532
|
+
c.error(declaration, 1701 /* Diagnostics.X_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type */, nameText, typeAsString);
|
|
533
|
+
else
|
|
534
|
+
c.error(declaration, 1703 /* Diagnostics.This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation */, typeAsString);
|
|
520
535
|
return;
|
|
521
536
|
}
|
|
522
537
|
if (!c.noImplicitAny)
|
|
523
|
-
message =
|
|
538
|
+
message = 1740 /* Diagnostics.X_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage */;
|
|
524
539
|
else if (wideningKind === 3 /* WideningKind.GeneratorYield */)
|
|
525
|
-
message =
|
|
540
|
+
message = 1745 /* Diagnostics.X_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type */;
|
|
526
541
|
else
|
|
527
|
-
message =
|
|
542
|
+
message = 1701 /* Diagnostics.X_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type */;
|
|
528
543
|
break;
|
|
529
|
-
case
|
|
544
|
+
case 202 /* SyntaxKind.MappedType */:
|
|
530
545
|
if (c.noImplicitAny)
|
|
531
|
-
c.error(declaration,
|
|
546
|
+
c.error(declaration, 1729 /* Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type */);
|
|
532
547
|
return;
|
|
533
548
|
default:
|
|
534
549
|
message = c.noImplicitAny
|
|
535
|
-
?
|
|
536
|
-
:
|
|
550
|
+
? 1697 /* Diagnostics.Variable_0_implicitly_has_an_1_type */
|
|
551
|
+
: 1733 /* Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
|
|
537
552
|
}
|
|
538
553
|
const name = getNameOfDeclaration(declaration);
|
|
539
554
|
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(declaration, message, [declarationNameToString(file, name), typeAsString]));
|
|
@@ -758,7 +773,7 @@ function someReadonlyAssignmentDeclaration(c, symbol) {
|
|
|
758
773
|
}
|
|
759
774
|
/** An `Object.defineProperty` call with a value and no `writable: true`, or without a setter. */
|
|
760
775
|
function isReadonlyAssignmentDeclaration(c, node) {
|
|
761
|
-
if (node.kind !==
|
|
776
|
+
if (node.kind !== 215 /* SyntaxKind.CallExpression */)
|
|
762
777
|
return false;
|
|
763
778
|
const args = getArguments(node);
|
|
764
779
|
if (args === undefined || args.nodes.length < 3)
|
|
@@ -769,7 +784,7 @@ function isReadonlyAssignmentDeclaration(c, node) {
|
|
|
769
784
|
if (writable === undefined)
|
|
770
785
|
return true;
|
|
771
786
|
const declaration = writable.valueDeclaration;
|
|
772
|
-
const writableType = declaration !== undefined && declaration.kind ===
|
|
787
|
+
const writableType = declaration !== undefined && declaration.kind === 304 /* SyntaxKind.PropertyAssignment */
|
|
773
788
|
? checkExpression(c, getInitializer(declaration))
|
|
774
789
|
: getTypeOfSymbol(c, writable);
|
|
775
790
|
return writableType === c.falseType || writableType === c.regularFalseType;
|
|
@@ -782,6 +797,7 @@ import { getParameterTypeOfFullSignature } from './checker-jsdoc.js';
|
|
|
782
797
|
import { isFunctionLikeDeclarationKind, isInJSFile } from './ast-utilities.js';
|
|
783
798
|
import { isEmptyArrayLiteralType } from './relations.js';
|
|
784
799
|
import { isCheckJsEnabledForFile } from './program-utilities.js';
|
|
800
|
+
import { isSharedValueSymbol, threadTypeOfSymbol } from './shared-results.js';
|
|
785
801
|
function getDeclarationModifierFlags(c, symbol) {
|
|
786
802
|
return getDeclarationModifierFlagsFromSymbol(c, symbol, false);
|
|
787
803
|
}
|
|
@@ -792,9 +808,9 @@ function getDeclarationNodeFlagsFromSymbol(symbol) {
|
|
|
792
808
|
export function getAnnotatedAccessorTypeNode(accessor) {
|
|
793
809
|
if (accessor === undefined)
|
|
794
810
|
return undefined;
|
|
795
|
-
if (accessor.kind ===
|
|
811
|
+
if (accessor.kind === 179 /* SyntaxKind.GetAccessor */ || accessor.kind === 174 /* SyntaxKind.PropertyDeclaration */)
|
|
796
812
|
return getType(accessor);
|
|
797
|
-
if (accessor.kind ===
|
|
813
|
+
if (accessor.kind === 180 /* SyntaxKind.SetAccessor */) {
|
|
798
814
|
const params = getParameters(accessor)?.nodes ?? [];
|
|
799
815
|
if (params.length === 0)
|
|
800
816
|
return undefined;
|
|
@@ -809,7 +825,7 @@ function getAnnotatedAccessorType(c, accessor) {
|
|
|
809
825
|
/** The `accessor` property declaration of `symbol`, if any. */
|
|
810
826
|
function getAutoAccessorDeclaration(symbol) {
|
|
811
827
|
for (const d of getDeclarations(symbol))
|
|
812
|
-
if (d.kind ===
|
|
828
|
+
if (d.kind === 174 /* SyntaxKind.PropertyDeclaration */ && (getCombinedModifierFlags(d) & 512 /* ModifierFlags.Accessor */) !== 0)
|
|
813
829
|
return d;
|
|
814
830
|
return undefined;
|
|
815
831
|
}
|
|
@@ -820,8 +836,8 @@ function getTypeOfAccessors(c, symbol) {
|
|
|
820
836
|
return type;
|
|
821
837
|
if (!pushTypeResolution(c, symbol, 0 /* TypeSystemPropertyName.Type */))
|
|
822
838
|
return c.errorType;
|
|
823
|
-
const getter = getDeclarations(symbol).find((d) => d.kind ===
|
|
824
|
-
const setter = getDeclarations(symbol).find((d) => d.kind ===
|
|
839
|
+
const getter = getDeclarations(symbol).find((d) => d.kind === 179 /* SyntaxKind.GetAccessor */);
|
|
840
|
+
const setter = getDeclarations(symbol).find((d) => d.kind === 180 /* SyntaxKind.SetAccessor */);
|
|
825
841
|
const accessor = getAutoAccessorDeclaration(symbol);
|
|
826
842
|
// Getter annotation, setter annotation, accessor annotation, then getter body.
|
|
827
843
|
let t = getAnnotatedAccessorType(c, getter) ?? getAnnotatedAccessorType(c, setter) ?? getAnnotatedAccessorType(c, accessor);
|
|
@@ -831,18 +847,18 @@ function getTypeOfAccessors(c, symbol) {
|
|
|
831
847
|
t = getWidenedTypeForVariableLikeDeclaration(c, accessor, true);
|
|
832
848
|
if (t === undefined) {
|
|
833
849
|
if (setter !== undefined && !isPrivateWithinAmbient(setter))
|
|
834
|
-
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(setter,
|
|
850
|
+
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(setter, 1722 /* Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation */, [symbolToString(c, symbol)]));
|
|
835
851
|
else if (getter !== undefined && !isPrivateWithinAmbient(getter))
|
|
836
|
-
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(getter,
|
|
852
|
+
c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(getter, 1723 /* Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation */, [symbolToString(c, symbol)]));
|
|
837
853
|
t = c.anyType;
|
|
838
854
|
}
|
|
839
855
|
if (!popTypeResolution(c)) {
|
|
840
856
|
if (getAnnotatedAccessorTypeNode(getter) !== undefined)
|
|
841
|
-
c.error(getter,
|
|
857
|
+
c.error(getter, 669 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
|
|
842
858
|
else if (getAnnotatedAccessorTypeNode(setter) !== undefined)
|
|
843
|
-
c.error(setter,
|
|
859
|
+
c.error(setter, 669 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
|
|
844
860
|
else if (getter !== undefined && c.noImplicitAny)
|
|
845
|
-
c.error(getter,
|
|
861
|
+
c.error(getter, 1713 /* Diagnostics.X_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions */, symbolToString(c, symbol));
|
|
846
862
|
t = c.anyType;
|
|
847
863
|
}
|
|
848
864
|
let cached = c.symbolTypes.get(id);
|
|
@@ -858,11 +874,11 @@ export function getWriteTypeOfAccessors(c, symbol) {
|
|
|
858
874
|
return links.writeType;
|
|
859
875
|
if (!pushTypeResolution(c, symbol, 7 /* TypeSystemPropertyName.WriteType */))
|
|
860
876
|
return c.errorType;
|
|
861
|
-
const setter = getDeclarations(symbol).find((d) => d.kind ===
|
|
877
|
+
const setter = getDeclarations(symbol).find((d) => d.kind === 180 /* SyntaxKind.SetAccessor */) ?? getAutoAccessorDeclaration(symbol);
|
|
862
878
|
let writeType = getAnnotatedAccessorType(c, setter);
|
|
863
879
|
if (!popTypeResolution(c)) {
|
|
864
880
|
if (getAnnotatedAccessorTypeNode(setter) !== undefined)
|
|
865
|
-
c.error(setter,
|
|
881
|
+
c.error(setter, 669 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
|
|
866
882
|
writeType = c.anyType;
|
|
867
883
|
}
|
|
868
884
|
// Without a setter annotation, the write type is the read type.
|
|
@@ -885,7 +901,7 @@ function getTypeOfFuncClassEnumModuleWorker(c, symbol) {
|
|
|
885
901
|
return c.anyType;
|
|
886
902
|
if ((symbol.flags & 512 /* SymbolFlags.ValueModule */) !== 0 &&
|
|
887
903
|
symbol.valueDeclaration !== undefined &&
|
|
888
|
-
symbol.valueDeclaration.kind ===
|
|
904
|
+
symbol.valueDeclaration.kind === 308 /* SyntaxKind.SourceFile */) {
|
|
889
905
|
const resolvedModule = resolveExternalModuleSymbol(c, symbol, false);
|
|
890
906
|
if (resolvedModule !== undefined && resolvedModule !== symbol)
|
|
891
907
|
return getTypeOfSymbol(c, resolvedModule);
|
|
@@ -901,7 +917,7 @@ function getTypeOfFuncClassEnumModuleWorker(c, symbol) {
|
|
|
901
917
|
}
|
|
902
918
|
function isShorthandAmbientModuleSymbol(symbol) {
|
|
903
919
|
const d = symbol.valueDeclaration;
|
|
904
|
-
return d !== undefined && d.kind ===
|
|
920
|
+
return d !== undefined && d.kind === 269 /* SyntaxKind.ModuleDeclaration */ && getBody(d) === undefined;
|
|
905
921
|
}
|
|
906
922
|
export function getBaseTypeVariableOfClass(c, symbol) {
|
|
907
923
|
const baseConstructorType = getBaseConstructorTypeOfClass(c, getDeclaredTypeOfClassOrInterface(c, symbol));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Identifier, type Node,
|
|
1
|
+
import { type Identifier, type Node, PatternAmbientModule, type SourceFile, Tristate } from './ast.js';
|
|
2
2
|
import { getSourceFileOfNode } from './binder-utilities.js';
|
|
3
3
|
import { type Diagnostic, type DiagnosticMessage } from './diagnostics.js';
|
|
4
4
|
import { NameResolver } from './name-resolver.js';
|
|
@@ -28,6 +28,12 @@ export declare class CheckerNameResolver extends NameResolver {
|
|
|
28
28
|
export declare function resolveName(c: Checker, location: Node | undefined, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage | undefined, isUse: boolean, excludeGlobals: boolean): Symbol | undefined;
|
|
29
29
|
/** `symbols[name]` (merged) if it has `meaning`, directly or through an alias. */
|
|
30
30
|
export declare function getSymbolOfMeaning(c: Checker, symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The name-not-found message of an identifier resolved from its own location, chosen only once the name
|
|
33
|
+
* isn't found (`onFailedToResolveSymbol`). Choosing it up front, as tsgo does, compares every resolved
|
|
34
|
+
* identifier's text with the list of names `getCannotFindNameDiagnosticForName` has messages for.
|
|
35
|
+
*/
|
|
36
|
+
export declare const cannotFindNameAtLocation: DiagnosticMessage;
|
|
31
37
|
/** Resolves names to their closest misspelling in scope, for "Did you mean" suggestions. */
|
|
32
38
|
export declare class SuggestionNameResolver extends CheckerNameResolver {
|
|
33
39
|
lookup(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol | undefined;
|
|
@@ -78,6 +84,7 @@ export declare class MergedGlobals {
|
|
|
78
84
|
readonly ambientModuleSymbols: Symbol[];
|
|
79
85
|
readonly patternAmbientModules: PatternAmbientModule[];
|
|
80
86
|
readonly patternAmbientModuleAugmentations: Map<string, Symbol>;
|
|
87
|
+
readonly patternAmbientModuleAugmentationTargets: Map<string, Symbol>;
|
|
81
88
|
/** Whether the global `undefined` is the checker's own (no declaration of `undefined` merged). */
|
|
82
89
|
readonly ownUndefined: boolean;
|
|
83
90
|
/** Ids of the symbols merged into each shared symbol. */
|
|
@@ -147,6 +154,11 @@ export declare function isReservedMemberName(name: string): boolean;
|
|
|
147
154
|
export declare function symbolIsValue(c: Checker, symbol: Symbol): boolean;
|
|
148
155
|
/** Value members other than signatures and index signatures, declared ones first, each part ordered by declaration. */
|
|
149
156
|
export declare function getNamedMembers(c: Checker, members: SymbolTable | undefined, container: Symbol | undefined): Symbol[];
|
|
157
|
+
/**
|
|
158
|
+
* `getNamedMembers(c, table, container)` for a table that holds `members` in this order under their names, as
|
|
159
|
+
* positions in `members`; undefined where a member is an alias (`symbolIsValue` then resolves it) or a name repeats.
|
|
160
|
+
*/
|
|
161
|
+
export declare function getNamedMemberPositions(c: Checker, members: Symbol[], container: Symbol | undefined): number[] | undefined;
|
|
150
162
|
export declare function getFirstIdentifier(node: Node): Identifier;
|
|
151
163
|
export declare function resolveEntityName(c: Checker, name: Node, meaning: SymbolFlags, ignoreErrors: boolean, dontResolveAlias: boolean, location: Node | undefined): Symbol | undefined;
|
|
152
164
|
/**
|