mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix signatureToSignatureDeclarationHelper
Even if `SuppressAnyReturnType` is on, don't supress it if it's a function. Fixes #35508.
This commit is contained in:
@@ -4532,7 +4532,8 @@ namespace ts {
|
||||
const returnType = getReturnTypeOfSignature(signature);
|
||||
returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context);
|
||||
}
|
||||
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType) {
|
||||
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType
|
||||
&& kind !== SyntaxKind.FunctionType && kind !== SyntaxKind.ConstructorType) {
|
||||
if (returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) {
|
||||
returnTypeNode = undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// #35508
|
||||
|
||||
////interface IFoo1 {
|
||||
//// parse(reviver: () => any): void;
|
||||
////}
|
||||
////
|
||||
////class Foo1 implements IFoo1 {
|
||||
////}
|
||||
////
|
||||
////interface IFoo2 {
|
||||
//// parse(reviver: { (): any }): void;
|
||||
////}
|
||||
////
|
||||
////class Foo2 implements IFoo2 {
|
||||
////}
|
||||
////
|
||||
////interface IFoo3 {
|
||||
//// parse(reviver: new () => any): void;
|
||||
////}
|
||||
////
|
||||
////class Foo3 implements IFoo3 {
|
||||
////}
|
||||
////
|
||||
////interface IFoo4 {
|
||||
//// parse(reviver: { new (): any }): void;
|
||||
////}
|
||||
////
|
||||
////class Foo4 implements IFoo4 {
|
||||
////}
|
||||
|
||||
verify.codeFixAll({
|
||||
fixAllDescription: ts.Diagnostics.Implement_all_unimplemented_interfaces.message,
|
||||
fixId: "fixClassIncorrectlyImplementsInterface",
|
||||
newFileContent:
|
||||
`interface IFoo1 {
|
||||
parse(reviver: () => any): void;
|
||||
}
|
||||
|
||||
class Foo1 implements IFoo1 {
|
||||
parse(reviver: () => any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
interface IFoo2 {
|
||||
parse(reviver: { (): any }): void;
|
||||
}
|
||||
|
||||
class Foo2 implements IFoo2 {
|
||||
parse(reviver: () => any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
interface IFoo3 {
|
||||
parse(reviver: new () => any): void;
|
||||
}
|
||||
|
||||
class Foo3 implements IFoo3 {
|
||||
parse(reviver: new () => any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
interface IFoo4 {
|
||||
parse(reviver: { new (): any }): void;
|
||||
}
|
||||
|
||||
class Foo4 implements IFoo4 {
|
||||
parse(reviver: new () => any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}`});
|
||||
Reference in New Issue
Block a user