fix(49478): add return type to method signature (#49482)

This commit is contained in:
Oleksandr T 2022-06-11 00:14:36 +03:00 committed by GitHub
parent e6808c4290
commit 806a710470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 4 deletions

View File

@ -332,7 +332,7 @@ namespace ts.codefix {
/*questionToken*/ undefined,
typeParameters,
parameters,
type
type === undefined ? factory.createKeywordTypeNode(SyntaxKind.UnknownKeyword) : type
);
case SyntaxKind.FunctionDeclaration:
return factory.createFunctionDeclaration(

View File

@ -682,7 +682,7 @@ namespace ts.textChanges {
return {
indentation,
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
suffix: insertTrailingComma ? "," : ""
suffix: insertTrailingComma ? "," : isInterfaceDeclaration(node) && isEmpty ? ";" : ""
};
}

View File

@ -10,6 +10,6 @@ verify.codeFix({
index: 0,
newRangeContent:
`type Foo = {
test(arg0: number, arg1: number, arg2: string);
test(arg0: number, arg1: number, arg2: string): unknown;
};`
});

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
// @noImplicitAny: true
////interface IFoo {}
////const foo: IFoo = {}
////foo.bar()
verify.codeFix({
description: [ts.Diagnostics.Declare_method_0.message, "bar"],
index: 0,
newFileContent:
`interface IFoo {
bar(): unknown;
}
const foo: IFoo = {}
foo.bar()`,
});

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />
// @noImplicitAny: true
////interface IFoo {
//// b(): void;
////}
////const foo: IFoo = {}
////foo.a()
verify.codeFix({
description: [ts.Diagnostics.Declare_method_0.message, "a"],
index: 1,
newFileContent:
`interface IFoo {
a(): unknown;
b(): void;
}
const foo: IFoo = {}
foo.a()`,
});

View File

@ -72,7 +72,7 @@ En.A;
type T = {
x: any;
y: number;
test(arg0: number, arg1: number);
test(arg0: number, arg1: number): unknown;
};
function foo(t: T) {
t.x;