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
3e12250
commit 28da703
Showing
61 changed files
with
1,211 additions
and
539 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
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/arrayFilterBooleanOverload#56013WithoutExternalOverload.js
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,32 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload#56013WithoutExternalOverload.ts] //// | ||
|
||
//// [arrayFilterBooleanOverload#56013WithoutExternalOverload.ts] | ||
type NonFalsy<T> = T extends false | 0 | "" | null | undefined | 0n | ||
? never | ||
: T; | ||
|
||
const id = <T,>() => (t: T) => !!t; | ||
|
||
['foo', 'bar'].filter(id()); // // expect id() = (t: string) => boolean | ||
|
||
['foo', 'bar', 1].filter(id()); // // expect id() = (t: string | number) => boolean | ||
|
||
declare const maybe: boolean; | ||
(maybe ? ['foo', 'bar'] : [1] ).filter(id()); // expect id() = (t: string | number) => boolean | ||
|
||
['foo', 'bar', undefined].filter(id()); // expect id() = (t: string | undefined) => boolean | ||
|
||
|
||
//// [arrayFilterBooleanOverload#56013WithoutExternalOverload.js] | ||
"use strict"; | ||
const id = () => (t) => !!t; | ||
['foo', 'bar'].filter(id()); // // expect id() = (t: string) => boolean | ||
['foo', 'bar', 1].filter(id()); // // expect id() = (t: string | number) => boolean | ||
(maybe ? ['foo', 'bar'] : [1]).filter(id()); // expect id() = (t: string | number) => boolean | ||
['foo', 'bar', undefined].filter(id()); // expect id() = (t: string | undefined) => boolean | ||
|
||
|
||
//// [arrayFilterBooleanOverload#56013WithoutExternalOverload.d.ts] | ||
type NonFalsy<T> = T extends false | 0 | "" | null | undefined | 0n ? never : T; | ||
declare const id: <T>() => (t: T) => boolean; | ||
declare const maybe: boolean; |
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/arrayFilterBooleanOverload#56013WithoutExternalOverload.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,44 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload#56013WithoutExternalOverload.ts] //// | ||
|
||
=== arrayFilterBooleanOverload#56013WithoutExternalOverload.ts === | ||
type NonFalsy<T> = T extends false | 0 | "" | null | undefined | 0n | ||
>NonFalsy : Symbol(NonFalsy, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 0, 0)) | ||
>T : Symbol(T, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 0, 14)) | ||
>T : Symbol(T, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 0, 14)) | ||
|
||
? never | ||
: T; | ||
>T : Symbol(T, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 0, 14)) | ||
|
||
const id = <T,>() => (t: T) => !!t; | ||
>id : Symbol(id, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 5)) | ||
>T : Symbol(T, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 12)) | ||
>t : Symbol(t, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 22)) | ||
>T : Symbol(T, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 12)) | ||
>t : Symbol(t, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 22)) | ||
|
||
['foo', 'bar'].filter(id()); // // expect id() = (t: string) => boolean | ||
>['foo', 'bar'].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>id : Symbol(id, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 5)) | ||
|
||
['foo', 'bar', 1].filter(id()); // // expect id() = (t: string | number) => boolean | ||
>['foo', 'bar', 1].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>id : Symbol(id, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 5)) | ||
|
||
declare const maybe: boolean; | ||
>maybe : Symbol(maybe, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 10, 13)) | ||
|
||
(maybe ? ['foo', 'bar'] : [1] ).filter(id()); // expect id() = (t: string | number) => boolean | ||
>(maybe ? ['foo', 'bar'] : [1] ).filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more) | ||
>maybe : Symbol(maybe, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 10, 13)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more) | ||
>id : Symbol(id, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 5)) | ||
|
||
['foo', 'bar', undefined].filter(id()); // expect id() = (t: string | undefined) => boolean | ||
>['foo', 'bar', undefined].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>undefined : Symbol(undefined) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>id : Symbol(id, Decl(arrayFilterBooleanOverload#56013WithoutExternalOverload.ts, 4, 5)) | ||
|
69 changes: 69 additions & 0 deletions
69
tests/baselines/reference/arrayFilterBooleanOverload#56013WithoutExternalOverload.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,69 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload#56013WithoutExternalOverload.ts] //// | ||
|
||
=== arrayFilterBooleanOverload#56013WithoutExternalOverload.ts === | ||
type NonFalsy<T> = T extends false | 0 | "" | null | undefined | 0n | ||
>NonFalsy : NonFalsy<T> | ||
>false : false | ||
|
||
? never | ||
: T; | ||
|
||
const id = <T,>() => (t: T) => !!t; | ||
>id : <T>() => (t: T) => boolean | ||
><T,>() => (t: T) => !!t : <T>() => (t: T) => boolean | ||
>(t: T) => !!t : (t: T) => boolean | ||
>t : T | ||
>!!t : boolean | ||
>!t : boolean | ||
>t : T | ||
|
||
['foo', 'bar'].filter(id()); // // expect id() = (t: string) => boolean | ||
>['foo', 'bar'].filter(id()) : string[] | ||
>['foo', 'bar'].filter : { <S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; } | ||
>['foo', 'bar'] : string[] | ||
>'foo' : "foo" | ||
>'bar' : "bar" | ||
>filter : { <S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; } | ||
>id() : (t: string) => boolean | ||
>id : <T>() => (t: T) => boolean | ||
|
||
['foo', 'bar', 1].filter(id()); // // expect id() = (t: string | number) => boolean | ||
>['foo', 'bar', 1].filter(id()) : (string | number)[] | ||
>['foo', 'bar', 1].filter : { <S extends string | number>(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): (string | number)[]; (predicate: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any): (string | number)[]; } | ||
>['foo', 'bar', 1] : (string | number)[] | ||
>'foo' : "foo" | ||
>'bar' : "bar" | ||
>1 : 1 | ||
>filter : { <S extends string | number>(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): (string | number)[]; (predicate: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any): (string | number)[]; } | ||
>id() : (t: string | number) => boolean | ||
>id : <T>() => (t: T) => boolean | ||
|
||
declare const maybe: boolean; | ||
>maybe : boolean | ||
|
||
(maybe ? ['foo', 'bar'] : [1] ).filter(id()); // expect id() = (t: string | number) => boolean | ||
>(maybe ? ['foo', 'bar'] : [1] ).filter(id()) : (string | number)[] | ||
>(maybe ? ['foo', 'bar'] : [1] ).filter : { <S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; } | { <S extends number>(predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): number[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; } | ||
>(maybe ? ['foo', 'bar'] : [1] ) : string[] | number[] | ||
>maybe ? ['foo', 'bar'] : [1] : string[] | number[] | ||
>maybe : boolean | ||
>['foo', 'bar'] : string[] | ||
>'foo' : "foo" | ||
>'bar' : "bar" | ||
>[1] : number[] | ||
>1 : 1 | ||
>filter : { <S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; } | { <S extends number>(predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): number[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; } | ||
>id() : (t: string | number) => boolean | ||
>id : <T>() => (t: T) => boolean | ||
|
||
['foo', 'bar', undefined].filter(id()); // expect id() = (t: string | undefined) => boolean | ||
>['foo', 'bar', undefined].filter(id()) : (string | undefined)[] | ||
>['foo', 'bar', undefined].filter : { <S extends string | undefined>(predicate: (value: string | undefined, index: number, array: (string | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string | undefined, index: number, array: (string | undefined)[]) => unknown, thisArg?: any): (string | undefined)[]; } | ||
>['foo', 'bar', undefined] : (string | undefined)[] | ||
>'foo' : "foo" | ||
>'bar' : "bar" | ||
>undefined : undefined | ||
>filter : { <S extends string | undefined>(predicate: (value: string | undefined, index: number, array: (string | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConstructor, thisArg?: any): string[]; (predicate: (value: string | undefined, index: number, array: (string | undefined)[]) => unknown, thisArg?: any): (string | undefined)[]; } | ||
>id() : (t: string | undefined) => boolean | ||
>id : <T>() => (t: T) => boolean | ||
|
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,32 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload.ts] //// | ||
|
||
//// [arrayFilterBooleanOverload.ts] | ||
const nullableValues = ['a', 'b', null]; // expect (string | null)[] | ||
|
||
const values1 = nullableValues.filter(Boolean); // expect string[] | ||
|
||
// @ts-expect-error | ||
const values2 = nullableValues.filter(new Boolean); | ||
|
||
const arr = [0, 1, "", "foo", null] as const; | ||
|
||
const arr2 = arr.filter(Boolean); // expect ("foo" | 1)[] | ||
|
||
|
||
|
||
//// [arrayFilterBooleanOverload.js] | ||
"use strict"; | ||
const nullableValues = ['a', 'b', null]; // expect (string | null)[] | ||
const values1 = nullableValues.filter(Boolean); // expect string[] | ||
// @ts-expect-error | ||
const values2 = nullableValues.filter(new Boolean); | ||
const arr = [0, 1, "", "foo", null]; | ||
const arr2 = arr.filter(Boolean); // expect ("foo" | 1)[] | ||
|
||
|
||
//// [arrayFilterBooleanOverload.d.ts] | ||
declare const nullableValues: (string | null)[]; | ||
declare const values1: string[]; | ||
declare const values2: (string | null)[]; | ||
declare const arr: readonly [0, 1, "", "foo", null]; | ||
declare const arr2: (1 | "foo")[]; |
Oops, something went wrong.