From fece0e0e6b46241e066062deb23771a23b19319e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:08:47 -0400 Subject: [PATCH 1/8] RSVP: switch to `export =` with `allowSyntheticDefaultExports`. --- types/rsvp/index.d.ts | 299 ++++++++++++++++++++------------------- types/rsvp/tsconfig.json | 5 +- 2 files changed, 153 insertions(+), 151 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index c0a7dc8b07..5372bdd7d5 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -14,98 +14,98 @@ // Credit for that file goes to: Barrie Nemetchek , Andrew Gaspar , John Reilly declare namespace RSVP { - type Resolution = (value: T) => U | Thenable; - type Rejection = (error: C) => D | Thenable; + type Resolution = (value: T) => U | Thenable; + type Rejection = (error: C) => D | Thenable; - interface Thenable { - then(label?: string): Thenable; - then(onFulfillment: Resolution, label?: string): Thenable; - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Thenable; - } + interface Thenable { + then(label?: string): Thenable; + then(onFulfillment: Resolution, label?: string): Thenable; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Thenable; + } - interface Catchable { - catch(label?: string): Catchable; - catch(onRejection: (error: C) => D, label?: string): Catchable; - } + interface Catchable { + catch(label?: string): Catchable; + catch(onRejection: (error: C) => D, label?: string): Catchable; + } - interface Deferred { - promise: Promise; - resolve(value: T): void; - reject(reason: C): void; - } + interface Deferred { + promise: Promise; + resolve(value: T): void; + reject(reason: C): void; + } - type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; - interface IPromiseState { - state: PromiseStates; - value: T; - reason: C; - } + type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; + interface IPromiseState { + state: PromiseStates; + value: T; + reason: C; + } - class Resolved implements IPromiseState { - state: 'fulfilled'; - value: T; - reason: never; - } + class Resolved implements IPromiseState { + state: 'fulfilled'; + value: T; + reason: never; + } - class Rejected implements IPromiseState { - state: 'rejected'; - value: never; - reason: C; - } + class Rejected implements IPromiseState { + state: 'rejected'; + value: never; + reason: C; + } - class Pending implements IPromiseState { - state: 'pending'; - value: never; - reason: never; - } + class Pending implements IPromiseState { + state: 'pending'; + value: never; + reason: never; + } - type PromiseState = Resolved | Rejected | Pending; + type PromiseState = Resolved | Rejected | Pending; - type PromiseHash = { [P in keyof T]: Thenable | T[P] }; + type PromiseHash = { [P in keyof T]: Thenable | T[P] }; - type SettledHash = { [P in keyof T]: PromiseState }; + type SettledHash = { [P in keyof T]: PromiseState }; - interface InstrumentEvent { - guid: string; // guid of promise. Must be globally unique, not just within the implementation - childGuid: string; // child of child promise (for chained via `then`) - eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] - detail: any; // fulfillment value or rejection reason, if applicable - label: string; // label passed to promise's constructor - timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now - } + interface InstrumentEvent { + guid: string; // guid of promise. Must be globally unique, not just within the implementation + childGuid: string; // child of child promise (for chained via `then`) + eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] + detail: any; // fulfillment value or rejection reason, if applicable + label: string; // label passed to promise's constructor + timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now + } - interface ObjectWithEventMixins { - on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - on(eventName: 'error', errorHandler: (reason: any) => void): void; - on(eventName: string, callback: (value: any) => void): void; - off(eventName: string, callback?: (value: any) => void): void; - trigger(eventName: string, options?: any, label?: string): void; - } + interface ObjectWithEventMixins { + on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + on(eventName: 'error', errorHandler: (reason: any) => void): void; + on(eventName: string, callback: (value: any) => void): void; + off(eventName: string, callback?: (value: any) => void): void; + trigger(eventName: string, options?: any, label?: string): void; + } - class Promise implements Thenable, Catchable { - /** + class Promise implements Thenable, Catchable { + /** * If you call resolve in the body of the callback passed to the constructor, * your promise is fulfilled with result object passed to resolve. * If you call reject your promise is rejected with the object passed to reject. * For consistency and debugging (eg stack traces), obj should be an instanceof Error. * Any errors thrown in the constructor callback will be implicitly passed to reject(). */ - constructor( - callback: ( - resolve: (result?: T | Thenable) => void, - reject: (error: C | Thenable) => void - ) => void, - label?: string - ); + constructor( + callback: ( + resolve: (result?: T | Thenable) => void, + reject: (error: C | Thenable) => void + ) => void, + label?: string + ); - /** + /** * onFulfillment is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. * Both are optional, if either/both are omitted the next onFulfillment/onRejected in the chain is called. * Both callbacks have a single parameter , the fulfillment value or rejection reason. @@ -116,31 +116,31 @@ declare namespace RSVP { * @param onRejected called when/if "promise" rejects * @param label useful for tooling */ - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Promise; - then(onFulfillment: Resolution, label?: string): Promise; - then(label?: string): Promise; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Promise; + then(onFulfillment: Resolution, label?: string): Promise; + then(label?: string): Promise; - /** + /** * Sugar for promise.then(undefined, onRejected) */ - catch(label?: string): Promise; - catch(onRejection: Rejection, label?: string): Promise; + catch(label?: string): Promise; + catch(onRejection: Rejection, label?: string): Promise; - finally(finallyCallback: Function): Promise; + finally(finallyCallback: Function): Promise; - /** + /** * `RSVP.Promise.all` accepts an array of promises, and returns a new promise which * is fulfilled with an array of fulfillment values for the passed promises, or * rejected with the reason of the first passed promise to be rejected. It casts all * elements of the passed iterable to promises as it runs this algorithm. */ - static all(promises: Thenable[], label?: string): Promise; + static all(promises: Thenable[], label?: string): Promise; - /** + /** * `RSVP.Promise.race` returns a new promise which is settled in the same way as the * first passed promise to settle. * @@ -150,67 +150,67 @@ declare namespace RSVP { * become rejected before the other promises became fulfilled, the returned * promise will become rejected. */ - static race(promises: Promise[]): Promise; + static race(promises: Promise[]): Promise; - /** + /** * Returns a promise that will become resolved with the passed `value` */ - static resolve(value: T, label?: string): Promise; + static resolve(value: T, label?: string): Promise; - /** + /** * Deprecated in favor of resolve */ - static cast(value: T, label?: string): Promise; + static cast(value: T, label?: string): Promise; - /** + /** * Returns a promise rejected with the passed `reason`. */ - static reject(reason: C): Promise; - } + static reject(reason: C): Promise; + } - export namespace EventTarget { - /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ - function mixin(object: object): ObjectWithEventMixins; + export namespace EventTarget { + /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ + function mixin(object: object): ObjectWithEventMixins; - /** Registers a callback to be executed when `eventName` is triggered */ - function on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - function on(eventName: 'error', errorHandler: (reason: any) => void): void; - function on(eventName: string, callback: (value: any) => void): void; + /** Registers a callback to be executed when `eventName` is triggered */ + function on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + function on(eventName: 'error', errorHandler: (reason: any) => void): void; + function on(eventName: string, callback: (value: any) => void): void; - /** + /** * You can use `off` to stop firing a particular callback for an event. * * If you don't pass a `callback` argument to `off`, ALL callbacks for the * event will not be executed when the event fires. */ - function off(eventName: string, callback?: (value: any) => void): void; + function off(eventName: string, callback?: (value: any) => void): void; - /** + /** * Use `trigger` to fire custom events. * * You can also pass a value as a second argument to `trigger` that will be * passed as an argument to all event listeners for the event */ - function trigger(eventName: string, options?: any, label?: string): void; - } + function trigger(eventName: string, options?: any, label?: string): void; + } - export function configure( - configName: 'instrument' | 'instrument-with-stack', - shouldInstrument: boolean - ): void; - export function configure(configName: string, value: any): void; + export function configure( + configName: 'instrument' | 'instrument-with-stack', + shouldInstrument: boolean + ): void; + export function configure(configName: string, value: any): void; - /** + /** * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - export function all(promises: Thenable[]): Promise; + export function all(promises: Thenable[]): Promise; - /** + /** * `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array * for its `promises` argument. * @@ -223,9 +223,9 @@ declare namespace RSVP { * If any of the `promises` given to `RSVP.hash` are rejected, the first promise * that is rejected will be given as the reason to the rejection handler. */ - export function hash(promises: PromiseHash): Promise; + export function hash(promises: PromiseHash): Promise; - /** + /** * `RSVP.map` is similar to JavaScript's native `map` method. `mapFn` is eagerly called * meaning that as soon as any promise resolves its value will be passed to `mapFn`. * `RSVP.map` returns a promise that will become fulfilled with the result of running @@ -235,21 +235,21 @@ declare namespace RSVP { * that is rejected will be given as an argument to the returned promise's * rejection handler. */ - export function map( - promises: Thenable[], - mapFn: (item: T) => U, - label?: string - ): Promise; + export function map( + promises: Thenable[], + mapFn: (item: T) => U, + label?: string + ): Promise; - /** + /** * `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing * a fail-fast method, it waits until all the promises have returned and * shows you all the results. This is useful if you want to handle multiple * promises' failure states together as a set. */ - export function allSettled(promises: Thenable[]): Promise[], C>; + export function allSettled(promises: Thenable[]): Promise[], C>; - /** + /** * `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object * instead of an array for its `promises` argument. * @@ -259,14 +259,14 @@ declare namespace RSVP { * with their states and values/reasons. This is useful if you want to * handle multiple promises' failure states together as a set. */ - export function hashSettled(promises: PromiseHash): Promise, C>; + export function hashSettled(promises: PromiseHash): Promise, C>; - /** + /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: Promise[]): Promise; - /** + /** * `RSVP.denodeify` takes a "node-style" function and returns a function that * will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the * browser when you'd prefer to use promises over using callbacks. For example, @@ -324,12 +324,12 @@ declare namespace RSVP { * }); * ``` */ - export function denodeify( - nodeFunction: Function, - options: boolean | string[] - ): (...args: A[]) => Promise; + export function denodeify( + nodeFunction: Function, + options: boolean | string[] + ): (...args: A[]) => Promise; - /** + /** * `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. * `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s * interface. New code should use the `RSVP.Promise` constructor instead. @@ -339,32 +339,32 @@ declare namespace RSVP { * * reject - a function that causes the `promise` property on this object to become rejected * * resolve - a function that causes the `promise` property on this object to become fulfilled. */ - export function defer(label?: string): Deferred; + export function defer(label?: string): Deferred; - /** + /** * `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. */ - export function reject(reason: C): Promise; + export function reject(reason: C): Promise; - /** + /** * `RSVP.Promise.resolve` returns a promise that will become resolved with the * passed `value`. */ - export function resolve(value: T): Promise; + export function resolve(value: T): Promise; - /** + /** * `RSVP.filter` is similar to JavaScript's native `filter` method, except that it * waits for all promises to become fulfilled before running the `filterFn` on * each item in given to `promises`. `RSVP.filter` returns a promise that will * become fulfilled with the result of running `filterFn` on the values the * promises become fulfilled with. */ - export function filter( - promises: Thenable[], - filterFn: (value: T) => boolean | Promise - ): Promise; + export function filter( + promises: Thenable[], + filterFn: (value: T) => boolean | Promise + ): Promise; - /** + /** * `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event * loop in order to aid debugging. * @@ -376,7 +376,8 @@ declare namespace RSVP { * or domain/cause uncaught exception in Node. `rethrow` will also throw the * error again so the error can be handled by the promise per the spec. */ - export function rethrow(reason: C): void; + export function rethrow(reason: C): void; } -export default RSVP; +// export default RSVP; +export = RSVP; diff --git a/types/rsvp/tsconfig.json b/types/rsvp/tsconfig.json index 58c8e605be..fee17b279a 100644 --- a/types/rsvp/tsconfig.json +++ b/types/rsvp/tsconfig.json @@ -13,10 +13,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "rsvp-tests.ts" ] -} \ No newline at end of file +} From 0196f2468ea3f38b96afe01e77fd7980710c8ac2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:18:16 -0400 Subject: [PATCH 2/8] Update RSVP dependencies to allow synthetic imports. --- types/ember-testing-helpers/tsconfig.json | 3 ++- types/ember/tsconfig.json | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index aaf474ecba..cd7634bd25 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index d2f27dfec9..fbc4052a08 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,10 +14,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "ember-tests.ts" ] -} \ No newline at end of file +} From 6ecbed72420aa10dac76a64db6ced41e217f645b Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:19:55 -0400 Subject: [PATCH 3/8] Fix spacing in RSVP (thanks, Prettier). --- types/rsvp/index.d.ts | 296 +++++++++++++++++++++--------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index 5372bdd7d5..1aa764d785 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -14,98 +14,98 @@ // Credit for that file goes to: Barrie Nemetchek , Andrew Gaspar , John Reilly declare namespace RSVP { - type Resolution = (value: T) => U | Thenable; - type Rejection = (error: C) => D | Thenable; + type Resolution = (value: T) => U | Thenable; + type Rejection = (error: C) => D | Thenable; - interface Thenable { - then(label?: string): Thenable; - then(onFulfillment: Resolution, label?: string): Thenable; - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Thenable; - } + interface Thenable { + then(label?: string): Thenable; + then(onFulfillment: Resolution, label?: string): Thenable; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Thenable; + } - interface Catchable { - catch(label?: string): Catchable; - catch(onRejection: (error: C) => D, label?: string): Catchable; - } + interface Catchable { + catch(label?: string): Catchable; + catch(onRejection: (error: C) => D, label?: string): Catchable; + } - interface Deferred { - promise: Promise; - resolve(value: T): void; - reject(reason: C): void; - } + interface Deferred { + promise: Promise; + resolve(value: T): void; + reject(reason: C): void; + } - type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; - interface IPromiseState { - state: PromiseStates; - value: T; - reason: C; - } + type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; + interface IPromiseState { + state: PromiseStates; + value: T; + reason: C; + } - class Resolved implements IPromiseState { - state: 'fulfilled'; - value: T; - reason: never; - } + class Resolved implements IPromiseState { + state: 'fulfilled'; + value: T; + reason: never; + } - class Rejected implements IPromiseState { - state: 'rejected'; - value: never; - reason: C; - } + class Rejected implements IPromiseState { + state: 'rejected'; + value: never; + reason: C; + } - class Pending implements IPromiseState { - state: 'pending'; - value: never; - reason: never; - } + class Pending implements IPromiseState { + state: 'pending'; + value: never; + reason: never; + } - type PromiseState = Resolved | Rejected | Pending; + type PromiseState = Resolved | Rejected | Pending; - type PromiseHash = { [P in keyof T]: Thenable | T[P] }; + type PromiseHash = { [P in keyof T]: Thenable | T[P] }; - type SettledHash = { [P in keyof T]: PromiseState }; + type SettledHash = { [P in keyof T]: PromiseState }; - interface InstrumentEvent { - guid: string; // guid of promise. Must be globally unique, not just within the implementation - childGuid: string; // child of child promise (for chained via `then`) - eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] - detail: any; // fulfillment value or rejection reason, if applicable - label: string; // label passed to promise's constructor - timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now - } + interface InstrumentEvent { + guid: string; // guid of promise. Must be globally unique, not just within the implementation + childGuid: string; // child of child promise (for chained via `then`) + eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] + detail: any; // fulfillment value or rejection reason, if applicable + label: string; // label passed to promise's constructor + timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now + } - interface ObjectWithEventMixins { - on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - on(eventName: 'error', errorHandler: (reason: any) => void): void; - on(eventName: string, callback: (value: any) => void): void; - off(eventName: string, callback?: (value: any) => void): void; - trigger(eventName: string, options?: any, label?: string): void; - } + interface ObjectWithEventMixins { + on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + on(eventName: 'error', errorHandler: (reason: any) => void): void; + on(eventName: string, callback: (value: any) => void): void; + off(eventName: string, callback?: (value: any) => void): void; + trigger(eventName: string, options?: any, label?: string): void; + } - class Promise implements Thenable, Catchable { - /** + class Promise implements Thenable, Catchable { + /** * If you call resolve in the body of the callback passed to the constructor, * your promise is fulfilled with result object passed to resolve. * If you call reject your promise is rejected with the object passed to reject. * For consistency and debugging (eg stack traces), obj should be an instanceof Error. * Any errors thrown in the constructor callback will be implicitly passed to reject(). */ - constructor( - callback: ( - resolve: (result?: T | Thenable) => void, - reject: (error: C | Thenable) => void - ) => void, - label?: string - ); + constructor( + callback: ( + resolve: (result?: T | Thenable) => void, + reject: (error: C | Thenable) => void + ) => void, + label?: string + ); - /** + /** * onFulfillment is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. * Both are optional, if either/both are omitted the next onFulfillment/onRejected in the chain is called. * Both callbacks have a single parameter , the fulfillment value or rejection reason. @@ -116,31 +116,31 @@ declare namespace RSVP { * @param onRejected called when/if "promise" rejects * @param label useful for tooling */ - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Promise; - then(onFulfillment: Resolution, label?: string): Promise; - then(label?: string): Promise; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Promise; + then(onFulfillment: Resolution, label?: string): Promise; + then(label?: string): Promise; - /** + /** * Sugar for promise.then(undefined, onRejected) */ - catch(label?: string): Promise; - catch(onRejection: Rejection, label?: string): Promise; + catch(label?: string): Promise; + catch(onRejection: Rejection, label?: string): Promise; - finally(finallyCallback: Function): Promise; + finally(finallyCallback: Function): Promise; - /** + /** * `RSVP.Promise.all` accepts an array of promises, and returns a new promise which * is fulfilled with an array of fulfillment values for the passed promises, or * rejected with the reason of the first passed promise to be rejected. It casts all * elements of the passed iterable to promises as it runs this algorithm. */ - static all(promises: Thenable[], label?: string): Promise; + static all(promises: Thenable[], label?: string): Promise; - /** + /** * `RSVP.Promise.race` returns a new promise which is settled in the same way as the * first passed promise to settle. * @@ -150,67 +150,67 @@ declare namespace RSVP { * become rejected before the other promises became fulfilled, the returned * promise will become rejected. */ - static race(promises: Promise[]): Promise; + static race(promises: Promise[]): Promise; - /** + /** * Returns a promise that will become resolved with the passed `value` */ - static resolve(value: T, label?: string): Promise; + static resolve(value: T, label?: string): Promise; - /** + /** * Deprecated in favor of resolve */ - static cast(value: T, label?: string): Promise; + static cast(value: T, label?: string): Promise; - /** + /** * Returns a promise rejected with the passed `reason`. */ - static reject(reason: C): Promise; - } + static reject(reason: C): Promise; + } - export namespace EventTarget { - /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ - function mixin(object: object): ObjectWithEventMixins; + export namespace EventTarget { + /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ + function mixin(object: object): ObjectWithEventMixins; - /** Registers a callback to be executed when `eventName` is triggered */ - function on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - function on(eventName: 'error', errorHandler: (reason: any) => void): void; - function on(eventName: string, callback: (value: any) => void): void; + /** Registers a callback to be executed when `eventName` is triggered */ + function on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + function on(eventName: 'error', errorHandler: (reason: any) => void): void; + function on(eventName: string, callback: (value: any) => void): void; - /** + /** * You can use `off` to stop firing a particular callback for an event. * * If you don't pass a `callback` argument to `off`, ALL callbacks for the * event will not be executed when the event fires. */ - function off(eventName: string, callback?: (value: any) => void): void; + function off(eventName: string, callback?: (value: any) => void): void; - /** + /** * Use `trigger` to fire custom events. * * You can also pass a value as a second argument to `trigger` that will be * passed as an argument to all event listeners for the event */ - function trigger(eventName: string, options?: any, label?: string): void; - } + function trigger(eventName: string, options?: any, label?: string): void; + } - export function configure( - configName: 'instrument' | 'instrument-with-stack', - shouldInstrument: boolean - ): void; - export function configure(configName: string, value: any): void; + export function configure( + configName: 'instrument' | 'instrument-with-stack', + shouldInstrument: boolean + ): void; + export function configure(configName: string, value: any): void; - /** + /** * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - export function all(promises: Thenable[]): Promise; + export function all(promises: Thenable[]): Promise; - /** + /** * `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array * for its `promises` argument. * @@ -223,9 +223,9 @@ declare namespace RSVP { * If any of the `promises` given to `RSVP.hash` are rejected, the first promise * that is rejected will be given as the reason to the rejection handler. */ - export function hash(promises: PromiseHash): Promise; + export function hash(promises: PromiseHash): Promise; - /** + /** * `RSVP.map` is similar to JavaScript's native `map` method. `mapFn` is eagerly called * meaning that as soon as any promise resolves its value will be passed to `mapFn`. * `RSVP.map` returns a promise that will become fulfilled with the result of running @@ -235,21 +235,21 @@ declare namespace RSVP { * that is rejected will be given as an argument to the returned promise's * rejection handler. */ - export function map( - promises: Thenable[], - mapFn: (item: T) => U, - label?: string - ): Promise; + export function map( + promises: Thenable[], + mapFn: (item: T) => U, + label?: string + ): Promise; - /** + /** * `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing * a fail-fast method, it waits until all the promises have returned and * shows you all the results. This is useful if you want to handle multiple * promises' failure states together as a set. */ - export function allSettled(promises: Thenable[]): Promise[], C>; + export function allSettled(promises: Thenable[]): Promise[], C>; - /** + /** * `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object * instead of an array for its `promises` argument. * @@ -259,14 +259,14 @@ declare namespace RSVP { * with their states and values/reasons. This is useful if you want to * handle multiple promises' failure states together as a set. */ - export function hashSettled(promises: PromiseHash): Promise, C>; + export function hashSettled(promises: PromiseHash): Promise, C>; - /** + /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: Promise[]): Promise; - /** + /** * `RSVP.denodeify` takes a "node-style" function and returns a function that * will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the * browser when you'd prefer to use promises over using callbacks. For example, @@ -324,12 +324,12 @@ declare namespace RSVP { * }); * ``` */ - export function denodeify( - nodeFunction: Function, - options: boolean | string[] - ): (...args: A[]) => Promise; + export function denodeify( + nodeFunction: Function, + options: boolean | string[] + ): (...args: A[]) => Promise; - /** + /** * `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. * `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s * interface. New code should use the `RSVP.Promise` constructor instead. @@ -339,32 +339,32 @@ declare namespace RSVP { * * reject - a function that causes the `promise` property on this object to become rejected * * resolve - a function that causes the `promise` property on this object to become fulfilled. */ - export function defer(label?: string): Deferred; + export function defer(label?: string): Deferred; - /** + /** * `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. */ - export function reject(reason: C): Promise; + export function reject(reason: C): Promise; - /** + /** * `RSVP.Promise.resolve` returns a promise that will become resolved with the * passed `value`. */ - export function resolve(value: T): Promise; + export function resolve(value: T): Promise; - /** + /** * `RSVP.filter` is similar to JavaScript's native `filter` method, except that it * waits for all promises to become fulfilled before running the `filterFn` on * each item in given to `promises`. `RSVP.filter` returns a promise that will * become fulfilled with the result of running `filterFn` on the values the * promises become fulfilled with. */ - export function filter( - promises: Thenable[], - filterFn: (value: T) => boolean | Promise - ): Promise; + export function filter( + promises: Thenable[], + filterFn: (value: T) => boolean | Promise + ): Promise; - /** + /** * `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event * loop in order to aid debugging. * @@ -376,7 +376,7 @@ declare namespace RSVP { * or domain/cause uncaught exception in Node. `rethrow` will also throw the * error again so the error can be handled by the promise per the spec. */ - export function rethrow(reason: C): void; + export function rethrow(reason: C): void; } // export default RSVP; From c1bbbe3c691c07c6017c11ecf7bf6c12a357fb0a Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 18:08:42 -0400 Subject: [PATCH 4/8] Use `import =` for RSVP tests; drop corresponding tsconfig setting. --- types/rsvp/index.d.ts | 1 - types/rsvp/rsvp-tests.ts | 2 +- types/rsvp/tsconfig.json | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index 1aa764d785..8f2fdfee04 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -379,5 +379,4 @@ declare namespace RSVP { export function rethrow(reason: C): void; } -// export default RSVP; export = RSVP; diff --git a/types/rsvp/rsvp-tests.ts b/types/rsvp/rsvp-tests.ts index 519947dcc7..aec0acfede 100644 --- a/types/rsvp/rsvp-tests.ts +++ b/types/rsvp/rsvp-tests.ts @@ -1,4 +1,4 @@ -import RSVP from 'rsvp'; +import RSVP = require('rsvp'); let promise1: RSVP.Promise = RSVP.Promise.resolve(1); let promise1a: RSVP.Promise = RSVP.resolve(1); diff --git a/types/rsvp/tsconfig.json b/types/rsvp/tsconfig.json index fee17b279a..4eb44a2f7d 100644 --- a/types/rsvp/tsconfig.json +++ b/types/rsvp/tsconfig.json @@ -13,8 +13,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 2ff76c2755156481894f7db78a7fa539b2aa3112 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 14 Aug 2017 14:06:21 -0700 Subject: [PATCH 5/8] Remove `--allowSyntheticDefaultImports` --- types/ember-testing-helpers/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index cd7634bd25..aaf474ecba 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,8 +14,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 43a1348b9146b0c6130a37f28d019eb2924ad9a3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 14 Aug 2017 14:06:48 -0700 Subject: [PATCH 6/8] Remove `--allowSyntheticDefaultImports` --- types/ember/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index fbc4052a08..b73838d20e 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,8 +14,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 149dde5da4afd0172f82a1bdd66b23581e4a56c2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Thu, 24 Aug 2017 09:02:31 -0400 Subject: [PATCH 7/8] Revert "Remove `--allowSyntheticDefaultImports`" (from ember-testing-helpers) This reverts commit 2ff76c2755156481894f7db78a7fa539b2aa3112. --- types/ember-testing-helpers/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index aaf474ecba..cd7634bd25 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", From 4ad5e86ffe81753f4fd3b53171ab33d9f313947e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Thu, 24 Aug 2017 09:02:49 -0400 Subject: [PATCH 8/8] Revert "Remove `--allowSyntheticDefaultImports`" (from ember) This reverts commit 43a1348b9146b0c6130a37f28d019eb2924ad9a3. --- types/ember/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index b73838d20e..fbc4052a08 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts",