-
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
3e12250
commit f49ff0c
Showing
59 changed files
with
1,061 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
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
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")[]; |
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/arrayFilterBooleanOverload.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,33 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload.ts] //// | ||
|
||
=== arrayFilterBooleanOverload.ts === | ||
const nullableValues = ['a', 'b', null]; // expect (string | null)[] | ||
>nullableValues : Symbol(nullableValues, Decl(arrayFilterBooleanOverload.ts, 0, 5)) | ||
|
||
const values1 = nullableValues.filter(Boolean); // expect string[] | ||
>values1 : Symbol(values1, Decl(arrayFilterBooleanOverload.ts, 2, 5)) | ||
>nullableValues.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>nullableValues : Symbol(nullableValues, Decl(arrayFilterBooleanOverload.ts, 0, 5)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
// @ts-expect-error | ||
const values2 = nullableValues.filter(new Boolean); | ||
>values2 : Symbol(values2, Decl(arrayFilterBooleanOverload.ts, 5, 5)) | ||
>nullableValues.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>nullableValues : Symbol(nullableValues, Decl(arrayFilterBooleanOverload.ts, 0, 5)) | ||
>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
const arr = [0, 1, "", "foo", null] as const; | ||
>arr : Symbol(arr, Decl(arrayFilterBooleanOverload.ts, 7, 5)) | ||
>const : Symbol(const) | ||
|
||
const arr2 = arr.filter(Boolean); // expect ("foo" | 1)[] | ||
>arr2 : Symbol(arr2, Decl(arrayFilterBooleanOverload.ts, 9, 5)) | ||
>arr.filter : Symbol(ReadonlyArray.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>arr : Symbol(arr, Decl(arrayFilterBooleanOverload.ts, 7, 5)) | ||
>filter : Symbol(ReadonlyArray.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
|
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/arrayFilterBooleanOverload.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,45 @@ | ||
//// [tests/cases/compiler/arrayFilterBooleanOverload.ts] //// | ||
|
||
=== arrayFilterBooleanOverload.ts === | ||
const nullableValues = ['a', 'b', null]; // expect (string | null)[] | ||
>nullableValues : (string | null)[] | ||
>['a', 'b', null] : (string | null)[] | ||
>'a' : "a" | ||
>'b' : "b" | ||
|
||
const values1 = nullableValues.filter(Boolean); // expect string[] | ||
>values1 : string[] | ||
>nullableValues.filter(Boolean) : string[] | ||
>nullableValues.filter : { <S extends string | null>(predicate: (value: string | null, index: number, array: (string | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): string[]; (predicate: (value: string | null, index: number, array: (string | null)[]) => unknown, thisArg?: any): (string | null)[]; } | ||
>nullableValues : (string | null)[] | ||
>filter : { <S extends string | null>(predicate: (value: string | null, index: number, array: (string | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): string[]; (predicate: (value: string | null, index: number, array: (string | null)[]) => unknown, thisArg?: any): (string | null)[]; } | ||
>Boolean : BooleanConstructor | ||
|
||
// @ts-expect-error | ||
const values2 = nullableValues.filter(new Boolean); | ||
>values2 : (string | null)[] | ||
>nullableValues.filter(new Boolean) : (string | null)[] | ||
>nullableValues.filter : { <S extends string | null>(predicate: (value: string | null, index: number, array: (string | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): string[]; (predicate: (value: string | null, index: number, array: (string | null)[]) => unknown, thisArg?: any): (string | null)[]; } | ||
>nullableValues : (string | null)[] | ||
>filter : { <S extends string | null>(predicate: (value: string | null, index: number, array: (string | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): string[]; (predicate: (value: string | null, index: number, array: (string | null)[]) => unknown, thisArg?: any): (string | null)[]; } | ||
>new Boolean : Boolean | ||
>Boolean : BooleanConstructor | ||
|
||
const arr = [0, 1, "", "foo", null] as const; | ||
>arr : readonly [0, 1, "", "foo", null] | ||
>[0, 1, "", "foo", null] as const : readonly [0, 1, "", "foo", null] | ||
>[0, 1, "", "foo", null] : readonly [0, 1, "", "foo", null] | ||
>0 : 0 | ||
>1 : 1 | ||
>"" : "" | ||
>"foo" : "foo" | ||
|
||
const arr2 = arr.filter(Boolean); // expect ("foo" | 1)[] | ||
>arr2 : (1 | "foo")[] | ||
>arr.filter(Boolean) : (1 | "foo")[] | ||
>arr.filter : { <S extends "" | 0 | 1 | "foo" | null>(predicate: (value: "" | 0 | 1 | "foo" | null, index: number, array: readonly ("" | 0 | 1 | "foo" | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): (1 | "foo")[]; (predicate: (value: "" | 0 | 1 | "foo" | null, index: number, array: readonly ("" | 0 | 1 | "foo" | null)[]) => unknown, thisArg?: any): ("" | 0 | 1 | "foo" | null)[]; } | ||
>arr : readonly [0, 1, "", "foo", null] | ||
>filter : { <S extends "" | 0 | 1 | "foo" | null>(predicate: (value: "" | 0 | 1 | "foo" | null, index: number, array: readonly ("" | 0 | 1 | "foo" | null)[]) => value is S, thisArg?: any): S[]; (predicate: BooleanConverter, thisArg?: any): (1 | "foo")[]; (predicate: (value: "" | 0 | 1 | "foo" | null, index: number, array: readonly ("" | 0 | 1 | "foo" | null)[]) => unknown, thisArg?: any): ("" | 0 | 1 | "foo" | null)[]; } | ||
>Boolean : BooleanConstructor | ||
|
||
|
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
Oops, something went wrong.