Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type corrections for Promise to adhere to Promises/A+ standard #8216

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/lib/es2015.promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ interface Promise<T> {
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
then<TResult>(onfulfilled?: null | undefined, onrejected?: null | undefined): Promise<T>;
then<TResult>(onfulfilled?: null | undefined, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T|TResult>;
Copy link
Contributor

Choose a reason for hiding this comment

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

this should not be not optional, do not think this would compile this way anyways.

then<TResult>(onfulfilled?: null | undefined, onrejected: (reason: any) => void): Promise<T|TResult>;
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => void): Promise<TResult>;

/**
* Attaches a callback for only the rejection of the Promise.
Expand Down Expand Up @@ -78,4 +81,4 @@ interface PromiseConstructor {
resolve(): Promise<void>;
}

declare var Promise: PromiseConstructor;
declare var Promise: PromiseConstructor;