Skip to content

Commit 193a8a7

Browse files
authored
skip optional parameters in js files (#51924)
1 parent 645b3dd commit 193a8a7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/services/codefixes/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export function createSignatureDeclarationFromSignature(
400400
parameterDecl.modifiers,
401401
parameterDecl.dotDotDotToken,
402402
parameterDecl.name,
403-
parameterDecl.questionToken,
403+
isJs ? undefined : parameterDecl.questionToken,
404404
type,
405405
parameterDecl.initializer
406406
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
// @filename: /a.js
6+
/////**
7+
//// * @type {{ f: (x?: string) => number }}
8+
//// */
9+
////[|export const foo = {}|]
10+
11+
verify.codeFix({
12+
index: 0,
13+
description: ts.Diagnostics.Add_missing_properties.message,
14+
newRangeContent:
15+
`export const foo = {
16+
f: function(x) {
17+
throw new Error("Function not implemented.");
18+
}
19+
}`,
20+
});

0 commit comments

Comments
 (0)