suppress type annotations in js file

This commit is contained in:
Arthur Ozga 2017-06-01 14:12:25 -07:00
parent 6742f9dcd8
commit c1d466a716
2 changed files with 10 additions and 11 deletions

View file

@ -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 = <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 });

View file

@ -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;
`);