Skip to content

Conversation

@mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Aug 29, 2017

I missed some methods in #16223, also coalescing Array.from signatures using generic defaults.

@mhegazy mhegazy requested review from a user, rbuckton and weswigham August 30, 2017 00:32
find(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean): T | undefined;
find(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean, thisArg: undefined): T | undefined;
find<Z>(predicate: (this: Z, value: T, index: number, obj: Array<T>) => boolean, thisArg: Z): T | undefined;
find(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the this: void? It's not actually accurate because if a thisArg is passed, then this won't be void.
If someone really does want to pass thisArg, this: void would stop them, but if this: void is ommitted, they will correctly get an error in --noImplicitThis mode, and can work around it by explicitly annotating a this type for their callback.

declare function f(cb: (this: void) => void, thisArg?: any): void;
declare function g(cb: () => void, thisArg?: any): void;

// Can't get a correct type for `this`, even with explicit annotation
f(function(this: string) {
    this.toLowerCase();
}, "");

// Works
g(function(this: string) {
    this.toLowerCase();
}, "");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. should be fixed now.

@mhegazy mhegazy merged commit 562abf3 into master Aug 30, 2017
@mhegazy mhegazy deleted the FollowUpOn16223 branch August 30, 2017 17:22
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants