Skip to content

Commit dc37473

Browse files
committed
Adding test for #10073
1 parent 32eddcf commit dc37473

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/compiler/selfReference.ts(2,12): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
2+
3+
4+
==== tests/cases/compiler/selfReference.ts (1 errors) ====
5+
declare function asFunction<T>(value: T): () => T;
6+
asFunction(() => { return 1; });
7+
~~~~~~~~~~~~~~~~~~~
8+
!!! error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [selfReference.ts]
2+
declare function asFunction<T>(value: T): () => T;
3+
asFunction(() => { return 1; });
4+
5+
//// [selfReference.js]
6+
asFunction(function () { return 1; });

tests/cases/compiler/selfReference.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @noImplicitAny: true
2+
declare function asFunction<T>(value: T): () => T;
3+
asFunction(() => { return 1; });

0 commit comments

Comments
 (0)