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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { checkDeprecatedSignature } from './checker-deprecation.js';
|
|
4
4
|
import { Node, getArguments as getArgumentList, getExpression, getName, getParameters, getText, getTypeArguments as getTypeArgumentList, getNodeId, getBody, getSymbol, callQuestionDotToken, callTypeArguments, } from './ast.js';
|
|
5
5
|
import { canHaveDecorators, getEffectiveCheckNode, isFunctionLikeDeclarationKind, isImportCall, nodeIsPresent, } from './ast-utilities.js';
|
|
6
|
-
import { getContainingClass, getSourceFileOfNode, isAccessExpression, isExpressionOfOptionalChainRoot, isOptionalChain, isOutermostOptionalChain, isDottedName, } from './binder-utilities.js';
|
|
6
|
+
import { getContainingClass, getSourceFileOfNode, isAccessExpression, isExpressionOfOptionalChainRoot, isOptionalChain, isOutermostOptionalChain, isDottedName, isFunctionExpressionOrArrowFunction, } from './binder-utilities.js';
|
|
7
7
|
import { Diagnostic, chainDiagnostic } from './diagnostics.js';
|
|
8
8
|
import { resolveInstanceofExpression } from './checker-operators.js';
|
|
9
9
|
import { skipTrivia } from './scanner.js';
|
|
@@ -20,7 +20,7 @@ import { getEffectsSignature } from './checker-narrowing.js';
|
|
|
20
20
|
import { addOptionalTypeMarker, getOptionalType, getTypeOfSymbol, removeOptionalTypeMarker, } from './checker-symbol-types.js';
|
|
21
21
|
import { checkTypeRelatedTo, getRegularTypeOfObjectLiteral, isTypeAssignableTo } from './relations.js';
|
|
22
22
|
import { getNonNullableType } from './checker-flow.js';
|
|
23
|
-
import { checkExpression, checkExpressionCached, checkNonNullType, checkNonNullTypeEx, checkTypeQueryExpression, } from './checker-expressions.js';
|
|
23
|
+
import { checkExpression, checkExpressionCached, checkNonNullType, checkNonNullTypeEx, checkTypeQueryExpression, getResolvedSymbol, } from './checker-expressions.js';
|
|
24
24
|
import { checkIteratedTypeOrElementType } from './checker-iteration.js';
|
|
25
25
|
import { isContextSensitive } from './checker-functions.js';
|
|
26
26
|
import { getExtendsHeritageClauseElement, getInstantiatedConstructorsForTypeArguments, fillMissingTypeArguments, getConstraintOfTypeParameter, getDefaultFromTypeParameter, getMinTypeArgumentCount, } from './checker-declared-types.js';
|
|
@@ -29,7 +29,7 @@ import { getIndexedAccessTypeEx, getRestTypeOfTupleType } from './checker-type-o
|
|
|
29
29
|
import { instantiateType, isNodeDescendantOf } from './instantiation.js';
|
|
30
30
|
import { maybeTypeOfKind } from './checker-utilities.js';
|
|
31
31
|
import { checkSourceElement, checkNodeDeferred } from './checker-source-file.js';
|
|
32
|
-
import { InferenceInfo, applyToParameterTypes, applyToReturnTypes, hasOverlappingInferences, instantiateSignatureInContextOf, mergeInferences, cloneInferenceContext, cloneInferredPartOfContext, createInferenceContext, createOuterReturnMapper, getInferredTypes, getMapperFromContext, everyInferenceHasCandidates, someInferenceHasCandidates, inferTypes, isConstTypeVariable, isMutableArrayLikeType, } from './checker-inference.js';
|
|
32
|
+
import { InferenceInfo, applyToParameterTypes, applyToReturnTypes, hasOverlappingInferences, instantiateSignatureInContextOf, mergeInferences, cloneInferenceContext, cloneInferredPartOfContext, createInferenceContext, createOuterReturnMapper, getInferredTypes, getMapperFromContext, everyInferenceHasCandidates, someInferenceHasCandidates, inferTypes, inferTypesFromUnstarted, isConstTypeVariable, isMutableArrayLikeType, } from './checker-inference.js';
|
|
33
33
|
import { checkExpressionWithContextualType, getApparentTypeOfContextualTypeEx, getContextualTypeEx, getContextualTypeForElementExpression, getInferenceContext, } from './checker-contextual.js';
|
|
34
34
|
import { couldContainTypeVariables } from './instantiation.js';
|
|
35
35
|
import { typeToString } from './type-printer.js';
|
|
@@ -38,7 +38,7 @@ import { getGlobalValueSymbol, getSymbolOfDeclaration, resolveName } from './che
|
|
|
38
38
|
import { checkImportCallExpression } from './checker-modules.js';
|
|
39
39
|
import { checkApplicableSignatureForJsxCallLikeElement, getAttributesOf, getEffectiveJsxArguments, inferJsxTypeArguments, isJsxOpeningLikeElement, resolveJsxOpeningLikeElement, } from './checker-jsx.js';
|
|
40
40
|
import { isCommonJSRequire, resolveExternalModuleTypeByLiteral } from './checker-javascript.js';
|
|
41
|
-
import { declarationCount, getDeclarations } from './symbol.js';
|
|
41
|
+
import { copyDeclarations, declarationCount, getDeclarations, } from './symbol.js';
|
|
42
42
|
/** The type of an optional chain's expression with the chain's `undefined` removed. */
|
|
43
43
|
export function getOptionalExpressionType(c, exprType, expression) {
|
|
44
44
|
if (isExpressionOfOptionalChainRoot(expression))
|
|
@@ -73,26 +73,26 @@ export function checkCallExpression(c, node, checkMode) {
|
|
|
73
73
|
return getESSymbolLikeTypeForNode(c, walkUpParenthesizedExpressions(node.parent));
|
|
74
74
|
// An assertion call must name its target through explicitly typed declarations.
|
|
75
75
|
if (callQuestionDotToken(call) === undefined &&
|
|
76
|
-
node.parent.kind ===
|
|
76
|
+
node.parent.kind === 246 /* SyntaxKind.ExpressionStatement */ &&
|
|
77
77
|
(returnType.flags & 16 /* TypeFlags.Void */) !== 0 &&
|
|
78
78
|
getTypePredicateOfSignature(c, signature) !== undefined) {
|
|
79
79
|
if (!isDottedName(callee))
|
|
80
|
-
c.error(callee,
|
|
80
|
+
c.error(callee, 915 /* Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name */);
|
|
81
81
|
else if (getEffectsSignature(c, node) === undefined)
|
|
82
|
-
c.error(callee,
|
|
82
|
+
c.error(callee, 914 /* Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation */);
|
|
83
83
|
}
|
|
84
84
|
return returnType;
|
|
85
85
|
}
|
|
86
86
|
function walkUpParenthesizedExpressions(node) {
|
|
87
87
|
let current = node;
|
|
88
|
-
while (current.kind ===
|
|
88
|
+
while (current.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
89
89
|
current = current.parent;
|
|
90
90
|
return current;
|
|
91
91
|
}
|
|
92
92
|
/** Whether `node` calls the global `Symbol` or `Symbol.for`. */
|
|
93
93
|
export function isSymbolOrSymbolForCall(c, node) {
|
|
94
94
|
let left = node.expression;
|
|
95
|
-
if (left.kind ===
|
|
95
|
+
if (left.kind === 213 /* SyntaxKind.PropertyAccessExpression */ && getText(getName(left)) === 'for')
|
|
96
96
|
left = getExpression(left);
|
|
97
97
|
if (left.kind !== 79 /* SyntaxKind.Identifier */ || getText(left) !== 'Symbol')
|
|
98
98
|
return false;
|
|
@@ -107,12 +107,12 @@ export function checkNewExpression(c, node, checkMode) {
|
|
|
107
107
|
checkDeprecatedSignature(c, signature, node);
|
|
108
108
|
const declaration = signature.declaration;
|
|
109
109
|
if (declaration !== undefined &&
|
|
110
|
-
declaration.kind !==
|
|
111
|
-
declaration.kind !==
|
|
112
|
-
declaration.kind !==
|
|
110
|
+
declaration.kind !== 178 /* SyntaxKind.Constructor */ &&
|
|
111
|
+
declaration.kind !== 182 /* SyntaxKind.ConstructSignature */ &&
|
|
112
|
+
declaration.kind !== 187 /* SyntaxKind.ConstructorType */) {
|
|
113
113
|
// A call signature resolved for `new` makes the result `any`.
|
|
114
114
|
if (c.noImplicitAny)
|
|
115
|
-
c.error(node,
|
|
115
|
+
c.error(node, 1700 /* Diagnostics.X_new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type */);
|
|
116
116
|
return c.anyType;
|
|
117
117
|
}
|
|
118
118
|
return getReturnTypeOfSignature(c, signature);
|
|
@@ -154,19 +154,19 @@ export function resolveCallSignatureForContext(c, call) {
|
|
|
154
154
|
}
|
|
155
155
|
function resolveSignature(c, node, checkMode) {
|
|
156
156
|
switch (node.kind) {
|
|
157
|
-
case
|
|
157
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
158
158
|
return resolveCallExpression(c, node, checkMode);
|
|
159
|
-
case
|
|
159
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
160
160
|
return resolveNewExpression(c, node, checkMode);
|
|
161
|
-
case
|
|
161
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
162
162
|
return resolveTaggedTemplateExpression(c, node, checkMode);
|
|
163
|
-
case
|
|
164
|
-
case
|
|
165
|
-
case
|
|
163
|
+
case 288 /* SyntaxKind.JsxOpeningElement */:
|
|
164
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
165
|
+
case 291 /* SyntaxKind.JsxOpeningFragment */:
|
|
166
166
|
return resolveJsxOpeningLikeElement(c, node, checkMode);
|
|
167
|
-
case
|
|
167
|
+
case 172 /* SyntaxKind.Decorator */:
|
|
168
168
|
return resolveDecorator(c, node, checkMode);
|
|
169
|
-
case
|
|
169
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
170
170
|
return resolveInstanceofExpression(c, node, checkMode);
|
|
171
171
|
}
|
|
172
172
|
return resolveUntypedCall(c, node);
|
|
@@ -197,12 +197,12 @@ function resolveCallExpression(c, node, checkMode) {
|
|
|
197
197
|
const numConstructSignatures = getSignaturesOfType(c, apparentType, 1 /* SignatureKind.Construct */).length;
|
|
198
198
|
if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
199
199
|
if (!isErrorType(c, funcType) && callTypeArguments(node) !== undefined)
|
|
200
|
-
c.error(node,
|
|
200
|
+
c.error(node, 530 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
|
|
201
201
|
return resolveUntypedCall(c, node);
|
|
202
202
|
}
|
|
203
203
|
if (callSignatures.length === 0) {
|
|
204
204
|
if (numConstructSignatures !== 0)
|
|
205
|
-
c.error(node,
|
|
205
|
+
c.error(node, 531 /* Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new */, typeToString(c, funcType));
|
|
206
206
|
else
|
|
207
207
|
invocationError(c, callee, apparentType, 0 /* SignatureKind.Call */);
|
|
208
208
|
return resolveErrorCall(c, node);
|
|
@@ -246,15 +246,15 @@ function resolveNewExpression(c, node, checkMode) {
|
|
|
246
246
|
return resolveErrorCall(c, node);
|
|
247
247
|
if ((expressionType.flags & 1 /* TypeFlags.Any */) !== 0) {
|
|
248
248
|
if (node.typeArguments !== undefined && node.typeArguments.nodes.length !== 0)
|
|
249
|
-
c.error(node,
|
|
249
|
+
c.error(node, 530 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
|
|
250
250
|
return resolveUntypedCall(c, node);
|
|
251
251
|
}
|
|
252
252
|
const constructSignatures = getSignaturesOfType(c, expressionType, 1 /* SignatureKind.Construct */);
|
|
253
253
|
if (constructSignatures.length !== 0) {
|
|
254
|
-
if (!isConstructorAccessible(c, node, constructSignatures
|
|
254
|
+
if (!isConstructorAccessible(c, node, constructSignatures))
|
|
255
255
|
return resolveErrorCall(c, node);
|
|
256
256
|
if (someSignature(constructSignatures, (s) => (s.flags & 8 /* SignatureFlags.Abstract */) !== 0)) {
|
|
257
|
-
c.error(node,
|
|
257
|
+
c.error(node, 678 /* Diagnostics.Cannot_create_an_instance_of_an_abstract_class */);
|
|
258
258
|
return resolveErrorCall(c, node);
|
|
259
259
|
}
|
|
260
260
|
return resolveCall(c, node, constructSignatures, checkMode, 0 /* SignatureFlags.None */, undefined);
|
|
@@ -265,9 +265,9 @@ function resolveNewExpression(c, node, checkMode) {
|
|
|
265
265
|
const signature = resolveCall(c, node, callSignatures, checkMode, 0 /* SignatureFlags.None */, undefined);
|
|
266
266
|
if (!c.noImplicitAny) {
|
|
267
267
|
if (signature.declaration !== undefined && getReturnTypeOfSignature(c, signature) !== c.voidType)
|
|
268
|
-
c.error(node,
|
|
268
|
+
c.error(node, 533 /* Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword */);
|
|
269
269
|
if (getThisTypeOfSignature(c, signature) === c.voidType)
|
|
270
|
-
c.error(node,
|
|
270
|
+
c.error(node, 820 /* Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void */);
|
|
271
271
|
}
|
|
272
272
|
return signature;
|
|
273
273
|
}
|
|
@@ -312,8 +312,8 @@ function resolveTaggedTemplateExpression(c, node, checkMode) {
|
|
|
312
312
|
if (isUntypedFunctionCall(c, tagType, apparentType, callSignatures.length, numConstructSignatures))
|
|
313
313
|
return resolveUntypedCall(c, node);
|
|
314
314
|
if (callSignatures.length === 0) {
|
|
315
|
-
if (node.parent !== undefined && node.parent.kind ===
|
|
316
|
-
c.error(tag,
|
|
315
|
+
if (node.parent !== undefined && node.parent.kind === 211 /* SyntaxKind.ArrayLiteralExpression */) {
|
|
316
|
+
c.error(tag, 935 /* Diagnostics.It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked */);
|
|
317
317
|
return resolveErrorCall(c, node);
|
|
318
318
|
}
|
|
319
319
|
invocationError(c, tag, apparentType, 0 /* SignatureKind.Call */);
|
|
@@ -335,7 +335,7 @@ function resolveDecorator(c, node, checkMode) {
|
|
|
335
335
|
if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures))
|
|
336
336
|
return resolveUntypedCall(c, node);
|
|
337
337
|
if (isPotentiallyUncalledDecorator(c, node, callSignatures) &&
|
|
338
|
-
expression.kind !==
|
|
338
|
+
expression.kind !== 219 /* SyntaxKind.ParenthesizedExpression */) {
|
|
339
339
|
c.error(node, 265 /* Diagnostics.X_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0 */, getUncalledDecoratorText(node));
|
|
340
340
|
return resolveErrorCall(c, node);
|
|
341
341
|
}
|
|
@@ -360,15 +360,15 @@ export function isUntypedFunctionCall(c, funcType, apparentFuncType, numCallSign
|
|
|
360
360
|
}
|
|
361
361
|
export function resolveUntypedCall(c, node) {
|
|
362
362
|
// Type arguments are checked even though untyped calls can't accept them.
|
|
363
|
-
if (node.kind ===
|
|
364
|
-
node.kind ===
|
|
365
|
-
node.kind ===
|
|
363
|
+
if (node.kind === 215 /* SyntaxKind.CallExpression */ ||
|
|
364
|
+
node.kind === 216 /* SyntaxKind.NewExpression */ ||
|
|
365
|
+
node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */ ||
|
|
366
366
|
isJsxOpeningLikeElement(node))
|
|
367
367
|
for (const t of getCallTypeArguments(node))
|
|
368
368
|
checkSourceElement(c, t);
|
|
369
|
-
if (node.kind ===
|
|
369
|
+
if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
|
|
370
370
|
const template = node.template;
|
|
371
|
-
if (template.kind ===
|
|
371
|
+
if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
|
|
372
372
|
for (const span of template.templateSpans.nodes)
|
|
373
373
|
checkExpression(c, getExpression(span));
|
|
374
374
|
}
|
|
@@ -384,29 +384,29 @@ export function resolveErrorCall(c, node) {
|
|
|
384
384
|
function invocationError(c, errorTarget, apparentType, kind) {
|
|
385
385
|
const isCall = kind === 0 /* SignatureKind.Call */;
|
|
386
386
|
const parent = errorTarget.parent;
|
|
387
|
-
const target = errorTarget.kind ===
|
|
387
|
+
const target = errorTarget.kind === 213 /* SyntaxKind.PropertyAccessExpression */ &&
|
|
388
388
|
parent !== undefined &&
|
|
389
|
-
parent.kind ===
|
|
389
|
+
parent.kind === 215 /* SyntaxKind.CallExpression */
|
|
390
390
|
? getName(errorTarget)
|
|
391
391
|
: errorTarget;
|
|
392
392
|
let headMessage = isCall
|
|
393
|
-
?
|
|
394
|
-
:
|
|
393
|
+
? 532 /* Diagnostics.This_expression_is_not_callable */
|
|
394
|
+
: 534 /* Diagnostics.This_expression_is_not_constructable */;
|
|
395
395
|
// A get accessor called as a function.
|
|
396
396
|
if (parent !== undefined &&
|
|
397
|
-
parent.kind ===
|
|
397
|
+
parent.kind === 215 /* SyntaxKind.CallExpression */ &&
|
|
398
398
|
parent.arguments.nodes.length === 0) {
|
|
399
399
|
const resolvedSymbol = c.resolvedSymbols.get(errorTarget.id);
|
|
400
400
|
if (resolvedSymbol !== undefined && (resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) !== 0)
|
|
401
401
|
headMessage =
|
|
402
|
-
|
|
402
|
+
1397 /* Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without */;
|
|
403
403
|
}
|
|
404
404
|
c.addDiagnostic(chainDiagnostic(getInvocationErrorDetails(c, target, apparentType, isCall), headMessage));
|
|
405
405
|
}
|
|
406
406
|
function getInvocationErrorDetails(c, target, apparentType, isCall) {
|
|
407
407
|
const kind = isCall ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */;
|
|
408
408
|
if ((apparentType.flags & 134217728 /* TypeFlags.Union */) === 0)
|
|
409
|
-
return createDiagnosticForNode(target, isCall ?
|
|
409
|
+
return createDiagnosticForNode(target, isCall ? 896 /* Diagnostics.Type_0_has_no_call_signatures */ : 900 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, apparentType)]);
|
|
410
410
|
let diagnostic = undefined;
|
|
411
411
|
let hasSignatures = false;
|
|
412
412
|
for (const constituent of typesOf(apparentType)) {
|
|
@@ -418,19 +418,19 @@ function getInvocationErrorDetails(c, target, apparentType, isCall) {
|
|
|
418
418
|
}
|
|
419
419
|
else if (diagnostic === undefined) {
|
|
420
420
|
// The first non-callable constituent.
|
|
421
|
-
diagnostic = chainDiagnostic(createDiagnosticForNode(target, isCall ?
|
|
422
|
-
?
|
|
423
|
-
:
|
|
421
|
+
diagnostic = chainDiagnostic(createDiagnosticForNode(target, isCall ? 896 /* Diagnostics.Type_0_has_no_call_signatures */ : 900 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, constituent)]), isCall
|
|
422
|
+
? 895 /* Diagnostics.Not_all_constituents_of_type_0_are_callable */
|
|
423
|
+
: 899 /* Diagnostics.Not_all_constituents_of_type_0_are_constructable */, typeToString(c, apparentType));
|
|
424
424
|
if (hasSignatures)
|
|
425
425
|
break;
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
if (!hasSignatures)
|
|
429
|
-
return createDiagnosticForNode(target, isCall ?
|
|
429
|
+
return createDiagnosticForNode(target, isCall ? 894 /* Diagnostics.No_constituent_of_type_0_is_callable */ : 898 /* Diagnostics.No_constituent_of_type_0_is_constructable */, [typeToString(c, apparentType)]);
|
|
430
430
|
return (diagnostic ??
|
|
431
431
|
createDiagnosticForNode(target, isCall
|
|
432
|
-
?
|
|
433
|
-
:
|
|
432
|
+
? 897 /* Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other */
|
|
433
|
+
: 901 /* Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other */, [typeToString(c, apparentType)]));
|
|
434
434
|
}
|
|
435
435
|
function checkNonNullTypeForCall(c, t, node) {
|
|
436
436
|
return checkNonNullTypeEx(c, t, node, true);
|
|
@@ -456,7 +456,7 @@ export class SyntheticExpression extends Node {
|
|
|
456
456
|
isSpread;
|
|
457
457
|
tupleNameSource;
|
|
458
458
|
constructor(parent, type, isSpread, tupleNameSource) {
|
|
459
|
-
super(
|
|
459
|
+
super(239 /* SyntaxKind.SyntheticExpression */);
|
|
460
460
|
this.parent = parent;
|
|
461
461
|
this.pos = parent.pos;
|
|
462
462
|
this.end = parent.end;
|
|
@@ -473,12 +473,12 @@ export class SyntheticExpression extends Node {
|
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
function getCallArgumentNodes(node) {
|
|
476
|
-
if (node.kind ===
|
|
476
|
+
if (node.kind === 228 /* SyntaxKind.BinaryExpression */)
|
|
477
477
|
return [node.left];
|
|
478
|
-
if (node.kind ===
|
|
478
|
+
if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
|
|
479
479
|
const template = node.template;
|
|
480
480
|
const args = [template];
|
|
481
|
-
if (template.kind ===
|
|
481
|
+
if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
|
|
482
482
|
for (const span of template.templateSpans.nodes)
|
|
483
483
|
args.push(getExpression(span));
|
|
484
484
|
return args;
|
|
@@ -489,11 +489,11 @@ function getCallArgumentNodes(node) {
|
|
|
489
489
|
/** The arguments of a call, with spreads of tuples expanded and a tagged template's strings first. */
|
|
490
490
|
export function getEffectiveCallArguments(c, node) {
|
|
491
491
|
// A fragment's attributes have no `children` yet, like those of `<React.Fragment>`.
|
|
492
|
-
if (node.kind ===
|
|
492
|
+
if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
|
|
493
493
|
return [new SyntheticExpression(node, c.emptyFreshJsxObjectType, false, undefined)];
|
|
494
494
|
if (isJsxOpeningLikeElement(node))
|
|
495
495
|
return getEffectiveJsxArguments(node);
|
|
496
|
-
if (node.kind ===
|
|
496
|
+
if (node.kind === 172 /* SyntaxKind.Decorator */) {
|
|
497
497
|
// One synthetic argument per parameter of the decorator's call signature.
|
|
498
498
|
const expression = node.expression;
|
|
499
499
|
const args = [];
|
|
@@ -501,10 +501,10 @@ export function getEffectiveCallArguments(c, node) {
|
|
|
501
501
|
args.push(new SyntheticExpression(expression, t, false, undefined));
|
|
502
502
|
return args;
|
|
503
503
|
}
|
|
504
|
-
if (node.kind ===
|
|
504
|
+
if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
|
|
505
505
|
const template = node.template;
|
|
506
506
|
const args = [new SyntheticExpression(template, getGlobalTemplateStringsArrayType(c), false, undefined)];
|
|
507
|
-
if (template.kind ===
|
|
507
|
+
if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
|
|
508
508
|
for (const span of template.templateSpans.nodes)
|
|
509
509
|
args.push(getExpression(span));
|
|
510
510
|
return args;
|
|
@@ -518,7 +518,7 @@ export function getEffectiveCallArguments(c, node) {
|
|
|
518
518
|
for (let i = spreadIndex; i < args.length; i++) {
|
|
519
519
|
const arg = args[i];
|
|
520
520
|
// Spread expressions never have a contextual type, so caching is safe.
|
|
521
|
-
const spreadType = arg.kind ===
|
|
521
|
+
const spreadType = arg.kind === 232 /* SyntaxKind.SpreadElement */
|
|
522
522
|
? c.flowLoopStack.length !== 0
|
|
523
523
|
? checkExpression(c, arg.expression)
|
|
524
524
|
: checkExpressionCached(c, arg.expression)
|
|
@@ -538,7 +538,7 @@ export function getEffectiveCallArguments(c, node) {
|
|
|
538
538
|
}
|
|
539
539
|
/** Checks an argument with the parameter type as its contextual type. */
|
|
540
540
|
function checkArgument(c, arg, paramType, context, checkMode) {
|
|
541
|
-
if (arg.kind ===
|
|
541
|
+
if (arg.kind === 239 /* SyntaxKind.SyntheticExpression */)
|
|
542
542
|
return checkSyntheticExpression(c, arg);
|
|
543
543
|
return checkExpressionWithContextualType(c, arg, paramType, context, checkMode);
|
|
544
544
|
}
|
|
@@ -555,8 +555,8 @@ function getSpreadArgumentIndex(args) {
|
|
|
555
555
|
return -1;
|
|
556
556
|
}
|
|
557
557
|
function isSpreadArgument(arg) {
|
|
558
|
-
return (arg.kind ===
|
|
559
|
-
(arg.kind ===
|
|
558
|
+
return (arg.kind === 232 /* SyntaxKind.SpreadElement */ ||
|
|
559
|
+
(arg.kind === 239 /* SyntaxKind.SyntheticExpression */ && arg.isSpread));
|
|
560
560
|
}
|
|
561
561
|
/** The rest arguments from `index` as a tuple, or an array for a trailing spread to a rest parameter. */
|
|
562
562
|
function getSpreadArgumentType(c, call, args, index, argCount, restType, context, checkMode) {
|
|
@@ -565,12 +565,12 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
|
|
|
565
565
|
const arg = args[argCount - 1];
|
|
566
566
|
if (isSpreadArgument(arg)) {
|
|
567
567
|
// A spread in the last position to a rest parameter: both are `...x` forms.
|
|
568
|
-
const spreadType = arg.kind ===
|
|
568
|
+
const spreadType = arg.kind === 239 /* SyntaxKind.SyntheticExpression */
|
|
569
569
|
? arg.type
|
|
570
570
|
: checkExpressionWithContextualType(c, arg.expression, restType, context, checkMode);
|
|
571
571
|
if (isArrayLikeType(c, spreadType))
|
|
572
572
|
return getMutableArrayOrTupleType(c, spreadType);
|
|
573
|
-
const errorNode = arg.kind ===
|
|
573
|
+
const errorNode = arg.kind === 232 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
|
|
574
574
|
return createArrayTypeEx(c, checkIteratedTypeOrElementType(c, 33 /* IterationUse.Spread */, spreadType, c.undefinedType, errorNode), inConstContext);
|
|
575
575
|
}
|
|
576
576
|
}
|
|
@@ -579,7 +579,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
|
|
|
579
579
|
for (let i = index; i < argCount; i++) {
|
|
580
580
|
const arg = args[i];
|
|
581
581
|
if (isSpreadArgument(arg)) {
|
|
582
|
-
const spreadType = arg.kind ===
|
|
582
|
+
const spreadType = arg.kind === 239 /* SyntaxKind.SyntheticExpression */
|
|
583
583
|
? arg.type
|
|
584
584
|
: checkExpression(c, arg.expression);
|
|
585
585
|
if (isArrayLikeType(c, spreadType)) {
|
|
@@ -587,7 +587,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
|
|
|
587
587
|
infos.push(new TupleElementInfo(8 /* ElementFlags.Variadic */, undefined));
|
|
588
588
|
}
|
|
589
589
|
else {
|
|
590
|
-
const errorNode = arg.kind ===
|
|
590
|
+
const errorNode = arg.kind === 232 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
|
|
591
591
|
types.push(checkIteratedTypeOrElementType(c, 33 /* IterationUse.Spread */, spreadType, c.undefinedType, errorNode));
|
|
592
592
|
infos.push(new TupleElementInfo(4 /* ElementFlags.Rest */, undefined));
|
|
593
593
|
}
|
|
@@ -600,7 +600,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
|
|
|
600
600
|
const hasPrimitiveContextualType = inConstContext ||
|
|
601
601
|
maybeTypeOfKind(contextualType, 12713980 /* TypeFlags.Primitive */ | 2097152 /* TypeFlags.Index */ | 4194304 /* TypeFlags.TemplateLiteral */ | 8388608 /* TypeFlags.StringMapping */);
|
|
602
602
|
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(c, argType) : getWidenedLiteralType(c, argType));
|
|
603
|
-
infos.push(new TupleElementInfo(1 /* ElementFlags.Required */, arg.kind ===
|
|
603
|
+
infos.push(new TupleElementInfo(1 /* ElementFlags.Required */, arg.kind === 239 /* SyntaxKind.SyntheticExpression */ ? arg.tupleNameSource : undefined));
|
|
604
604
|
}
|
|
605
605
|
return createTupleTypeEx(c, types, infos, inConstContext && !someType(restType, (t) => isMutableArrayLikeType(c, t)));
|
|
606
606
|
}
|
|
@@ -626,6 +626,8 @@ class CallState {
|
|
|
626
626
|
candidates;
|
|
627
627
|
argCheckMode = 0 /* CheckMode.Normal */;
|
|
628
628
|
isSingleNonGenericCandidate = false;
|
|
629
|
+
/** The call is resolved while its own resolution is in progress. */
|
|
630
|
+
recursiveResolution = false;
|
|
629
631
|
candidatesForArgumentError = [];
|
|
630
632
|
candidateForArgumentArityError = undefined;
|
|
631
633
|
candidateForTypeArgumentError = undefined;
|
|
@@ -637,9 +639,9 @@ class CallState {
|
|
|
637
639
|
}
|
|
638
640
|
}
|
|
639
641
|
function getCallTypeArguments(node) {
|
|
640
|
-
if (node.kind ===
|
|
642
|
+
if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */ || node.kind === 172 /* SyntaxKind.Decorator */)
|
|
641
643
|
return [];
|
|
642
|
-
if (node.kind ===
|
|
644
|
+
if (node.kind === 215 /* SyntaxKind.CallExpression */ && node.expression.kind === 107 /* SyntaxKind.SuperKeyword */)
|
|
643
645
|
return [];
|
|
644
646
|
const list = getTypeArgumentList(node);
|
|
645
647
|
return list !== undefined ? list.nodes : [];
|
|
@@ -656,14 +658,27 @@ export function resolveCall(c, node, signatures, checkMode, callChainFlags, head
|
|
|
656
658
|
// included in a second pass with their contextual types fixed.
|
|
657
659
|
s.isSingleNonGenericCandidate = candidates.length === 1 && candidates[0].typeParameters.length === 0;
|
|
658
660
|
// Decorator arguments are synthetic, so never context sensitive.
|
|
659
|
-
if (node.kind !==
|
|
661
|
+
if (node.kind !== 172 /* SyntaxKind.Decorator */ && !s.isSingleNonGenericCandidate && someContextSensitive(c, s.args))
|
|
660
662
|
s.argCheckMode = 4 /* CheckMode.SkipContextSensitive */;
|
|
661
663
|
// A subtype pass picks the best overload; assignability decides whether the call is an error.
|
|
662
664
|
let result = undefined;
|
|
665
|
+
const callResolutionDepth = c.callResolutionDepth;
|
|
666
|
+
const callResolutionStack = c.callResolutionStack;
|
|
667
|
+
for (let i = 0; i < callResolutionDepth; i++)
|
|
668
|
+
if (callResolutionStack[i] === node) {
|
|
669
|
+
s.recursiveResolution = true;
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
if (callResolutionDepth < callResolutionStack.length)
|
|
673
|
+
callResolutionStack[callResolutionDepth] = node;
|
|
674
|
+
else
|
|
675
|
+
callResolutionStack.push(node);
|
|
676
|
+
c.callResolutionDepth = callResolutionDepth + 1;
|
|
663
677
|
if (candidates.length > 1)
|
|
664
678
|
result = chooseOverload(c, s, c.subtypeRelation);
|
|
665
679
|
if (result === undefined)
|
|
666
680
|
result = chooseOverload(c, s, c.assignableRelation);
|
|
681
|
+
c.callResolutionDepth = callResolutionDepth;
|
|
667
682
|
if (result !== undefined)
|
|
668
683
|
return result;
|
|
669
684
|
result = getCandidateForOverloadFailure(c, node, s.candidates, s.args, checkMode);
|
|
@@ -764,7 +779,12 @@ function chooseOverload(c, s, relation) {
|
|
|
764
779
|
}
|
|
765
780
|
}
|
|
766
781
|
else {
|
|
767
|
-
inferenceContext = createInferenceContext(c, candidate.typeParameters, candidate,
|
|
782
|
+
inferenceContext = createInferenceContext(c, candidate.typeParameters, candidate,
|
|
783
|
+
// A recursive resolution of a call with one candidate skips constraint checks during inference, which
|
|
784
|
+
// would otherwise report circularities.
|
|
785
|
+
(s.recursiveResolution && s.candidates.length === 1
|
|
786
|
+
? 8 /* InferenceFlags.NoConstraintChecks */
|
|
787
|
+
: 0 /* InferenceFlags.None */) | (isInJSFile(s.node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */), undefined);
|
|
768
788
|
typeArgumentTypes = inferTypeArguments(c, s.node, candidate, s.args, s.argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext);
|
|
769
789
|
if ((inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */) !== 0)
|
|
770
790
|
s.argCheckMode |= 8 /* CheckMode.SkipGenericFunctions */;
|
|
@@ -808,7 +828,7 @@ function isInJSFile(node) {
|
|
|
808
828
|
return node !== undefined && (node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0;
|
|
809
829
|
}
|
|
810
830
|
function hasCorrectArity(c, node, args, signature) {
|
|
811
|
-
if (node.kind ===
|
|
831
|
+
if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
|
|
812
832
|
return true;
|
|
813
833
|
let argCount;
|
|
814
834
|
let callIsIncomplete = false;
|
|
@@ -825,10 +845,10 @@ function hasCorrectArity(c, node, args, signature) {
|
|
|
825
845
|
// A component's extra parameters, such as a legacy context, are provided by the library.
|
|
826
846
|
effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
|
|
827
847
|
}
|
|
828
|
-
else if (node.kind ===
|
|
848
|
+
else if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
|
|
829
849
|
argCount = args.length;
|
|
830
850
|
const template = node.template;
|
|
831
|
-
if (template.kind ===
|
|
851
|
+
if (template.kind === 230 /* SyntaxKind.TemplateExpression */) {
|
|
832
852
|
// A template without a tail literal makes the call incomplete.
|
|
833
853
|
const spans = template.templateSpans.nodes;
|
|
834
854
|
const literal = spans[spans.length - 1].literal;
|
|
@@ -837,10 +857,10 @@ function hasCorrectArity(c, node, args, signature) {
|
|
|
837
857
|
else
|
|
838
858
|
callIsIncomplete = isUnterminatedLiteral(template);
|
|
839
859
|
}
|
|
840
|
-
else if (node.kind ===
|
|
860
|
+
else if (node.kind === 172 /* SyntaxKind.Decorator */) {
|
|
841
861
|
argCount = getDecoratorArgumentCount(c, node, signature);
|
|
842
862
|
}
|
|
843
|
-
else if (node.kind ===
|
|
863
|
+
else if (node.kind === 216 /* SyntaxKind.NewExpression */ && node.arguments === undefined) {
|
|
844
864
|
// `new C`
|
|
845
865
|
return getMinArgumentCount(c, signature) === 0;
|
|
846
866
|
}
|
|
@@ -886,7 +906,7 @@ function checkTypeArguments(c, signature, typeArgumentNodes, reportErrors, headM
|
|
|
886
906
|
continue;
|
|
887
907
|
const typeArgument = typeArgumentTypes[i];
|
|
888
908
|
const diagnostics = [];
|
|
889
|
-
if (!checkTypeRelatedTo(c, typeArgument, getTypeWithThisArgument(c, instantiateType(c, constraint, mapper), typeArgument, false), c.assignableRelation, reportErrors ? typeArgumentNodes[i] : undefined, headMessage ??
|
|
909
|
+
if (!checkTypeRelatedTo(c, typeArgument, getTypeWithThisArgument(c, instantiateType(c, constraint, mapper), typeArgument, false), c.assignableRelation, reportErrors ? typeArgumentNodes[i] : undefined, headMessage ?? 527 /* Diagnostics.Type_0_does_not_satisfy_the_constraint_1 */, diagnostics)) {
|
|
890
910
|
if (diagnostics.length !== 0)
|
|
891
911
|
c.addDiagnostic(diagnostics[0]);
|
|
892
912
|
return undefined;
|
|
@@ -895,26 +915,26 @@ function checkTypeArguments(c, signature, typeArgumentNodes, reportErrors, headM
|
|
|
895
915
|
return typeArgumentTypes;
|
|
896
916
|
}
|
|
897
917
|
function isSignatureApplicable(c, node, args, signature, relation, checkMode, reportErrors, diagnosticOutput) {
|
|
898
|
-
if (isJsxOpeningLikeElement(node) || node.kind ===
|
|
918
|
+
if (isJsxOpeningLikeElement(node) || node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
|
|
899
919
|
return checkApplicableSignatureForJsxCallLikeElement(c, node, signature, relation, checkMode, reportErrors, diagnosticOutput);
|
|
900
920
|
const thisType = getThisTypeOfSignature(c, signature);
|
|
901
921
|
if (thisType !== undefined &&
|
|
902
922
|
thisType !== c.voidType &&
|
|
903
|
-
!(node.kind ===
|
|
904
|
-
(node.kind ===
|
|
923
|
+
!(node.kind === 216 /* SyntaxKind.NewExpression */ ||
|
|
924
|
+
(node.kind === 215 /* SyntaxKind.CallExpression */ && isSuperProperty(getExpression(node))))) {
|
|
905
925
|
// Without an `x.f` callee the `this` argument is `void`.
|
|
906
926
|
const thisArgumentNode = getThisArgumentOfCall(c, node);
|
|
907
927
|
const thisArgumentType = getThisArgumentType(c, thisArgumentNode);
|
|
908
928
|
const errorNode = reportErrors ? (thisArgumentNode ?? node) : undefined;
|
|
909
|
-
if (!checkTypeRelatedTo(c, thisArgumentType, thisType, relation, errorNode,
|
|
929
|
+
if (!checkTypeRelatedTo(c, thisArgumentType, thisType, relation, errorNode, 824 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, diagnosticOutput))
|
|
910
930
|
return false;
|
|
911
931
|
}
|
|
912
|
-
const headMessage =
|
|
932
|
+
const headMessage = 528 /* Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 */;
|
|
913
933
|
const restType = getNonArrayRestType(c, signature);
|
|
914
934
|
const argCount = restType !== undefined ? Math.min(getParameterCount(c, signature) - 1, args.length) : args.length;
|
|
915
935
|
for (let i = 0; i < argCount; i++) {
|
|
916
936
|
const arg = args[i];
|
|
917
|
-
if (arg.kind ===
|
|
937
|
+
if (arg.kind === 234 /* SyntaxKind.OmittedExpression */)
|
|
918
938
|
continue;
|
|
919
939
|
const paramType = getTypeAtPosition(c, signature, i);
|
|
920
940
|
const argType = checkArgument(c, arg, paramType, undefined, checkMode);
|
|
@@ -960,20 +980,20 @@ function isUnterminatedLiteral(node) {
|
|
|
960
980
|
return false;
|
|
961
981
|
}
|
|
962
982
|
function isSuperProperty(node) {
|
|
963
|
-
return ((node.kind ===
|
|
983
|
+
return ((node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 214 /* SyntaxKind.ElementAccessExpression */) &&
|
|
964
984
|
getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */);
|
|
965
985
|
}
|
|
966
986
|
/** The `this` argument of `x.f(...)` and `x[f](...)`. */
|
|
967
987
|
function getThisArgumentOfCall(c, node) {
|
|
968
988
|
// `x instanceof C` calls `C[Symbol.hasInstance](x)`.
|
|
969
|
-
if (node.kind ===
|
|
989
|
+
if (node.kind === 228 /* SyntaxKind.BinaryExpression */)
|
|
970
990
|
return node.right;
|
|
971
991
|
let expression = undefined;
|
|
972
|
-
if (node.kind ===
|
|
992
|
+
if (node.kind === 215 /* SyntaxKind.CallExpression */)
|
|
973
993
|
expression = node.expression;
|
|
974
|
-
else if (node.kind ===
|
|
994
|
+
else if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */)
|
|
975
995
|
expression = node.tag;
|
|
976
|
-
else if (node.kind ===
|
|
996
|
+
else if (node.kind === 172 /* SyntaxKind.Decorator */ && !c.legacyDecorators)
|
|
977
997
|
expression = node.expression;
|
|
978
998
|
if (expression === undefined)
|
|
979
999
|
return undefined;
|
|
@@ -983,13 +1003,13 @@ function getThisArgumentOfCall(c, node) {
|
|
|
983
1003
|
function skipOuterExpressionsForCall(node) {
|
|
984
1004
|
for (;;) {
|
|
985
1005
|
switch (node.kind) {
|
|
986
|
-
case
|
|
987
|
-
case
|
|
988
|
-
case
|
|
989
|
-
case
|
|
990
|
-
case
|
|
991
|
-
case
|
|
992
|
-
case
|
|
1006
|
+
case 219 /* SyntaxKind.ParenthesizedExpression */:
|
|
1007
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
1008
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
1009
|
+
case 240 /* SyntaxKind.SatisfiesExpression */:
|
|
1010
|
+
case 237 /* SyntaxKind.NonNullExpression */:
|
|
1011
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
1012
|
+
case 349 /* SyntaxKind.PartiallyEmittedExpression */:
|
|
993
1013
|
node = getExpression(node);
|
|
994
1014
|
continue;
|
|
995
1015
|
}
|
|
@@ -1018,7 +1038,7 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
|
|
|
1018
1038
|
}
|
|
1019
1039
|
}
|
|
1020
1040
|
// Decorators have no contextual type.
|
|
1021
|
-
const contextualType = node.kind ===
|
|
1041
|
+
const contextualType = node.kind === 172 /* SyntaxKind.Decorator */
|
|
1022
1042
|
? undefined
|
|
1023
1043
|
: getContextualTypeEx(c, node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */);
|
|
1024
1044
|
if (contextualType !== undefined) {
|
|
@@ -1038,14 +1058,14 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
|
|
|
1038
1058
|
? getOrCreateTypeFromSignature(c, getSignatureInstantiationWithoutFillingInTypeArguments(c, contextualSignature, contextualSignature.typeParameters))
|
|
1039
1059
|
: instantiatedType;
|
|
1040
1060
|
// Return type inferences have the lowest priority.
|
|
1041
|
-
|
|
1061
|
+
inferTypesFromUnstarted(c, signature, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */);
|
|
1042
1062
|
}
|
|
1043
1063
|
// A separate pass for the mapper used to instantiate generic contextual types, from the outer
|
|
1044
1064
|
// return mapper so that inferences can't reference the type parameters being inferred.
|
|
1045
1065
|
const returnContext = createInferenceContext(c, signature.typeParameters, signature, context.flags, undefined);
|
|
1046
1066
|
const outerReturnMapper = outerContext !== undefined ? createOuterReturnMapper(c, outerContext) : undefined;
|
|
1047
1067
|
const returnSourceType = instantiateType(c, contextualType, outerReturnMapper);
|
|
1048
|
-
|
|
1068
|
+
inferTypesFromUnstarted(c, signature, returnContext.inferences, returnSourceType, inferenceTargetType, 0 /* InferencePriority.None */);
|
|
1049
1069
|
context.returnMapper = someInferenceHasCandidates(returnContext.inferences)
|
|
1050
1070
|
? getMapperFromContext(cloneInferredPartOfContext(c, returnContext))
|
|
1051
1071
|
: undefined;
|
|
@@ -1065,7 +1085,7 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
|
|
|
1065
1085
|
inferTypes(c, context.inferences, getThisArgumentType(c, getThisArgumentOfCall(c, node)), thisType, 0 /* InferencePriority.None */, false);
|
|
1066
1086
|
for (let i = 0; i < argCount; i++) {
|
|
1067
1087
|
const arg = args[i];
|
|
1068
|
-
if (arg.kind ===
|
|
1088
|
+
if (arg.kind === 234 /* SyntaxKind.OmittedExpression */)
|
|
1069
1089
|
continue;
|
|
1070
1090
|
const paramType = getTypeAtPosition(c, signature, i);
|
|
1071
1091
|
if (couldContainTypeVariables(c, paramType)) {
|
|
@@ -1222,13 +1242,13 @@ function reportCallResolutionErrors(c, s, signatures, headMessage) {
|
|
|
1222
1242
|
isSignatureApplicable(c, s.node, s.args, last, c.assignableRelation, 0 /* CheckMode.Normal */, true, diagnostics);
|
|
1223
1243
|
for (let diagnostic of diagnostics) {
|
|
1224
1244
|
if (s.candidatesForArgumentError.length > 1) {
|
|
1225
|
-
diagnostic = chainDiagnostic(diagnostic,
|
|
1226
|
-
diagnostic = chainDiagnostic(diagnostic,
|
|
1245
|
+
diagnostic = chainDiagnostic(diagnostic, 909 /* Diagnostics.The_last_overload_gave_the_following_error */);
|
|
1246
|
+
diagnostic = chainDiagnostic(diagnostic, 908 /* Diagnostics.No_overload_matches_this_call */);
|
|
1227
1247
|
}
|
|
1228
1248
|
if (headMessage !== undefined)
|
|
1229
1249
|
diagnostic = chainDiagnostic(diagnostic, headMessage);
|
|
1230
1250
|
if (last.declaration !== undefined && s.candidatesForArgumentError.length > 1)
|
|
1231
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(last.declaration,
|
|
1251
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(last.declaration, 910 /* Diagnostics.The_last_overload_is_declared_here */, []));
|
|
1232
1252
|
addImplementationSuccessElaboration(c, s, last, diagnostic);
|
|
1233
1253
|
c.addDiagnostic(diagnostic);
|
|
1234
1254
|
}
|
|
@@ -1237,7 +1257,7 @@ function reportCallResolutionErrors(c, s, signatures, headMessage) {
|
|
|
1237
1257
|
c.addDiagnostic(getArgumentArityError(c, s.node, [s.candidateForArgumentArityError], s.args, headMessage));
|
|
1238
1258
|
else if (s.candidateForTypeArgumentError !== undefined)
|
|
1239
1259
|
checkTypeArguments(c, s.candidateForTypeArgumentError, getCallTypeArguments(s.node), true, headMessage);
|
|
1240
|
-
else if (s.node.kind !==
|
|
1260
|
+
else if (s.node.kind !== 291 /* SyntaxKind.JsxOpeningFragment */) {
|
|
1241
1261
|
const withCorrectTypeArgumentArity = [];
|
|
1242
1262
|
for (const sig of signatures)
|
|
1243
1263
|
if (hasCorrectTypeArgumentArity(c, sig, s.typeArguments))
|
|
@@ -1270,15 +1290,35 @@ function addImplementationSuccessElaboration(c, s, failed, diagnostic) {
|
|
|
1270
1290
|
localState.candidateForArgumentArityError = s.candidateForArgumentArityError;
|
|
1271
1291
|
localState.candidateForTypeArgumentError = s.candidateForTypeArgumentError;
|
|
1272
1292
|
if (chooseOverload(c, localState, c.assignableRelation) !== undefined)
|
|
1273
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(implementation,
|
|
1293
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(implementation, 932 /* Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible */, []));
|
|
1274
1294
|
}
|
|
1275
1295
|
function withHeadMessage(diagnostic, headMessage) {
|
|
1276
1296
|
return headMessage !== undefined ? chainDiagnostic(diagnostic, headMessage) : diagnostic;
|
|
1277
1297
|
}
|
|
1298
|
+
/** Whether `node` calls the `resolve` parameter of an executor passed to the global `new Promise`. */
|
|
1299
|
+
function isPromiseResolveArityError(c, node) {
|
|
1300
|
+
if (node.kind !== 215 /* SyntaxKind.CallExpression */)
|
|
1301
|
+
return false;
|
|
1302
|
+
const callee = getExpression(node);
|
|
1303
|
+
if (callee.kind !== 79 /* SyntaxKind.Identifier */)
|
|
1304
|
+
return false;
|
|
1305
|
+
const symbol = resolveName(c, callee, getText(callee), 111551 /* SymbolFlags.Value */, undefined, false, false);
|
|
1306
|
+
const declaration = symbol?.valueDeclaration;
|
|
1307
|
+
if (declaration === undefined ||
|
|
1308
|
+
declaration.kind !== 171 /* SyntaxKind.Parameter */ ||
|
|
1309
|
+
!isFunctionExpressionOrArrowFunction(declaration.parent) ||
|
|
1310
|
+
declaration.parent.parent?.kind !== 216 /* SyntaxKind.NewExpression */)
|
|
1311
|
+
return false;
|
|
1312
|
+
const constructor = getExpression(declaration.parent.parent);
|
|
1313
|
+
if (constructor === undefined || constructor.kind !== 79 /* SyntaxKind.Identifier */)
|
|
1314
|
+
return false;
|
|
1315
|
+
const globalPromiseSymbol = getGlobalValueSymbol(c, 'Promise', false);
|
|
1316
|
+
return globalPromiseSymbol !== undefined && getResolvedSymbol(c, constructor) === globalPromiseSymbol;
|
|
1317
|
+
}
|
|
1278
1318
|
function getArgumentArityError(c, node, signatures, args, headMessage) {
|
|
1279
1319
|
const spreadIndex = getSpreadArgumentIndex(args);
|
|
1280
1320
|
if (spreadIndex > -1)
|
|
1281
|
-
return createDiagnosticForNode(args[spreadIndex],
|
|
1321
|
+
return createDiagnosticForNode(args[spreadIndex], 718 /* Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter */, []);
|
|
1282
1322
|
let minCount = Number.MAX_SAFE_INTEGER;
|
|
1283
1323
|
let maxCount = Number.MIN_SAFE_INTEGER;
|
|
1284
1324
|
let maxBelow = Number.MIN_SAFE_INTEGER;
|
|
@@ -1309,17 +1349,23 @@ function getArgumentArityError(c, node, signatures, args, headMessage) {
|
|
|
1309
1349
|
: minCount < maxCount
|
|
1310
1350
|
? minCount + '-' + maxCount
|
|
1311
1351
|
: String(minCount);
|
|
1352
|
+
// `resolve()` without an argument, where `resolve` is the parameter of a `new Promise` executor.
|
|
1353
|
+
const isVoidPromiseError = !hasRestParameter && parameterRange === '1' && args.length === 0 && isPromiseResolveArityError(c, node);
|
|
1312
1354
|
const errorNode = getErrorNodeForCallNode(node);
|
|
1313
|
-
|
|
1355
|
+
if (isVoidPromiseError && isInJSFile(node))
|
|
1356
|
+
return createDiagnosticForNode(errorNode, 948 /* Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments */, []);
|
|
1357
|
+
const message = node.kind === 172 /* SyntaxKind.Decorator */
|
|
1314
1358
|
? hasRestParameter
|
|
1315
1359
|
? 228 /* Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_at_least_0 */
|
|
1316
1360
|
: 227 /* Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0 */
|
|
1317
1361
|
: hasRestParameter
|
|
1318
|
-
?
|
|
1319
|
-
:
|
|
1362
|
+
? 717 /* Diagnostics.Expected_at_least_0_arguments_but_got_1 */
|
|
1363
|
+
: isVoidPromiseError
|
|
1364
|
+
? 933 /* Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise */
|
|
1365
|
+
: 716 /* Diagnostics.Expected_0_arguments_but_got_1 */;
|
|
1320
1366
|
if (minCount < args.length && args.length < maxCount)
|
|
1321
1367
|
// Between min and max, but no overload matches.
|
|
1322
|
-
return withHeadMessage(createDiagnosticForNode(errorNode,
|
|
1368
|
+
return withHeadMessage(createDiagnosticForNode(errorNode, 733 /* Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments */, [String(args.length), String(maxBelow), String(minAbove)]), headMessage);
|
|
1323
1369
|
if (args.length < minCount) {
|
|
1324
1370
|
// Too short: the error spans the callee.
|
|
1325
1371
|
const diagnostic = withHeadMessage(createDiagnosticForNode(errorNode, message, [parameterRange, String(args.length)]), headMessage);
|
|
@@ -1329,14 +1375,14 @@ function getArgumentArityError(c, node, signatures, args, headMessage) {
|
|
|
1329
1375
|
const parameter = params !== undefined && index < params.nodes.length ? params.nodes[index] : undefined;
|
|
1330
1376
|
if (parameter !== undefined) {
|
|
1331
1377
|
const name = getName(parameter);
|
|
1332
|
-
if (name.kind ===
|
|
1333
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter,
|
|
1378
|
+
if (name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)
|
|
1379
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1375 /* Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided */, []));
|
|
1334
1380
|
else if (parameter.dotDotDotToken !== undefined)
|
|
1335
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter,
|
|
1381
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1399 /* Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided */, [
|
|
1336
1382
|
getTextOfName(name),
|
|
1337
1383
|
]));
|
|
1338
1384
|
else
|
|
1339
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter,
|
|
1385
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1374 /* Diagnostics.An_argument_for_0_was_not_provided */, [getTextOfName(name)]));
|
|
1340
1386
|
}
|
|
1341
1387
|
return diagnostic;
|
|
1342
1388
|
}
|
|
@@ -1366,7 +1412,7 @@ function getTypeArgumentArityError(c, node, signatures, typeArguments, headMessa
|
|
|
1366
1412
|
const minCount = getMinTypeArgumentCount(c, sig.typeParameters);
|
|
1367
1413
|
const maxCount = sig.typeParameters.length;
|
|
1368
1414
|
const expected = minCount < maxCount ? minCount + '-' + maxCount : String(minCount);
|
|
1369
|
-
diagnostic = new Diagnostic(file.diagnosticFile(), pos, end,
|
|
1415
|
+
diagnostic = new Diagnostic(file.diagnosticFile(), pos, end, 719 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
|
|
1370
1416
|
expected,
|
|
1371
1417
|
String(argCount),
|
|
1372
1418
|
]);
|
|
@@ -1384,8 +1430,8 @@ function getTypeArgumentArityError(c, node, signatures, typeArguments, headMessa
|
|
|
1384
1430
|
}
|
|
1385
1431
|
diagnostic =
|
|
1386
1432
|
belowArgCount !== Number.MIN_SAFE_INTEGER && aboveArgCount !== Number.MAX_SAFE_INTEGER
|
|
1387
|
-
? new Diagnostic(file.diagnosticFile(), pos, end,
|
|
1388
|
-
: new Diagnostic(file.diagnosticFile(), pos, end,
|
|
1433
|
+
? new Diagnostic(file.diagnosticFile(), pos, end, 882 /* Diagnostics.No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments */, [String(argCount), String(belowArgCount), String(aboveArgCount)])
|
|
1434
|
+
: new Diagnostic(file.diagnosticFile(), pos, end, 719 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
|
|
1389
1435
|
String(belowArgCount === Number.MIN_SAFE_INTEGER ? aboveArgCount : belowArgCount),
|
|
1390
1436
|
String(argCount),
|
|
1391
1437
|
]);
|
|
@@ -1396,9 +1442,9 @@ function getTextOfName(name) {
|
|
|
1396
1442
|
return name.kind === 79 /* SyntaxKind.Identifier */ ? getText(name) : '';
|
|
1397
1443
|
}
|
|
1398
1444
|
function getErrorNodeForCallNode(node) {
|
|
1399
|
-
if (node.kind ===
|
|
1445
|
+
if (node.kind === 215 /* SyntaxKind.CallExpression */) {
|
|
1400
1446
|
const callee = node.expression;
|
|
1401
|
-
if (callee.kind ===
|
|
1447
|
+
if (callee.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
1402
1448
|
return getName(callee);
|
|
1403
1449
|
return callee;
|
|
1404
1450
|
}
|
|
@@ -1520,14 +1566,14 @@ export function checkExpressionWithTypeArguments(c, node) {
|
|
|
1520
1566
|
for (const a of typeArguments.nodes)
|
|
1521
1567
|
checkSourceElement(c, a);
|
|
1522
1568
|
let exprType;
|
|
1523
|
-
if (node.kind ===
|
|
1569
|
+
if (node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */) {
|
|
1524
1570
|
let parent = node.parent;
|
|
1525
|
-
while (parent.kind ===
|
|
1571
|
+
while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
|
|
1526
1572
|
parent = parent.parent;
|
|
1527
|
-
if (parent.kind ===
|
|
1573
|
+
if (parent.kind === 228 /* SyntaxKind.BinaryExpression */ &&
|
|
1528
1574
|
parent.operatorToken.kind === 103 /* SyntaxKind.InstanceOfKeyword */ &&
|
|
1529
1575
|
isNodeDescendantOf(node, parent.right))
|
|
1530
|
-
c.error(node,
|
|
1576
|
+
c.error(node, 975 /* Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression */);
|
|
1531
1577
|
exprType = checkExpression(c, getExpression(node));
|
|
1532
1578
|
}
|
|
1533
1579
|
else
|
|
@@ -1549,7 +1595,7 @@ export function getInstantiationExpressionType(c, exprType, node) {
|
|
|
1549
1595
|
const errorType = instantiator.hasSomeApplicableSignature ? instantiator.nonApplicableType : exprType;
|
|
1550
1596
|
if (errorType !== undefined) {
|
|
1551
1597
|
const file = getSourceFileOfNode(node);
|
|
1552
|
-
c.addDiagnostic(new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, typeArgumentList.pos), typeArgumentList.end,
|
|
1598
|
+
c.addDiagnostic(new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, typeArgumentList.pos), typeArgumentList.end, 785 /* Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable */, [typeToString(c, errorType)]));
|
|
1553
1599
|
}
|
|
1554
1600
|
return result;
|
|
1555
1601
|
}
|
|
@@ -1592,7 +1638,11 @@ class InstantiationExpressionInstantiator {
|
|
|
1592
1638
|
if (callSignatures.length !== 0 || constructSignatures.length !== 0)
|
|
1593
1639
|
this.hasApplicableSignature = true;
|
|
1594
1640
|
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
1595
|
-
|
|
1641
|
+
// A symbol of its own, with the declarations of the instantiated type's symbol.
|
|
1642
|
+
const symbol = c.newSymbol(0 /* SymbolFlags.None */, "\uFFFEinstantiationExpression" /* InternalSymbolName.InstantiationExpression */);
|
|
1643
|
+
if (t.symbol !== undefined)
|
|
1644
|
+
copyDeclarations(symbol, t.symbol);
|
|
1645
|
+
const result = newObjectType(c, 16 /* ObjectFlags.Anonymous */ | 16777216 /* ObjectFlags.InstantiationExpressionType */, symbol);
|
|
1596
1646
|
setStructuredTypeMembers(c, result, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
1597
1647
|
result.node = this.node;
|
|
1598
1648
|
return result;
|