-
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.
- Loading branch information
1 parent
deb32d8
commit 210023c
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
tests/baselines/reference/nonInferrableTypePropagation3.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
=== tests/cases/compiler/nonInferrableTypePropagation3.ts === | ||
// Repro from #53748 | ||
|
||
declare type Callback<Args extends any[], Out, R> = (...args: Args) => (data: Out) => R; | ||
>Callback : Symbol(Callback, Decl(nonInferrableTypePropagation3.ts, 0, 0)) | ||
>Args : Symbol(Args, Decl(nonInferrableTypePropagation3.ts, 2, 22)) | ||
>Out : Symbol(Out, Decl(nonInferrableTypePropagation3.ts, 2, 41)) | ||
>R : Symbol(R, Decl(nonInferrableTypePropagation3.ts, 2, 46)) | ||
>args : Symbol(args, Decl(nonInferrableTypePropagation3.ts, 2, 53)) | ||
>Args : Symbol(Args, Decl(nonInferrableTypePropagation3.ts, 2, 22)) | ||
>data : Symbol(data, Decl(nonInferrableTypePropagation3.ts, 2, 72)) | ||
>Out : Symbol(Out, Decl(nonInferrableTypePropagation3.ts, 2, 41)) | ||
>R : Symbol(R, Decl(nonInferrableTypePropagation3.ts, 2, 46)) | ||
|
||
declare function factory<Out>(): <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R; | ||
>factory : Symbol(factory, Decl(nonInferrableTypePropagation3.ts, 2, 88)) | ||
>Out : Symbol(Out, Decl(nonInferrableTypePropagation3.ts, 3, 25)) | ||
>Args : Symbol(Args, Decl(nonInferrableTypePropagation3.ts, 3, 34)) | ||
>R : Symbol(R, Decl(nonInferrableTypePropagation3.ts, 3, 53)) | ||
>callback : Symbol(callback, Decl(nonInferrableTypePropagation3.ts, 3, 57)) | ||
>Callback : Symbol(Callback, Decl(nonInferrableTypePropagation3.ts, 0, 0)) | ||
>Args : Symbol(Args, Decl(nonInferrableTypePropagation3.ts, 3, 34)) | ||
>Out : Symbol(Out, Decl(nonInferrableTypePropagation3.ts, 3, 25)) | ||
>R : Symbol(R, Decl(nonInferrableTypePropagation3.ts, 3, 53)) | ||
>args : Symbol(args, Decl(nonInferrableTypePropagation3.ts, 3, 95)) | ||
>Args : Symbol(Args, Decl(nonInferrableTypePropagation3.ts, 3, 34)) | ||
>R : Symbol(R, Decl(nonInferrableTypePropagation3.ts, 3, 53)) | ||
|
||
const make = factory<{id: string, age: number}[]>(); | ||
>make : Symbol(make, Decl(nonInferrableTypePropagation3.ts, 5, 5)) | ||
>factory : Symbol(factory, Decl(nonInferrableTypePropagation3.ts, 2, 88)) | ||
>id : Symbol(id, Decl(nonInferrableTypePropagation3.ts, 5, 22)) | ||
>age : Symbol(age, Decl(nonInferrableTypePropagation3.ts, 5, 33)) | ||
|
||
const usersOverAge = make((age: number) => data => { | ||
>usersOverAge : Symbol(usersOverAge, Decl(nonInferrableTypePropagation3.ts, 7, 5)) | ||
>make : Symbol(make, Decl(nonInferrableTypePropagation3.ts, 5, 5)) | ||
>age : Symbol(age, Decl(nonInferrableTypePropagation3.ts, 7, 27)) | ||
>data : Symbol(data, Decl(nonInferrableTypePropagation3.ts, 7, 42)) | ||
|
||
return data.filter(user => user.age >= age); | ||
>data.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>data : Symbol(data, Decl(nonInferrableTypePropagation3.ts, 7, 42)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>user : Symbol(user, Decl(nonInferrableTypePropagation3.ts, 8, 23)) | ||
>user.age : Symbol(age, Decl(nonInferrableTypePropagation3.ts, 5, 33)) | ||
>user : Symbol(user, Decl(nonInferrableTypePropagation3.ts, 8, 23)) | ||
>age : Symbol(age, Decl(nonInferrableTypePropagation3.ts, 5, 33)) | ||
>age : Symbol(age, Decl(nonInferrableTypePropagation3.ts, 7, 27)) | ||
|
||
}); | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/nonInferrableTypePropagation3.types
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,44 @@ | ||
=== tests/cases/compiler/nonInferrableTypePropagation3.ts === | ||
// Repro from #53748 | ||
|
||
declare type Callback<Args extends any[], Out, R> = (...args: Args) => (data: Out) => R; | ||
>Callback : Callback<Args, Out, R> | ||
>args : Args | ||
>data : Out | ||
|
||
declare function factory<Out>(): <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R; | ||
>factory : <Out>() => <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R | ||
>callback : Callback<Args, Out, R> | ||
>args : Args | ||
|
||
const make = factory<{id: string, age: number}[]>(); | ||
>make : <Args extends any[], R>(callback: Callback<Args, { id: string; age: number; }[], R>) => (...args: Args) => R | ||
>factory<{id: string, age: number}[]>() : <Args extends any[], R>(callback: Callback<Args, { id: string; age: number; }[], R>) => (...args: Args) => R | ||
>factory : <Out>() => <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R | ||
>id : string | ||
>age : number | ||
|
||
const usersOverAge = make((age: number) => data => { | ||
>usersOverAge : (age: number) => { id: string; age: number; }[] | ||
>make((age: number) => data => { return data.filter(user => user.age >= age);}) : (age: number) => { id: string; age: number; }[] | ||
>make : <Args extends any[], R>(callback: Callback<Args, { id: string; age: number; }[], R>) => (...args: Args) => R | ||
>(age: number) => data => { return data.filter(user => user.age >= age);} : (age: number) => (data: { id: string; age: number; }[]) => { id: string; age: number; }[] | ||
>age : number | ||
>data => { return data.filter(user => user.age >= age);} : (data: { id: string; age: number; }[]) => { id: string; age: number; }[] | ||
>data : { id: string; age: number; }[] | ||
|
||
return data.filter(user => user.age >= age); | ||
>data.filter(user => user.age >= age) : { id: string; age: number; }[] | ||
>data.filter : { <S extends { id: string; age: number; }>(predicate: (value: { id: string; age: number; }, index: number, array: { id: string; age: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: string; age: number; }, index: number, array: { id: string; age: number; }[]) => unknown, thisArg?: any): { id: string; age: number; }[]; } | ||
>data : { id: string; age: number; }[] | ||
>filter : { <S extends { id: string; age: number; }>(predicate: (value: { id: string; age: number; }, index: number, array: { id: string; age: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: string; age: number; }, index: number, array: { id: string; age: number; }[]) => unknown, thisArg?: any): { id: string; age: number; }[]; } | ||
>user => user.age >= age : (user: { id: string; age: number; }) => boolean | ||
>user : { id: string; age: number; } | ||
>user.age >= age : boolean | ||
>user.age : number | ||
>user : { id: string; age: number; } | ||
>age : number | ||
>age : number | ||
|
||
}); | ||
|
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,13 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// Repro from #53748 | ||
|
||
declare type Callback<Args extends any[], Out, R> = (...args: Args) => (data: Out) => R; | ||
declare function factory<Out>(): <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R; | ||
|
||
const make = factory<{id: string, age: number}[]>(); | ||
|
||
const usersOverAge = make((age: number) => data => { | ||
return data.filter(user => user.age >= age); | ||
}); |