lodash: signatures of _.join have been changed

This commit is contained in:
Ilya Mochalov
2016-01-24 09:49:37 +05:00
parent 7fffbd3e04
commit 74d4078b8e
4 changed files with 155 additions and 18 deletions
+43 -1
View File
@@ -230,7 +230,6 @@ declare module _ {
interface LoDashExplicitObjectWrapper<T> extends LoDashExplicitWrapperBase<T, LoDashExplicitObjectWrapper<T>> { }
interface LoDashImplicitArrayWrapper<T> extends LoDashImplicitWrapperBase<T[], LoDashImplicitArrayWrapper<T>> {
join(seperator?: string): string;
pop(): T;
push(...items: T[]): LoDashImplicitArrayWrapper<T>;
shift(): T;
@@ -246,6 +245,49 @@ declare module _ {
interface LoDashExplicitNumberArrayWrapper extends LoDashExplicitArrayWrapper<number> { }
// join (exists only in wrappers)
interface LoDashImplicitWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
/*********
* Array *
*********/
+28 -1
View File
@@ -133,7 +133,6 @@ module TestWrapper {
}
//Wrapped array shortcut methods
result = <string>_([1, 2, 3, 4]).join(',');
result = <number>_([1, 2, 3, 4]).pop();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).push(5, 6, 7);
result = <number>_([1, 2, 3, 4]).shift();
@@ -142,6 +141,34 @@ result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
// join (exists only in wrappers)
namespace TestJoin {
let array = [1, 2];
let list = {0: 1, 1: 2, length: 2};
{
let result: string;
result = _('abc').join();
result = _('abc').join('_');
result = _(array).join();
result = _(array).join('_');
result = _(list).join();
result = _(list).join('_');
}
{
let result: _.LoDashExplicitWrapper<string>;
result = _('abc').chain().join();
result = _('abc').chain().join('_');
result = _(array).chain().join();
result = _(array).chain().join('_');
result = _(list).chain().join();
result = _(list).chain().join('_');
}
}
/*********
* Array *
*********/
+35 -1
View File
@@ -133,7 +133,6 @@ module TestWrapper {
}
//Wrapped array shortcut methods
result = <string>_([1, 2, 3, 4]).join(',');
result = <number>_([1, 2, 3, 4]).pop();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).push(5, 6, 7);
result = <number>_([1, 2, 3, 4]).shift();
@@ -941,6 +940,41 @@ module TestIntersection {
}
}
// _.join
namespace TestJoin {
let array = [1, 2];
let list = {0: 1, 1: 2, length: 2};
{
let result: string;
result = _.join('abc');
result = _.join('abc', '_');
result = _.join(array);
result = _.join(array, '_');
result = _.join(list);
result = _.join(list, '_');
result = _('abc').join();
result = _('abc').join('_');
result = _(array).join();
result = _(array).join('_');
result = _(list).join();
result = _(list).join('_');
}
{
let result: _.LoDashExplicitWrapper<string>;
result = _('abc').chain().join();
result = _('abc').chain().join('_');
result = _(array).chain().join();
result = _(array).chain().join('_');
result = _(list).chain().join();
result = _(list).chain().join('_');
}
}
// _.last
module TestLast {
let array: TResult[];
+49 -15
View File
@@ -375,7 +375,6 @@ declare module _ {
interface LoDashExplicitObjectWrapper<T> extends LoDashExplicitWrapperBase<T, LoDashExplicitObjectWrapper<T>> { }
interface LoDashImplicitArrayWrapper<T> extends LoDashImplicitWrapperBase<T[], LoDashImplicitArrayWrapper<T>> {
join(seperator?: string): string;
pop(): T;
push(...items: T[]): LoDashImplicitArrayWrapper<T>;
shift(): T;
@@ -1676,26 +1675,61 @@ declare module _ {
): any[];
}
//_.join DUMMY
//_.join
interface LoDashStatic {
/**
* Converts all elements in `array` into a string separated by `separator`.
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to convert.
* @param {string} [separator=','] The element separator.
* @returns {string} Returns the joined string.
* @example
*
* _.join(['a', 'b', 'c'], '~');
* // => 'a~b~c'
* @param array The array to convert.
* @param separator The element separator.
* @returns Returns the joined string.
*/
join(
array: any[]|List<any>,
...values: any[]
): any[];
array: List<any>,
separator?: string
): string;
}
interface LoDashImplicitWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): string;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.join
*/
join(separator?: string): LoDashExplicitWrapper<string>;
}
//_.pullAll DUMMY