Skip to content

Commit c1d466a

Browse files
author
Arthur Ozga
committed
suppress type annotations in js file
1 parent 6742f9d commit c1d466a

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace ts.codefix {
7070
function getActionsForAddMissingMemberInJavaScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined {
7171
let actions: CodeAction[];
7272

73-
const methodCodeAction = getActionForMethodDeclaration();
73+
const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ false);
7474
if (methodCodeAction) {
7575
actions = [methodCodeAction];
7676
}
@@ -130,7 +130,7 @@ namespace ts.codefix {
130130
function getActionsForAddMissingMemberInTypeScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined {
131131
let actions: CodeAction[];
132132

133-
const methodCodeAction = getActionForMethodDeclaration();
133+
const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ true);
134134
if (methodCodeAction) {
135135
actions = [methodCodeAction];
136136
}
@@ -189,10 +189,10 @@ namespace ts.codefix {
189189
return actions;
190190
}
191191

192-
function getActionForMethodDeclaration(): CodeAction | undefined {
192+
function getActionForMethodDeclaration(includeTypeScriptSyntax: boolean): CodeAction | undefined {
193193
if (token.parent.parent.kind === SyntaxKind.CallExpression) {
194194
const callExpression = <CallExpression>token.parent.parent;
195-
const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, /*includeTypeScriptSyntax*/ true, makeStatic);
195+
const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic);
196196

197197
const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
198198
methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter });

tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
// @Filename: f1.js
1515
//// [|export class C {
16-
//// x: number;
17-
//// static y: string;
1816
//// constructor() { }
19-
//// }|]
17+
//// }
18+
////
19+
//// |]
2020

2121
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
2222
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
@@ -25,16 +25,15 @@ verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
2525

2626
verify.rangeIs(`
2727
export class C {
28-
m1(): any {
28+
m1() {
2929
throw new Error("Method not implemented.");
3030
}
31-
static m0(arg0: any, arg1: any, arg2: any): any {
31+
static m0(arg0, arg1, arg2) {
3232
throw new Error("Method not implemented.");
3333
}
34-
x: number;
35-
static y: string;
3634
constructor() {
3735
this.y = undefined;
3836
}
3937
}
38+
C.x = undefined;
4039
`);

0 commit comments

Comments
 (0)