Skip to content

Commit dcd8622

Browse files
committed
fix(46570): Unhelpful Promise type argument hint in JS file
1 parent 8bda03d commit dcd8622

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30266,9 +30266,11 @@ namespace ts {
3026630266
const parameterRange = hasRestParameter ? min
3026730267
: min < max ? min + "-" + max
3026830268
: min;
30269+
const file = getSourceFileOfNode(node);
3026930270
const error = hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1
30270-
: parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_TypeScript_may_need_a_JSDoc_hint_that_the_call_to_new_Promise_produces_a_Promise_void
30271-
: Diagnostics.Expected_0_arguments_but_got_1;
30271+
: (file.scriptKind === ScriptKind.JS || file.scriptKind === ScriptKind.JSX) && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node)
30272+
? Diagnostics.Expected_0_arguments_but_got_1_TypeScript_may_need_a_JSDoc_hint_that_the_call_to_new_Promise_produces_a_Promise_void
30273+
: Diagnostics.Expected_0_arguments_but_got_1;
3027230274
if (min < args.length && args.length < max) {
3027330275
// between min and max, but with no matching overload
3027430276
return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove);

src/services/codefixes/fixAddVoidToPromise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace ts.codefix {
33
const fixName = "addVoidToPromise";
44
const fixId = "addVoidToPromise";
55
const errorCodes = [
6-
Diagnostics.Expected_0_arguments_but_got_1_TypeScript_may_need_a_JSDoc_hint_that_the_call_to_new_Promise_produces_a_Promise_void.code
6+
Diagnostics.Expected_0_arguments_but_got_1.code
77
];
88
registerCodeFix({
99
errorCodes,

0 commit comments

Comments
 (0)