From c1d466a716eef632ecbc44a2fb53b6bdc92694bc Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 1 Jun 2017 14:12:25 -0700 Subject: [PATCH] suppress type annotations in js file --- src/services/codefixes/fixAddMissingMember.ts | 8 ++++---- .../fourslash/codeFixUndeclaredAcrossFiles2.ts | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 0859500e2d2..80dd16c5f58 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -70,7 +70,7 @@ namespace ts.codefix { function getActionsForAddMissingMemberInJavaScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined { let actions: CodeAction[]; - const methodCodeAction = getActionForMethodDeclaration(); + const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ false); if (methodCodeAction) { actions = [methodCodeAction]; } @@ -130,7 +130,7 @@ namespace ts.codefix { function getActionsForAddMissingMemberInTypeScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined { let actions: CodeAction[]; - const methodCodeAction = getActionForMethodDeclaration(); + const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ true); if (methodCodeAction) { actions = [methodCodeAction]; } @@ -189,10 +189,10 @@ namespace ts.codefix { return actions; } - function getActionForMethodDeclaration(): CodeAction | undefined { + function getActionForMethodDeclaration(includeTypeScriptSyntax: boolean): CodeAction | undefined { if (token.parent.parent.kind === SyntaxKind.CallExpression) { const callExpression = token.parent.parent; - const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, /*includeTypeScriptSyntax*/ true, makeStatic); + const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts index 9f40c967658..04e2afc667c 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts @@ -13,10 +13,10 @@ // @Filename: f1.js //// [|export class C { -//// x: number; -//// static y: string; //// constructor() { } -//// }|] +//// } +//// +//// |] verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); @@ -25,16 +25,15 @@ verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); verify.rangeIs(` export class C { - m1(): any { + m1() { throw new Error("Method not implemented."); } - static m0(arg0: any, arg1: any, arg2: any): any { + static m0(arg0, arg1, arg2) { throw new Error("Method not implemented."); } - x: number; - static y: string; constructor() { this.y = undefined; } } +C.x = undefined; `); \ No newline at end of file