skip optional parameters in js files (#51924)

This commit is contained in:
Oleksandr T 2022-12-16 21:51:41 +02:00 committed by GitHub
parent 645b3ddb06
commit 193a8a74c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -400,7 +400,7 @@ export function createSignatureDeclarationFromSignature(
parameterDecl.modifiers,
parameterDecl.dotDotDotToken,
parameterDecl.name,
parameterDecl.questionToken,
isJs ? undefined : parameterDecl.questionToken,
type,
parameterDecl.initializer
);

View File

@ -0,0 +1,20 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @type {{ f: (x?: string) => number }}
//// */
////[|export const foo = {}|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`export const foo = {
f: function(x) {
throw new Error("Function not implemented.");
}
}`,
});