From 79dcc43b5081eda64bdfc9701071994a3a526234 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 13:53:54 -0700 Subject: [PATCH 1/2] Make JSON.stringify's 'space' parameter have type 'string | number'. --- src/lib/core.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index f177c421f4f..442921ca5a4 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -971,14 +971,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1181,4 +1181,4 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} From 9c9e39e7a3f875a4865518f76ee91c0fe42f8b78 Mon Sep 17 00:00:00 2001 From: kimamula Date: Sat, 18 Jul 2015 18:46:40 +0900 Subject: [PATCH 2/2] Add includes method to String interface, and remove contains --- src/lib/es6.d.ts | 2 +- tests/baselines/reference/stringIncludes.js | 10 ++++++++ .../reference/stringIncludes.symbols | 15 ++++++++++++ .../baselines/reference/stringIncludes.types | 24 +++++++++++++++++++ tests/cases/compiler/stringIncludes.ts | 5 ++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/stringIncludes.js create mode 100644 tests/baselines/reference/stringIncludes.symbols create mode 100644 tests/baselines/reference/stringIncludes.types create mode 100644 tests/cases/compiler/stringIncludes.ts diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index f3c0a1418fe..97291f742bd 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -377,7 +377,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the diff --git a/tests/baselines/reference/stringIncludes.js b/tests/baselines/reference/stringIncludes.js new file mode 100644 index 00000000000..055d7d8beeb --- /dev/null +++ b/tests/baselines/reference/stringIncludes.js @@ -0,0 +1,10 @@ +//// [stringIncludes.ts] + +var includes: boolean; +includes = "abcde".includes("cd"); +includes = "abcde".includes("cd", 2); + +//// [stringIncludes.js] +var includes; +includes = "abcde".includes("cd"); +includes = "abcde".includes("cd", 2); diff --git a/tests/baselines/reference/stringIncludes.symbols b/tests/baselines/reference/stringIncludes.symbols new file mode 100644 index 00000000000..d0fa641c857 --- /dev/null +++ b/tests/baselines/reference/stringIncludes.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/stringIncludes.ts === + +var includes: boolean; +>includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) + +includes = "abcde".includes("cd"); +>includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) + +includes = "abcde".includes("cd", 2); +>includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) + diff --git a/tests/baselines/reference/stringIncludes.types b/tests/baselines/reference/stringIncludes.types new file mode 100644 index 00000000000..0d1e5ffea4d --- /dev/null +++ b/tests/baselines/reference/stringIncludes.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/stringIncludes.ts === + +var includes: boolean; +>includes : boolean + +includes = "abcde".includes("cd"); +>includes = "abcde".includes("cd") : boolean +>includes : boolean +>"abcde".includes("cd") : boolean +>"abcde".includes : (searchString: string, position?: number) => boolean +>"abcde" : string +>includes : (searchString: string, position?: number) => boolean +>"cd" : string + +includes = "abcde".includes("cd", 2); +>includes = "abcde".includes("cd", 2) : boolean +>includes : boolean +>"abcde".includes("cd", 2) : boolean +>"abcde".includes : (searchString: string, position?: number) => boolean +>"abcde" : string +>includes : (searchString: string, position?: number) => boolean +>"cd" : string +>2 : number + diff --git a/tests/cases/compiler/stringIncludes.ts b/tests/cases/compiler/stringIncludes.ts new file mode 100644 index 00000000000..8196cafa3ed --- /dev/null +++ b/tests/cases/compiler/stringIncludes.ts @@ -0,0 +1,5 @@ +//@target: ES6 + +var includes: boolean; +includes = "abcde".includes("cd"); +includes = "abcde".includes("cd", 2); \ No newline at end of file