mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
fix(49478): add return type to method signature (#49482)
This commit is contained in:
parent
e6808c4290
commit
806a710470
@ -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(
|
||||
|
||||
@ -682,7 +682,7 @@ namespace ts.textChanges {
|
||||
return {
|
||||
indentation,
|
||||
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
|
||||
suffix: insertTrailingComma ? "," : ""
|
||||
suffix: insertTrailingComma ? "," : isInterfaceDeclaration(node) && isEmpty ? ";" : ""
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
};`
|
||||
});
|
||||
|
||||
18
tests/cases/fourslash/codeFixAddMissingMember27.ts
Normal file
18
tests/cases/fourslash/codeFixAddMissingMember27.ts
Normal 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()`,
|
||||
});
|
||||
21
tests/cases/fourslash/codeFixAddMissingMember28.ts
Normal file
21
tests/cases/fourslash/codeFixAddMissingMember28.ts
Normal 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()`,
|
||||
});
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user