diff --git a/types/baconjs/baconjs-tests.ts b/types/baconjs/baconjs-tests.ts index e948668dc7..75560d4e42 100644 --- a/types/baconjs/baconjs-tests.ts +++ b/types/baconjs/baconjs-tests.ts @@ -190,6 +190,11 @@ function CommonMethodsInEventStreamsAndProperties() { console.log(sum); // returns [-1, 2, 8] in an order }); } + + { + var src = Bacon.fromArray([1, 2, 3]); + src.doLog('element value'); + } } function EventStream() { diff --git a/types/baconjs/index.d.ts b/types/baconjs/index.d.ts index 8659ea9115..0550d6ec48 100644 --- a/types/baconjs/index.d.ts +++ b/types/baconjs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bacon.js 0.7.0 // Project: https://baconjs.github.io/ -// Definitions by: Alexander Matsievsky +// Definitions by: Alexander Matsievsky , Joonas Javanainen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -69,7 +69,7 @@ declare namespace Bacon { /** * @function * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the optional `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream. - * @param {Promise|JQueryXHR} promise + * @param {PromiseLike|JQueryXHR} promise * @param {boolean} [abort] * @returns {EventStream} * @example @@ -78,7 +78,7 @@ declare namespace Bacon { * Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true); * Bacon.fromPromise(Promise.resolve(1), false); */ - function fromPromise(promise:Promise|JQueryXHR, abort?:boolean):EventStream; + function fromPromise(promise:PromiseLike|JQueryXHR, abort?:boolean):EventStream; /** * @callback Bacon.fromPromise~eventTransformer @@ -88,7 +88,7 @@ declare namespace Bacon { /** * @function Bacon.fromPromise * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream, and also pass a function `eventTransformer` that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`. - * @param {Promise|JQueryXHR} promise + * @param {PromiseLike|JQueryXHR} promise * @param {boolean} abort * @param {Bacon.fromPromise~eventTransformer} eventTransformer * @returns {EventStream} @@ -100,7 +100,7 @@ declare namespace Bacon { * return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()]; * }); */ - function fromPromise(promise:Promise|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial|Next|End|Error)[]):EventStream; + function fromPromise(promise:PromiseLike|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial|Next|End|Error)[]):EventStream; /** * @function @@ -1026,9 +1026,10 @@ declare namespace Bacon { /** * @method EventStream#doLog * @description Logs each value of the [EventStream]{@link Bacon.EventStream} to the console. [doLog]{@link Bacon.EventStream#doLog} behaves like [log]{@link Bacon.EventStream#log} but does not subscribe to the EventStream. You can think of `doLog` as a logger function that – unlike `log` – is safe to use in production. `doLog` is safe, because it does not cause the same surprising side-effects as `log` does. + * @param {string} [label] * @returns {EventStream} */ - doLog():EventStream; + doLog(label?:string):EventStream; /** * @method @@ -1613,9 +1614,10 @@ declare namespace Bacon { /** * @method Property#doLog * @description Logs each value of the [Property]{@link Bacon.Property} to the console. [doLog]{@link Bacon.Property#doLog} behaves like [log]{@link Bacon.Property#log} but does not subscribe to the Property. You can think of `doLog` as a logger function that – unlike `log` – is safe to use in production. `doLog` is safe, because it does not cause the same surprising side-effects as `log` does. + * @param {string} [label] * @returns {Property} */ - doLog():Property; + doLog(label?:string):Property; /** * @method