mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-30 04:16:48 -05:00
String.prototype.{trimStart,trimEnd} hit stage 4
This commit is contained in:
@@ -43,6 +43,7 @@ namespace ts {
|
||||
["es2018.promise", "lib.es2018.promise.d.ts"],
|
||||
["es2018.regexp", "lib.es2018.regexp.d.ts"],
|
||||
["es2019.array", "lib.es2019.array.d.ts"],
|
||||
["es2019.string", "lib.es2019.string.d.ts"],
|
||||
["es2019.symbol", "lib.es2019.symbol.d.ts"],
|
||||
["esnext.array", "lib.es2019.array.d.ts"],
|
||||
["esnext.symbol", "lib.es2019.symbol.d.ts"],
|
||||
|
||||
1
src/lib/es2019.d.ts
vendored
1
src/lib/es2019.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="es2019.array" />
|
||||
/// <reference lib="es2019.string" />
|
||||
/// <reference lib="es2019.symbol" />
|
||||
|
||||
13
src/lib/es2019.string.d.ts
vendored
Normal file
13
src/lib/es2019.string.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
interface String {
|
||||
/** Removes the trailing white space and line terminator characters from a string. */
|
||||
trimEnd(): string;
|
||||
|
||||
/** Removes the leading white space and line terminator characters from a string. */
|
||||
trimStart(): string;
|
||||
|
||||
/** Removes the trailing white space and line terminator characters from a string. */
|
||||
trimLeft(): string;
|
||||
|
||||
/** Removes the leading white space and line terminator characters from a string. */
|
||||
trimRight(): string;
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
"es2018.promise",
|
||||
"es2018.intl",
|
||||
"es2019.array",
|
||||
"es2019.string",
|
||||
"es2019.symbol",
|
||||
"esnext.asynciterable",
|
||||
"esnext.bigint",
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
@@ -259,7 +259,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
@@ -278,7 +278,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
|
||||
@@ -53,7 +53,7 @@ typedArray[bigNum] = 0xAA; // should error
|
||||
|
||||
typedArray[String(bigNum)] = 0xAA;
|
||||
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
|
||||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 2 more)
|
||||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 3 more)
|
||||
>bigNum : Symbol(bigNum, Decl(a.ts, 16, 5))
|
||||
|
||||
typedArray["1"] = 0xBB;
|
||||
|
||||
14
tests/baselines/reference/stringTrim.js
Normal file
14
tests/baselines/reference/stringTrim.js
Normal file
@@ -0,0 +1,14 @@
|
||||
//// [stringTrim.ts]
|
||||
var trimmed: string;
|
||||
trimmed = "abcde".trimEnd();
|
||||
trimmed = "abcde".trimStart();
|
||||
trimmed = "abcde".trimLeft();
|
||||
trimmed = "abcde".trimRight();
|
||||
|
||||
|
||||
//// [stringTrim.js]
|
||||
var trimmed;
|
||||
trimmed = "abcde".trimEnd();
|
||||
trimmed = "abcde".trimStart();
|
||||
trimmed = "abcde".trimLeft();
|
||||
trimmed = "abcde".trimRight();
|
||||
24
tests/baselines/reference/stringTrim.symbols
Normal file
24
tests/baselines/reference/stringTrim.symbols
Normal file
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/stringTrim.ts ===
|
||||
var trimmed: string;
|
||||
>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3))
|
||||
|
||||
trimmed = "abcde".trimEnd();
|
||||
>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3))
|
||||
>"abcde".trimEnd : Symbol(String.trimEnd, Decl(lib.es2019.string.d.ts, --, --))
|
||||
>trimEnd : Symbol(String.trimEnd, Decl(lib.es2019.string.d.ts, --, --))
|
||||
|
||||
trimmed = "abcde".trimStart();
|
||||
>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3))
|
||||
>"abcde".trimStart : Symbol(String.trimStart, Decl(lib.es2019.string.d.ts, --, --))
|
||||
>trimStart : Symbol(String.trimStart, Decl(lib.es2019.string.d.ts, --, --))
|
||||
|
||||
trimmed = "abcde".trimLeft();
|
||||
>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3))
|
||||
>"abcde".trimLeft : Symbol(String.trimLeft, Decl(lib.es2019.string.d.ts, --, --))
|
||||
>trimLeft : Symbol(String.trimLeft, Decl(lib.es2019.string.d.ts, --, --))
|
||||
|
||||
trimmed = "abcde".trimRight();
|
||||
>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3))
|
||||
>"abcde".trimRight : Symbol(String.trimRight, Decl(lib.es2019.string.d.ts, --, --))
|
||||
>trimRight : Symbol(String.trimRight, Decl(lib.es2019.string.d.ts, --, --))
|
||||
|
||||
36
tests/baselines/reference/stringTrim.types
Normal file
36
tests/baselines/reference/stringTrim.types
Normal file
@@ -0,0 +1,36 @@
|
||||
=== tests/cases/compiler/stringTrim.ts ===
|
||||
var trimmed: string;
|
||||
>trimmed : string
|
||||
|
||||
trimmed = "abcde".trimEnd();
|
||||
>trimmed = "abcde".trimEnd() : string
|
||||
>trimmed : string
|
||||
>"abcde".trimEnd() : string
|
||||
>"abcde".trimEnd : () => string
|
||||
>"abcde" : "abcde"
|
||||
>trimEnd : () => string
|
||||
|
||||
trimmed = "abcde".trimStart();
|
||||
>trimmed = "abcde".trimStart() : string
|
||||
>trimmed : string
|
||||
>"abcde".trimStart() : string
|
||||
>"abcde".trimStart : () => string
|
||||
>"abcde" : "abcde"
|
||||
>trimStart : () => string
|
||||
|
||||
trimmed = "abcde".trimLeft();
|
||||
>trimmed = "abcde".trimLeft() : string
|
||||
>trimmed : string
|
||||
>"abcde".trimLeft() : string
|
||||
>"abcde".trimLeft : () => string
|
||||
>"abcde" : "abcde"
|
||||
>trimLeft : () => string
|
||||
|
||||
trimmed = "abcde".trimRight();
|
||||
>trimmed = "abcde".trimRight() : string
|
||||
>trimmed : string
|
||||
>"abcde".trimRight() : string
|
||||
>"abcde".trimRight : () => string
|
||||
>"abcde" : "abcde"
|
||||
>trimRight : () => string
|
||||
|
||||
7
tests/cases/compiler/stringTrim.ts
Normal file
7
tests/cases/compiler/stringTrim.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// @target: es2019
|
||||
|
||||
var trimmed: string;
|
||||
trimmed = "abcde".trimEnd();
|
||||
trimmed = "abcde".trimStart();
|
||||
trimmed = "abcde".trimLeft();
|
||||
trimmed = "abcde".trimRight();
|
||||
Reference in New Issue
Block a user