-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into release-5.4
- Loading branch information
Showing
21 changed files
with
586 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/circularReferenceInReturnType.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
circularReferenceInReturnType.ts(3,7): error TS7022: 'res1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
circularReferenceInReturnType.ts(9,7): error TS7022: 'res3' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
|
||
|
||
==== circularReferenceInReturnType.ts (2 errors) ==== | ||
// inference fails for res1 and res2, but ideally should not | ||
declare function fn1<T>(cb: () => T): string; | ||
const res1 = fn1(() => res1); | ||
~~~~ | ||
!!! error TS7022: 'res1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
|
||
declare function fn2<T>(): (cb: () => any) => (a: T) => void; | ||
const res2 = fn2()(() => res2); | ||
|
||
declare function fn3<T>(): <T2>(cb: (arg: T2) => any) => (a: T) => void; | ||
const res3 = fn3()(() => res3); | ||
~~~~ | ||
!!! error TS7022: 'res3' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
|
49 changes: 25 additions & 24 deletions
49
tests/baselines/reference/circularReferenceInReturnType.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
//// [tests/cases/compiler/circularReferenceInReturnType.ts] //// | ||
|
||
=== circularReferenceInReturnType.ts === | ||
// inference fails for res1 and res2, but ideally should not | ||
declare function fn1<T>(cb: () => T): string; | ||
>fn1 : Symbol(fn1, Decl(circularReferenceInReturnType.ts, 0, 0)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 0, 21)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 0, 24)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 0, 21)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 1, 21)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 1, 24)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 1, 21)) | ||
|
||
const res1 = fn1(() => res1); | ||
>res1 : Symbol(res1, Decl(circularReferenceInReturnType.ts, 1, 5)) | ||
>res1 : Symbol(res1, Decl(circularReferenceInReturnType.ts, 2, 5)) | ||
>fn1 : Symbol(fn1, Decl(circularReferenceInReturnType.ts, 0, 0)) | ||
>res1 : Symbol(res1, Decl(circularReferenceInReturnType.ts, 1, 5)) | ||
>res1 : Symbol(res1, Decl(circularReferenceInReturnType.ts, 2, 5)) | ||
|
||
declare function fn2<T>(): (cb: () => any) => (a: T) => void; | ||
>fn2 : Symbol(fn2, Decl(circularReferenceInReturnType.ts, 1, 29)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 3, 21)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 3, 28)) | ||
>a : Symbol(a, Decl(circularReferenceInReturnType.ts, 3, 47)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 3, 21)) | ||
>fn2 : Symbol(fn2, Decl(circularReferenceInReturnType.ts, 2, 29)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 4, 21)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 4, 28)) | ||
>a : Symbol(a, Decl(circularReferenceInReturnType.ts, 4, 47)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 4, 21)) | ||
|
||
const res2 = fn2()(() => res2); | ||
>res2 : Symbol(res2, Decl(circularReferenceInReturnType.ts, 4, 5)) | ||
>fn2 : Symbol(fn2, Decl(circularReferenceInReturnType.ts, 1, 29)) | ||
>res2 : Symbol(res2, Decl(circularReferenceInReturnType.ts, 4, 5)) | ||
>res2 : Symbol(res2, Decl(circularReferenceInReturnType.ts, 5, 5)) | ||
>fn2 : Symbol(fn2, Decl(circularReferenceInReturnType.ts, 2, 29)) | ||
>res2 : Symbol(res2, Decl(circularReferenceInReturnType.ts, 5, 5)) | ||
|
||
declare function fn3<T>(): <T2>(cb: (arg: T2) => any) => (a: T) => void; | ||
>fn3 : Symbol(fn3, Decl(circularReferenceInReturnType.ts, 4, 31)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 6, 21)) | ||
>T2 : Symbol(T2, Decl(circularReferenceInReturnType.ts, 6, 28)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 6, 32)) | ||
>arg : Symbol(arg, Decl(circularReferenceInReturnType.ts, 6, 37)) | ||
>T2 : Symbol(T2, Decl(circularReferenceInReturnType.ts, 6, 28)) | ||
>a : Symbol(a, Decl(circularReferenceInReturnType.ts, 6, 58)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 6, 21)) | ||
>fn3 : Symbol(fn3, Decl(circularReferenceInReturnType.ts, 5, 31)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 7, 21)) | ||
>T2 : Symbol(T2, Decl(circularReferenceInReturnType.ts, 7, 28)) | ||
>cb : Symbol(cb, Decl(circularReferenceInReturnType.ts, 7, 32)) | ||
>arg : Symbol(arg, Decl(circularReferenceInReturnType.ts, 7, 37)) | ||
>T2 : Symbol(T2, Decl(circularReferenceInReturnType.ts, 7, 28)) | ||
>a : Symbol(a, Decl(circularReferenceInReturnType.ts, 7, 58)) | ||
>T : Symbol(T, Decl(circularReferenceInReturnType.ts, 7, 21)) | ||
|
||
const res3 = fn3()(() => res3); | ||
>res3 : Symbol(res3, Decl(circularReferenceInReturnType.ts, 7, 5)) | ||
>fn3 : Symbol(fn3, Decl(circularReferenceInReturnType.ts, 4, 31)) | ||
>res3 : Symbol(res3, Decl(circularReferenceInReturnType.ts, 7, 5)) | ||
>res3 : Symbol(res3, Decl(circularReferenceInReturnType.ts, 8, 5)) | ||
>fn3 : Symbol(fn3, Decl(circularReferenceInReturnType.ts, 5, 31)) | ||
>res3 : Symbol(res3, Decl(circularReferenceInReturnType.ts, 8, 5)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tests/baselines/reference/circularReferenceInReturnType2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
circularReferenceInReturnType2.ts(39,7): error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
|
||
|
||
==== circularReferenceInReturnType2.ts (1 errors) ==== | ||
type ObjectType<Source> = { | ||
kind: "object"; | ||
__source: (source: Source) => void; | ||
}; | ||
|
||
type Field<Source, Key extends string> = { | ||
__key: (key: Key) => void; | ||
__source: (source: Source) => void; | ||
}; | ||
|
||
declare const object: <Source>() => < | ||
Fields extends { | ||
[Key in keyof Fields]: Field<Source, Key & string>; | ||
} | ||
>(config: { | ||
name: string; | ||
fields: Fields | (() => Fields); | ||
}) => ObjectType<Source>; | ||
|
||
type InferValueFromObjectType<Type extends ObjectType<any>> = | ||
Type extends ObjectType<infer Source> ? Source : never; | ||
|
||
type FieldResolver<Source, TType extends ObjectType<any>> = ( | ||
source: Source | ||
) => InferValueFromObjectType<TType>; | ||
|
||
type FieldFuncArgs<Source, Type extends ObjectType<any>> = { | ||
type: Type; | ||
resolve: FieldResolver<Source, Type>; | ||
}; | ||
|
||
declare const field: <Source, Type extends ObjectType<any>, Key extends string>( | ||
field: FieldFuncArgs<Source, Type> | ||
) => Field<Source, Key>; | ||
|
||
type Something = { foo: number }; | ||
|
||
// inference fails here, but ideally should not | ||
const A = object<Something>()({ | ||
~ | ||
!!! error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. | ||
name: "A", | ||
fields: () => ({ | ||
a: field({ | ||
type: A, | ||
resolve() { | ||
return { | ||
foo: 100, | ||
}; | ||
}, | ||
}), | ||
}), | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.