diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 23805495b6971..639d053a9ac3c 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1235,6 +1235,14 @@ interface Array { map(callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; map(callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => value is S): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => value is S, thisArg: Z): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. diff --git a/tests/baselines/reference/arrayFilter.symbols b/tests/baselines/reference/arrayFilter.symbols index 81d92ba04b6a2..d750acc919528 100644 --- a/tests/baselines/reference/arrayFilter.symbols +++ b/tests/baselines/reference/arrayFilter.symbols @@ -14,9 +14,9 @@ var foo = [ ] foo.filter(x => x.name); //should accepted all possible types not only boolean! ->foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >foo : Symbol(foo, Decl(arrayFilter.ts, 0, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) >x.name : Symbol(name, Decl(arrayFilter.ts, 1, 5)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 23ab4d915bd22..24200c7a52f31 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,9 +22,9 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } +>foo.filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => value is S): S[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg: undefined): S[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } >foo : { name: string; }[] ->filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } +>filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => value is S): S[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg: undefined): S[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } >x => x.name : (this: void, x: { name: string; }) => string >x : { name: string; } >x.name : string diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index d1333bb060c78..475dc96d15ccf 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -39,13 +39,13 @@ export async function runSampleWorks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 0, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 0, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].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, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 4, 52)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 5, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 5, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 5, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 5, 70)) ->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, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 6, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 6, 68)) @@ -111,13 +111,13 @@ export async function runSampleBreaks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 0, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 0, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].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, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 13, 53)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 14, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 14, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 14, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 14, 70)) ->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, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 15, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 15, 68)) diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 9fafbd0cbd6f8..e7cdb62f34e58 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -44,14 +44,14 @@ export async function runSampleWorks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S): S[]; >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: undefined): S[]; , Z>(callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>filter : { >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S): S[]; >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: undefined): S[]; , Z>(callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >el => !!el : (this: void, el: bluebird) => boolean >el : bluebird >!!el : boolean @@ -129,14 +129,14 @@ export async function runSampleBreaks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S): S[]; >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: undefined): S[]; , Z>(callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>filter : { >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S): S[]; >(callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: undefined): S[]; , Z>(callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: void, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >el => !!el : (this: void, el: bluebird) => boolean >el : bluebird >!!el : boolean diff --git a/tests/baselines/reference/genericMethodOverspecialization.symbols b/tests/baselines/reference/genericMethodOverspecialization.symbols index 55ff9cb5afbc6..e1c14103514d2 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.symbols +++ b/tests/baselines/reference/genericMethodOverspecialization.symbols @@ -43,9 +43,9 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : Symbol(xxx, Decl(genericMethodOverspecialization.ts, 17, 3)) ->elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >e : Symbol(e, Decl(genericMethodOverspecialization.ts, 17, 36)) return !e.isDisabled; diff --git a/tests/baselines/reference/genericMethodOverspecialization.types b/tests/baselines/reference/genericMethodOverspecialization.types index 17f3e0dddd76c..b969211213ac6 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.types +++ b/tests/baselines/reference/genericMethodOverspecialization.types @@ -53,9 +53,9 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled;}) : HTMLElement[] ->elements.filter : { (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } +>elements.filter : { (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => value is S): S[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg: undefined): S[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } >elements : HTMLElement[] ->filter : { (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } +>filter : { (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => value is S): S[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg: undefined): S[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg: Z): S[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: void, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } >function (e) { return !e.isDisabled;} : (this: void, e: HTMLElement) => boolean >e : HTMLElement