Skip to content

Commit 0c467d0

Browse files
committed
Fix signatureToSignatureDeclarationHelper
Even if `SuppressAnyReturnType` is on, don't supress it if it's a function. Fixes #35508.
1 parent 8ed92dc commit 0c467d0

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4532,7 +4532,8 @@ namespace ts {
45324532
const returnType = getReturnTypeOfSignature(signature);
45334533
returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context);
45344534
}
4535-
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType) {
4535+
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType
4536+
&& kind !== SyntaxKind.FunctionType && kind !== SyntaxKind.ConstructorType) {
45364537
if (returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) {
45374538
returnTypeNode = undefined;
45384539
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// #35508
4+
5+
////interface IFoo1 {
6+
//// parse(reviver: () => any): void;
7+
////}
8+
////
9+
////class Foo1 implements IFoo1 {
10+
////}
11+
////
12+
////interface IFoo2 {
13+
//// parse(reviver: { (): any }): void;
14+
////}
15+
////
16+
////class Foo2 implements IFoo2 {
17+
////}
18+
////
19+
////interface IFoo3 {
20+
//// parse(reviver: new () => any): void;
21+
////}
22+
////
23+
////class Foo3 implements IFoo3 {
24+
////}
25+
////
26+
////interface IFoo4 {
27+
//// parse(reviver: { new (): any }): void;
28+
////}
29+
////
30+
////class Foo4 implements IFoo4 {
31+
////}
32+
33+
verify.codeFixAll({
34+
fixAllDescription: ts.Diagnostics.Implement_all_unimplemented_interfaces.message,
35+
fixId: "fixClassIncorrectlyImplementsInterface",
36+
newFileContent:
37+
`interface IFoo1 {
38+
parse(reviver: () => any): void;
39+
}
40+
41+
class Foo1 implements IFoo1 {
42+
parse(reviver: () => any): void {
43+
throw new Error("Method not implemented.");
44+
}
45+
}
46+
47+
interface IFoo2 {
48+
parse(reviver: { (): any }): void;
49+
}
50+
51+
class Foo2 implements IFoo2 {
52+
parse(reviver: () => any): void {
53+
throw new Error("Method not implemented.");
54+
}
55+
}
56+
57+
interface IFoo3 {
58+
parse(reviver: new () => any): void;
59+
}
60+
61+
class Foo3 implements IFoo3 {
62+
parse(reviver: new () => any): void {
63+
throw new Error("Method not implemented.");
64+
}
65+
}
66+
67+
interface IFoo4 {
68+
parse(reviver: { new (): any }): void;
69+
}
70+
71+
class Foo4 implements IFoo4 {
72+
parse(reviver: new () => any): void {
73+
throw new Error("Method not implemented.");
74+
}
75+
}`});

0 commit comments

Comments
 (0)