From 73590f4fb1635df4e69c0aa843ad336dfbb0be51 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 7 May 2016 16:24:30 -0700 Subject: [PATCH 1/4] {Map, WeakMap}.set and {Set, WeakSet}.add return `this`. --- src/lib/es2015.collection.d.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 521dd29be9fb9..a3207175c48e4 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -4,7 +4,7 @@ interface Map { forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): Map; + set(key: K, value?: V): this; readonly size: number; } @@ -20,8 +20,7 @@ interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): WeakMap; - + set(key: K, value?: V): this; } interface WeakMapConstructor { @@ -32,7 +31,7 @@ interface WeakMapConstructor { declare var WeakMap: WeakMapConstructor; interface Set { - add(value: T): Set; + add(value: T): this; clear(): void; delete(value: T): boolean; forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; @@ -48,11 +47,10 @@ interface SetConstructor { declare var Set: SetConstructor; interface WeakSet { - add(value: T): WeakSet; + add(value: T): this; clear(): void; delete(value: T): boolean; has(value: T): boolean; - } interface WeakSetConstructor { From 8bb75ec3daf241d8c2bcebe016a14ecd71e7eae4 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 7 May 2016 16:28:15 -0700 Subject: [PATCH 2/4] {Array, TypedArray}.{copyWithin, fill, sort} return `this`. --- src/lib/es2015.core.d.ts | 4 +-- src/lib/es5.d.ts | 56 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 34833b9c70d62..819d89eb0c429 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -31,7 +31,7 @@ interface Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: T, start?: number, end?: number): T[]; + fill(value: T, start?: number, end?: number): this; /** * Returns the this object after copying a section of the array identified by start and end @@ -42,7 +42,7 @@ interface Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): T[]; + copyWithin(target: number, start: number, end?: number): this; } interface ArrayConstructor { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index f450371f90db8..761bc48441f05 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1139,7 +1139,7 @@ interface Array { * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: T, b: T) => number): T[]; + sort(compareFn?: (a: T, b: T) => number): this; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1481,7 +1481,7 @@ interface Int8Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Int8Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -1501,7 +1501,7 @@ interface Int8Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Int8Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -1670,7 +1670,7 @@ interface Int8Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements @@ -1754,7 +1754,7 @@ interface Uint8Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Uint8Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -1774,7 +1774,7 @@ interface Uint8Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Uint8Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -1943,7 +1943,7 @@ interface Uint8Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements @@ -2028,7 +2028,7 @@ interface Uint8ClampedArray { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -2048,7 +2048,7 @@ interface Uint8ClampedArray { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -2217,7 +2217,7 @@ interface Uint8ClampedArray { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements @@ -2301,7 +2301,7 @@ interface Int16Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Int16Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -2321,7 +2321,7 @@ interface Int16Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Int16Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -2490,7 +2490,7 @@ interface Int16Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements @@ -2575,7 +2575,7 @@ interface Uint16Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Uint16Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -2595,7 +2595,7 @@ interface Uint16Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Uint16Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -2764,7 +2764,7 @@ interface Uint16Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements @@ -2848,7 +2848,7 @@ interface Int32Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Int32Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -2868,7 +2868,7 @@ interface Int32Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Int32Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -3037,7 +3037,7 @@ interface Int32Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements @@ -3121,7 +3121,7 @@ interface Uint32Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Uint32Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -3141,7 +3141,7 @@ interface Uint32Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Uint32Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -3310,7 +3310,7 @@ interface Uint32Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements @@ -3394,7 +3394,7 @@ interface Float32Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Float32Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -3414,7 +3414,7 @@ interface Float32Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Float32Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -3583,7 +3583,7 @@ interface Float32Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements @@ -3668,7 +3668,7 @@ interface Float64Array { * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ - copyWithin(target: number, start: number, end?: number): Float64Array; + copyWithin(target: number, start: number, end?: number): this; /** * Determines whether all the members of an array satisfy the specified test. @@ -3688,7 +3688,7 @@ interface Float64Array { * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ - fill(value: number, start?: number, end?: number): Float64Array; + fill(value: number, start?: number, end?: number): this; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -3857,7 +3857,7 @@ interface Float64Array { * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; + sort(compareFn?: (a: number, b: number) => number): this; /** * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements From 0b789ff0bc2c12e57056bd4a428bcb5bf8d5e354 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 7 May 2016 16:29:45 -0700 Subject: [PATCH 3/4] Add string literal union type overload for String.normalize parameter. --- src/lib/es2015.core.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 819d89eb0c429..71a8655350fd8 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -402,6 +402,14 @@ interface String { */ endsWith(searchString: string, endPosition?: number): boolean; + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; + /** * Returns the String value result of normalizing the string into the normalization form * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. From aa87df2cfb5fb05b3228a536bd1757534b101d65 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 7 May 2016 16:40:52 -0700 Subject: [PATCH 4/4] Update tests and baselines. --- tests/baselines/reference/implementArrayInterface.js | 2 +- tests/baselines/reference/implementArrayInterface.symbols | 7 +++---- tests/baselines/reference/implementArrayInterface.types | 5 ++--- tests/cases/compiler/implementArrayInterface.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/baselines/reference/implementArrayInterface.js b/tests/baselines/reference/implementArrayInterface.js index b75de77ea979f..733a861071bae 100644 --- a/tests/baselines/reference/implementArrayInterface.js +++ b/tests/baselines/reference/implementArrayInterface.js @@ -10,7 +10,7 @@ declare class MyArray implements Array { reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; - sort(compareFn?: (a: T, b: T) => number): T[]; + sort(compareFn?: (a: T, b: T) => number): this; splice(start: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; diff --git a/tests/baselines/reference/implementArrayInterface.symbols b/tests/baselines/reference/implementArrayInterface.symbols index 0491f282f755e..e6a15a8774f63 100644 --- a/tests/baselines/reference/implementArrayInterface.symbols +++ b/tests/baselines/reference/implementArrayInterface.symbols @@ -52,22 +52,21 @@ declare class MyArray implements Array { >end : Symbol(end, Decl(implementArrayInterface.ts, 10, 25)) >T : Symbol(T, Decl(implementArrayInterface.ts, 0, 22)) - sort(compareFn?: (a: T, b: T) => number): T[]; + sort(compareFn?: (a: T, b: T) => number): this; >sort : Symbol(MyArray.sort, Decl(implementArrayInterface.ts, 10, 45)) >compareFn : Symbol(compareFn, Decl(implementArrayInterface.ts, 11, 9)) >a : Symbol(a, Decl(implementArrayInterface.ts, 11, 22)) >T : Symbol(T, Decl(implementArrayInterface.ts, 0, 22)) >b : Symbol(b, Decl(implementArrayInterface.ts, 11, 27)) ->T : Symbol(T, Decl(implementArrayInterface.ts, 0, 22)) >T : Symbol(T, Decl(implementArrayInterface.ts, 0, 22)) splice(start: number): T[]; ->splice : Symbol(MyArray.splice, Decl(implementArrayInterface.ts, 11, 50), Decl(implementArrayInterface.ts, 12, 31)) +>splice : Symbol(MyArray.splice, Decl(implementArrayInterface.ts, 11, 51), Decl(implementArrayInterface.ts, 12, 31)) >start : Symbol(start, Decl(implementArrayInterface.ts, 12, 11)) >T : Symbol(T, Decl(implementArrayInterface.ts, 0, 22)) splice(start: number, deleteCount: number, ...items: T[]): T[]; ->splice : Symbol(MyArray.splice, Decl(implementArrayInterface.ts, 11, 50), Decl(implementArrayInterface.ts, 12, 31)) +>splice : Symbol(MyArray.splice, Decl(implementArrayInterface.ts, 11, 51), Decl(implementArrayInterface.ts, 12, 31)) >start : Symbol(start, Decl(implementArrayInterface.ts, 13, 11)) >deleteCount : Symbol(deleteCount, Decl(implementArrayInterface.ts, 13, 25)) >items : Symbol(items, Decl(implementArrayInterface.ts, 13, 46)) diff --git a/tests/baselines/reference/implementArrayInterface.types b/tests/baselines/reference/implementArrayInterface.types index 347fcf37693e6..2085cfdf6e0f7 100644 --- a/tests/baselines/reference/implementArrayInterface.types +++ b/tests/baselines/reference/implementArrayInterface.types @@ -52,13 +52,12 @@ declare class MyArray implements Array { >end : number >T : T - sort(compareFn?: (a: T, b: T) => number): T[]; ->sort : (compareFn?: (a: T, b: T) => number) => T[] + sort(compareFn?: (a: T, b: T) => number): this; +>sort : (compareFn?: (a: T, b: T) => number) => this >compareFn : (a: T, b: T) => number >a : T >T : T >b : T ->T : T >T : T splice(start: number): T[]; diff --git a/tests/cases/compiler/implementArrayInterface.ts b/tests/cases/compiler/implementArrayInterface.ts index 1ba8b8f25240d..79ba68bdc4279 100644 --- a/tests/cases/compiler/implementArrayInterface.ts +++ b/tests/cases/compiler/implementArrayInterface.ts @@ -9,7 +9,7 @@ declare class MyArray implements Array { reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; - sort(compareFn?: (a: T, b: T) => number): T[]; + sort(compareFn?: (a: T, b: T) => number): this; splice(start: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number;