mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-27 04:48:33 -05:00
Merge pull request #2691 from Microsoft/isRegExpWeHardlyKnewYe
Remove 'Symbol.isRegExp' and introduce 'RegExp.prototype.flags'
This commit is contained in:
2
src/lib/core.d.ts
vendored
2
src/lib/core.d.ts
vendored
@@ -823,7 +823,7 @@ interface RegExp {
|
||||
*/
|
||||
test(string: string): boolean;
|
||||
|
||||
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
|
||||
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
|
||||
source: string;
|
||||
|
||||
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
|
||||
|
||||
31
src/lib/es6.d.ts
vendored
31
src/lib/es6.d.ts
vendored
@@ -50,26 +50,21 @@ interface SymbolConstructor {
|
||||
*/
|
||||
isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object may be used as a regular expression.
|
||||
*/
|
||||
isRegExp: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object.Called by the semantics of the
|
||||
* for-of statement.
|
||||
* for-of statement.
|
||||
*/
|
||||
iterator: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
|
||||
* abstract operation.
|
||||
* abstract operation.
|
||||
*/
|
||||
toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built- in method Object.prototype.toString.
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
toStringTag: symbol;
|
||||
|
||||
@@ -111,7 +106,7 @@ interface ObjectConstructor {
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
* @param value1 The first value.
|
||||
* @param value2 The second value.
|
||||
*/
|
||||
@@ -598,8 +593,6 @@ interface Math {
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
[Symbol.isRegExp]: boolean;
|
||||
|
||||
/**
|
||||
* Matches a string with a regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
@@ -631,6 +624,20 @@ interface RegExp {
|
||||
*/
|
||||
split(string: string, limit?: number): string[];
|
||||
|
||||
/**
|
||||
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
|
||||
* The characters in this string are sequenced and concatenated in the following order:
|
||||
*
|
||||
* - "g" for global
|
||||
* - "i" for ignoreCase
|
||||
* - "m" for multiline
|
||||
* - "u" for unicode
|
||||
* - "y" for sticky
|
||||
*
|
||||
* If no flags are set, the value is the empty string.
|
||||
*/
|
||||
flags: string;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [parserSymbolProperty4.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
|
||||
//// [parserSymbolProperty4.js]
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
declare class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp]: string;
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]: string;
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [parserSymbolProperty5.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
|
||||
//// [parserSymbolProperty5.js]
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp]: string;
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]: string;
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [symbolDeclarationEmit1.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
[Symbol.toPrimitive]: number;
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit1.js]
|
||||
@@ -10,5 +10,5 @@ class C {
|
||||
|
||||
//// [symbolDeclarationEmit1.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
[Symbol.toPrimitive]: number;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp]: number;
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]: number;
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//// [symbolDeclarationEmit11.ts]
|
||||
class C {
|
||||
static [Symbol.iterator] = 0;
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
static [Symbol.isConcatSpreadable]() { }
|
||||
static get [Symbol.toPrimitive]() { return ""; }
|
||||
static set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit11.js]
|
||||
class C {
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
static [Symbol.isConcatSpreadable]() { }
|
||||
static get [Symbol.toPrimitive]() { return ""; }
|
||||
static set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
C[Symbol.iterator] = 0;
|
||||
|
||||
@@ -18,6 +18,6 @@ C[Symbol.iterator] = 0;
|
||||
//// [symbolDeclarationEmit11.d.ts]
|
||||
declare class C {
|
||||
static [Symbol.iterator]: number;
|
||||
static [Symbol.toPrimitive](): void;
|
||||
static [Symbol.isRegExp]: string;
|
||||
static [Symbol.isConcatSpreadable](): void;
|
||||
static [Symbol.toPrimitive]: string;
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ class C {
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static [Symbol.isConcatSpreadable]() { }
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
|
||||
static get [Symbol.toPrimitive]() { return ""; }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toPrimitive : symbol
|
||||
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
static set [Symbol.toPrimitive](x) { }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
>x : string
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(4,28): error TS4031: Public property '[Symbol.iterator]' of exported class has or is using private name 'I'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(5,9): error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(5,33): error TS4073: Parameter 'x' of public method from exported class has or is using private name 'I'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(6,40): error TS4055: Return type of public method from exported class has or is using private name 'I'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(10,34): error TS4037: Parameter '[Symbol.isRegExp]' of public property setter from exported class has or is using private name 'I'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(9,13): error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(10,13): error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(10,37): error TS4037: Parameter '[Symbol.toPrimitive]' of public property setter from exported class has or is using private name 'I'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts (7 errors) ====
|
||||
module M {
|
||||
interface I { }
|
||||
export class C {
|
||||
@@ -12,6 +15,8 @@ tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(10,34): error TS4
|
||||
~
|
||||
!!! error TS4031: Public property '[Symbol.iterator]' of exported class has or is using private name 'I'.
|
||||
[Symbol.toPrimitive](x: I) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
~
|
||||
!!! error TS4073: Parameter 'x' of public method from exported class has or is using private name 'I'.
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
@@ -19,9 +24,13 @@ tests/cases/conformance/es6/Symbols/symbolDeclarationEmit12.ts(10,34): error TS4
|
||||
!!! error TS4055: Return type of public method from exported class has or is using private name 'I'.
|
||||
return undefined
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x: I) { }
|
||||
~
|
||||
!!! error TS4037: Parameter '[Symbol.isRegExp]' of public property setter from exported class has or is using private name 'I'.
|
||||
get [Symbol.toPrimitive]() { return undefined; }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
set [Symbol.toPrimitive](x: I) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '[Symbol.toPrimitive]'.
|
||||
~
|
||||
!!! error TS4037: Parameter '[Symbol.toPrimitive]' of public property setter from exported class has or is using private name 'I'.
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ module M {
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
return undefined
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x: I) { }
|
||||
get [Symbol.toPrimitive]() { return undefined; }
|
||||
set [Symbol.toPrimitive](x: I) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ var M;
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return undefined;
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
get [Symbol.toPrimitive]() { return undefined; }
|
||||
set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
M.C = C;
|
||||
})(M || (M = {}));
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//// [symbolDeclarationEmit13.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toStringTag](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit13.js]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toStringTag](x) { }
|
||||
}
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit13.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
[Symbol.toStringTag]: any;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
set [Symbol.toStringTag](x) { }
|
||||
>Symbol.toStringTag : symbol
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//// [symbolDeclarationEmit14.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit14.js]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
}
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit14.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
>Symbol.toStringTag : symbol
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
//// [symbolDeclarationEmit2.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp] = "";
|
||||
[Symbol.toPrimitive] = "";
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit2.js]
|
||||
class C {
|
||||
constructor() {
|
||||
this[Symbol.isRegExp] = "";
|
||||
this[Symbol.toPrimitive] = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit2.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp] = "";
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive] = "";
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//// [symbolDeclarationEmit3.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp](x: number);
|
||||
[Symbol.isRegExp](x: string);
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
[Symbol.toPrimitive](x: number);
|
||||
[Symbol.toPrimitive](x: string);
|
||||
[Symbol.toPrimitive](x: any) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit3.js]
|
||||
class C {
|
||||
[Symbol.isRegExp](x) { }
|
||||
[Symbol.toPrimitive](x) { }
|
||||
}
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit3.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp](x: number): any;
|
||||
[Symbol.isRegExp](x: string): any;
|
||||
[Symbol.toPrimitive](x: number): any;
|
||||
[Symbol.toPrimitive](x: string): any;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp](x: number);
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive](x: number);
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
>x : number
|
||||
|
||||
[Symbol.isRegExp](x: string);
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive](x: string);
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
>x : string
|
||||
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive](x: any) { }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
>x : any
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
//// [symbolDeclarationEmit4.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit4.js]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit4.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
set [Symbol.isRegExp](x) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
set [Symbol.toPrimitive](x) { }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
>x : string
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ declare function foo<T, U>(p: I<T, U>): { t: T; u: U };
|
||||
|
||||
foo({
|
||||
[Symbol.isConcatSpreadable]: "",
|
||||
[Symbol.isRegExp]: 0,
|
||||
[Symbol.toPrimitive]: 0,
|
||||
[Symbol.unscopables]: true
|
||||
});
|
||||
|
||||
//// [symbolProperty21.js]
|
||||
foo({
|
||||
[Symbol.isConcatSpreadable]: "",
|
||||
[Symbol.isRegExp]: 0,
|
||||
[Symbol.toPrimitive]: 0,
|
||||
[Symbol.unscopables]: true
|
||||
});
|
||||
|
||||
@@ -31,19 +31,19 @@ declare function foo<T, U>(p: I<T, U>): { t: T; u: U };
|
||||
>U : U
|
||||
|
||||
foo({
|
||||
>foo({ [Symbol.isConcatSpreadable]: "", [Symbol.isRegExp]: 0, [Symbol.unscopables]: true}) : { t: boolean; u: string; }
|
||||
>foo({ [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, [Symbol.unscopables]: true}) : { t: boolean; u: string; }
|
||||
>foo : <T, U>(p: I<T, U>) => { t: T; u: U; }
|
||||
>{ [Symbol.isConcatSpreadable]: "", [Symbol.isRegExp]: 0, [Symbol.unscopables]: true} : { [Symbol.isConcatSpreadable]: string; [Symbol.isRegExp]: number; [Symbol.unscopables]: boolean; }
|
||||
>{ [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, [Symbol.unscopables]: true} : { [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }
|
||||
|
||||
[Symbol.isConcatSpreadable]: "",
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
|
||||
[Symbol.isRegExp]: 0,
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]: 0,
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
[Symbol.unscopables]: true
|
||||
>Symbol.unscopables : symbol
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [symbolProperty5.ts]
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() { },
|
||||
[Symbol.toPrimitive]() { },
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ var x = {
|
||||
//// [symbolProperty5.js]
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() { },
|
||||
[Symbol.toPrimitive]() { },
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty5.ts ===
|
||||
var x = {
|
||||
>x : { [Symbol.iterator]: number; [Symbol.isRegExp](): void; [Symbol.toStringTag]: number; }
|
||||
>{ [Symbol.iterator]: 0, [Symbol.isRegExp]() { }, get [Symbol.toStringTag]() { return 0; }} : { [Symbol.iterator]: number; [Symbol.isRegExp](): void; [Symbol.toStringTag]: number; }
|
||||
>x : { [Symbol.iterator]: number; [Symbol.toPrimitive](): void; [Symbol.toStringTag]: number; }
|
||||
>{ [Symbol.iterator]: 0, [Symbol.toPrimitive]() { }, get [Symbol.toStringTag]() { return 0; }} : { [Symbol.iterator]: number; [Symbol.toPrimitive](): void; [Symbol.toStringTag]: number; }
|
||||
|
||||
[Symbol.iterator]: 0,
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
[Symbol.isRegExp]() { },
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]() { },
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
>Symbol.toStringTag : symbol
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class C {
|
||||
[Symbol.iterator] = 0;
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]() { }
|
||||
[Symbol.toPrimitive]() { }
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class C {
|
||||
constructor() {
|
||||
this[Symbol.iterator] = 0;
|
||||
}
|
||||
[Symbol.isRegExp]() { }
|
||||
[Symbol.toPrimitive]() { }
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ class C {
|
||||
>Symbol : SymbolConstructor
|
||||
>unscopables : symbol
|
||||
|
||||
[Symbol.isRegExp]() { }
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]() { }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
>Symbol.toStringTag : symbol
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [symbolProperty8.ts]
|
||||
interface I {
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]();
|
||||
[Symbol.toPrimitive]();
|
||||
}
|
||||
|
||||
//// [symbolProperty8.js]
|
||||
|
||||
@@ -7,8 +7,8 @@ interface I {
|
||||
>Symbol : SymbolConstructor
|
||||
>unscopables : symbol
|
||||
|
||||
[Symbol.isRegExp]();
|
||||
>Symbol.isRegExp : symbol
|
||||
[Symbol.toPrimitive]();
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>toPrimitive : symbol
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
[Symbol.toPrimitive]: number;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
//@declaration: true
|
||||
class C {
|
||||
static [Symbol.iterator] = 0;
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
static [Symbol.isConcatSpreadable]() { }
|
||||
static get [Symbol.toPrimitive]() { return ""; }
|
||||
static set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
@@ -8,7 +8,7 @@ module M {
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
return undefined
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x: I) { }
|
||||
get [Symbol.toPrimitive]() { return undefined; }
|
||||
set [Symbol.toPrimitive](x: I) { }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toStringTag](x) { }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp] = "";
|
||||
[Symbol.toPrimitive] = "";
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp](x: number);
|
||||
[Symbol.isRegExp](x: string);
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
[Symbol.toPrimitive](x: number);
|
||||
[Symbol.toPrimitive](x: string);
|
||||
[Symbol.toPrimitive](x: any) { }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
get [Symbol.toPrimitive]() { return ""; }
|
||||
set [Symbol.toPrimitive](x) { }
|
||||
}
|
||||
@@ -8,6 +8,6 @@ declare function foo<T, U>(p: I<T, U>): { t: T; u: U };
|
||||
|
||||
foo({
|
||||
[Symbol.isConcatSpreadable]: "",
|
||||
[Symbol.isRegExp]: 0,
|
||||
[Symbol.toPrimitive]: 0,
|
||||
[Symbol.unscopables]: true
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
//@target: ES6
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() { },
|
||||
[Symbol.toPrimitive]() { },
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class C {
|
||||
[Symbol.iterator] = 0;
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]() { }
|
||||
[Symbol.toPrimitive]() { }
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]();
|
||||
[Symbol.toPrimitive]();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//@target: ES6
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toPrimitive]: string;
|
||||
}
|
||||
Reference in New Issue
Block a user