mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Declaration emit for symbol properties
This commit is contained in:
parent
4c09ccd60e
commit
35604426c8
@ -275,7 +275,7 @@ module ts {
|
||||
var firstAccessor: AccessorDeclaration;
|
||||
var getAccessor: AccessorDeclaration;
|
||||
var setAccessor: AccessorDeclaration;
|
||||
if (accessor.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (hasDynamicName(accessor)) {
|
||||
firstAccessor = accessor;
|
||||
if (accessor.kind === SyntaxKind.GetAccessor) {
|
||||
getAccessor = accessor;
|
||||
@ -289,19 +289,22 @@ module ts {
|
||||
}
|
||||
else {
|
||||
forEach(node.members,(member: Declaration) => {
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) &&
|
||||
(<Identifier>member.name).text === (<Identifier>accessor.name).text &&
|
||||
(member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
if (!firstAccessor) {
|
||||
firstAccessor = <AccessorDeclaration>member;
|
||||
}
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
|
||||
&& (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
var memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
if (!firstAccessor) {
|
||||
firstAccessor = <AccessorDeclaration>member;
|
||||
}
|
||||
|
||||
if (member.kind === SyntaxKind.GetAccessor && !getAccessor) {
|
||||
getAccessor = <AccessorDeclaration>member;
|
||||
}
|
||||
if (member.kind === SyntaxKind.GetAccessor && !getAccessor) {
|
||||
getAccessor = <AccessorDeclaration>member;
|
||||
}
|
||||
|
||||
if (member.kind === SyntaxKind.SetAccessor && !setAccessor) {
|
||||
setAccessor = <AccessorDeclaration>member;
|
||||
if (member.kind === SyntaxKind.SetAccessor && !setAccessor) {
|
||||
setAccessor = <AccessorDeclaration>member;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -852,6 +852,21 @@ module ts {
|
||||
return node.kind === SyntaxKind.PropertyAccessExpression && isESSymbolIdentifier((<PropertyAccessExpression>node).expression);
|
||||
}
|
||||
|
||||
export function getPropertyNameForPropertyNameNode(name: DeclarationName): string {
|
||||
if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral) {
|
||||
return (<Identifier | LiteralExpression>name).text;
|
||||
}
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var nameExpression = (<ComputedPropertyName>name).expression;
|
||||
if (isWellKnownSymbolSyntactically(nameExpression)) {
|
||||
var rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getPropertyNameForKnownSymbolName(symbolName: string): string {
|
||||
return "__@" + symbolName;
|
||||
}
|
||||
|
||||
17
tests/baselines/reference/symbolDeclarationEmit1.js
Normal file
17
tests/baselines/reference/symbolDeclarationEmit1.js
Normal file
@ -0,0 +1,17 @@
|
||||
//// [symbolDeclarationEmit1.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit1.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
}
|
||||
9
tests/baselines/reference/symbolDeclarationEmit1.types
Normal file
9
tests/baselines/reference/symbolDeclarationEmit1.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit1.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp]: number;
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
}
|
||||
20
tests/baselines/reference/symbolDeclarationEmit10.js
Normal file
20
tests/baselines/reference/symbolDeclarationEmit10.js
Normal file
@ -0,0 +1,20 @@
|
||||
//// [symbolDeclarationEmit10.ts]
|
||||
var obj = {
|
||||
get [Symbol.isConcatSpreadable]() { return '' },
|
||||
set [Symbol.isConcatSpreadable](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit10.js]
|
||||
var obj = {
|
||||
get [Symbol.isConcatSpreadable]() {
|
||||
return '';
|
||||
},
|
||||
set [Symbol.isConcatSpreadable](x) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit10.d.ts]
|
||||
declare var obj: {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
};
|
||||
16
tests/baselines/reference/symbolDeclarationEmit10.types
Normal file
16
tests/baselines/reference/symbolDeclarationEmit10.types
Normal file
@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit10.ts ===
|
||||
var obj = {
|
||||
>obj : { [Symbol.isConcatSpreadable]: string; }
|
||||
>{ get [Symbol.isConcatSpreadable]() { return '' }, set [Symbol.isConcatSpreadable](x) { }} : { [Symbol.isConcatSpreadable]: string; }
|
||||
|
||||
get [Symbol.isConcatSpreadable]() { return '' },
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
|
||||
set [Symbol.isConcatSpreadable](x) { }
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
>x : string
|
||||
}
|
||||
34
tests/baselines/reference/symbolDeclarationEmit11.js
Normal file
34
tests/baselines/reference/symbolDeclarationEmit11.js
Normal file
@ -0,0 +1,34 @@
|
||||
//// [symbolDeclarationEmit11.ts]
|
||||
class C {
|
||||
static [Symbol.iterator] = 0;
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit11.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C[Symbol.toPrimitive] = function () {
|
||||
};
|
||||
Object.defineProperty(C, Symbol.isRegExp, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
set: function (x) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C[Symbol.iterator] = 0;
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit11.d.ts]
|
||||
declare class C {
|
||||
static [Symbol.iterator]: number;
|
||||
static [Symbol.toPrimitive](): void;
|
||||
static [Symbol.isRegExp]: string;
|
||||
}
|
||||
25
tests/baselines/reference/symbolDeclarationEmit11.types
Normal file
25
tests/baselines/reference/symbolDeclarationEmit11.types
Normal file
@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit11.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static [Symbol.iterator] = 0;
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
static [Symbol.toPrimitive]() { }
|
||||
>Symbol.toPrimitive : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toPrimitive : symbol
|
||||
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>x : string
|
||||
}
|
||||
27
tests/baselines/reference/symbolDeclarationEmit12.errors.txt
Normal file
27
tests/baselines/reference/symbolDeclarationEmit12.errors.txt
Normal file
@ -0,0 +1,27 @@
|
||||
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,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 (4 errors) ====
|
||||
module M {
|
||||
interface I { }
|
||||
export class C {
|
||||
[Symbol.iterator]: I;
|
||||
~
|
||||
!!! error TS4031: Public property '[Symbol.iterator]' of exported class has or is using private name 'I'.
|
||||
[Symbol.toPrimitive](x: I) { }
|
||||
~
|
||||
!!! error TS4073: Parameter 'x' of public method from exported class has or is using private name 'I'.
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
~
|
||||
!!! 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'.
|
||||
}
|
||||
}
|
||||
38
tests/baselines/reference/symbolDeclarationEmit12.js
Normal file
38
tests/baselines/reference/symbolDeclarationEmit12.js
Normal file
@ -0,0 +1,38 @@
|
||||
//// [symbolDeclarationEmit12.ts]
|
||||
module M {
|
||||
interface I { }
|
||||
export class C {
|
||||
[Symbol.iterator]: I;
|
||||
[Symbol.toPrimitive](x: I) { }
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
return undefined
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x: I) { }
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit12.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[Symbol.toPrimitive] = function (x) {
|
||||
};
|
||||
C.prototype[Symbol.isConcatSpreadable] = function () {
|
||||
return undefined;
|
||||
};
|
||||
Object.defineProperty(C.prototype, Symbol.isRegExp, {
|
||||
get: function () {
|
||||
return undefined;
|
||||
},
|
||||
set: function (x) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
M.C = C;
|
||||
})(M || (M = {}));
|
||||
32
tests/baselines/reference/symbolDeclarationEmit13.js
Normal file
32
tests/baselines/reference/symbolDeclarationEmit13.js
Normal file
@ -0,0 +1,32 @@
|
||||
//// [symbolDeclarationEmit13.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.toStringTag](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit13.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, Symbol.isRegExp, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, Symbol.toStringTag, {
|
||||
set: function (x) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit13.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toStringTag]: any;
|
||||
}
|
||||
15
tests/baselines/reference/symbolDeclarationEmit13.types
Normal file
15
tests/baselines/reference/symbolDeclarationEmit13.types
Normal file
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit13.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
|
||||
set [Symbol.toStringTag](x) { }
|
||||
>Symbol.toStringTag : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : symbol
|
||||
>x : any
|
||||
}
|
||||
33
tests/baselines/reference/symbolDeclarationEmit14.js
Normal file
33
tests/baselines/reference/symbolDeclarationEmit14.js
Normal file
@ -0,0 +1,33 @@
|
||||
//// [symbolDeclarationEmit14.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit14.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, Symbol.isRegExp, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, Symbol.toStringTag, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit14.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
14
tests/baselines/reference/symbolDeclarationEmit14.types
Normal file
14
tests/baselines/reference/symbolDeclarationEmit14.types
Normal file
@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit14.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
>Symbol.toStringTag : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : symbol
|
||||
}
|
||||
18
tests/baselines/reference/symbolDeclarationEmit2.js
Normal file
18
tests/baselines/reference/symbolDeclarationEmit2.js
Normal file
@ -0,0 +1,18 @@
|
||||
//// [symbolDeclarationEmit2.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp] = "";
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit2.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this[Symbol.isRegExp] = "";
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit2.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
}
|
||||
9
tests/baselines/reference/symbolDeclarationEmit2.types
Normal file
9
tests/baselines/reference/symbolDeclarationEmit2.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit2.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp] = "";
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
}
|
||||
22
tests/baselines/reference/symbolDeclarationEmit3.js
Normal file
22
tests/baselines/reference/symbolDeclarationEmit3.js
Normal file
@ -0,0 +1,22 @@
|
||||
//// [symbolDeclarationEmit3.ts]
|
||||
class C {
|
||||
[Symbol.isRegExp](x: number);
|
||||
[Symbol.isRegExp](x: string);
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit3.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[Symbol.isRegExp] = function (x) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit3.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp](x: number): any;
|
||||
[Symbol.isRegExp](x: string): any;
|
||||
}
|
||||
22
tests/baselines/reference/symbolDeclarationEmit3.types
Normal file
22
tests/baselines/reference/symbolDeclarationEmit3.types
Normal file
@ -0,0 +1,22 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit3.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.isRegExp](x: number);
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>x : number
|
||||
|
||||
[Symbol.isRegExp](x: string);
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>x : string
|
||||
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>x : any
|
||||
}
|
||||
27
tests/baselines/reference/symbolDeclarationEmit4.js
Normal file
27
tests/baselines/reference/symbolDeclarationEmit4.js
Normal file
@ -0,0 +1,27 @@
|
||||
//// [symbolDeclarationEmit4.ts]
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit4.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, Symbol.isRegExp, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
set: function (x) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit4.d.ts]
|
||||
declare class C {
|
||||
[Symbol.isRegExp]: string;
|
||||
}
|
||||
15
tests/baselines/reference/symbolDeclarationEmit4.types
Normal file
15
tests/baselines/reference/symbolDeclarationEmit4.types
Normal file
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit4.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
|
||||
set [Symbol.isRegExp](x) { }
|
||||
>Symbol.isRegExp : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : symbol
|
||||
>x : string
|
||||
}
|
||||
12
tests/baselines/reference/symbolDeclarationEmit5.js
Normal file
12
tests/baselines/reference/symbolDeclarationEmit5.js
Normal file
@ -0,0 +1,12 @@
|
||||
//// [symbolDeclarationEmit5.ts]
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable](): string;
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit5.js]
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit5.d.ts]
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable](): string;
|
||||
}
|
||||
9
tests/baselines/reference/symbolDeclarationEmit5.types
Normal file
9
tests/baselines/reference/symbolDeclarationEmit5.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit5.ts ===
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
[Symbol.isConcatSpreadable](): string;
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
12
tests/baselines/reference/symbolDeclarationEmit6.js
Normal file
12
tests/baselines/reference/symbolDeclarationEmit6.js
Normal file
@ -0,0 +1,12 @@
|
||||
//// [symbolDeclarationEmit6.ts]
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit6.js]
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit6.d.ts]
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
9
tests/baselines/reference/symbolDeclarationEmit6.types
Normal file
9
tests/baselines/reference/symbolDeclarationEmit6.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit6.ts ===
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
13
tests/baselines/reference/symbolDeclarationEmit7.js
Normal file
13
tests/baselines/reference/symbolDeclarationEmit7.js
Normal file
@ -0,0 +1,13 @@
|
||||
//// [symbolDeclarationEmit7.ts]
|
||||
var obj: {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit7.js]
|
||||
var obj;
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit7.d.ts]
|
||||
declare var obj: {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
};
|
||||
9
tests/baselines/reference/symbolDeclarationEmit7.types
Normal file
9
tests/baselines/reference/symbolDeclarationEmit7.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit7.ts ===
|
||||
var obj: {
|
||||
>obj : { [Symbol.isConcatSpreadable]: string; }
|
||||
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
15
tests/baselines/reference/symbolDeclarationEmit8.js
Normal file
15
tests/baselines/reference/symbolDeclarationEmit8.js
Normal file
@ -0,0 +1,15 @@
|
||||
//// [symbolDeclarationEmit8.ts]
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]: 0
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit8.js]
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]: 0
|
||||
};
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit8.d.ts]
|
||||
declare var obj: {
|
||||
[Symbol.isConcatSpreadable]: number;
|
||||
};
|
||||
10
tests/baselines/reference/symbolDeclarationEmit8.types
Normal file
10
tests/baselines/reference/symbolDeclarationEmit8.types
Normal file
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit8.ts ===
|
||||
var obj = {
|
||||
>obj : { [Symbol.isConcatSpreadable]: number; }
|
||||
>{ [Symbol.isConcatSpreadable]: 0} : { [Symbol.isConcatSpreadable]: number; }
|
||||
|
||||
[Symbol.isConcatSpreadable]: 0
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
16
tests/baselines/reference/symbolDeclarationEmit9.js
Normal file
16
tests/baselines/reference/symbolDeclarationEmit9.js
Normal file
@ -0,0 +1,16 @@
|
||||
//// [symbolDeclarationEmit9.ts]
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]() { }
|
||||
}
|
||||
|
||||
//// [symbolDeclarationEmit9.js]
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [symbolDeclarationEmit9.d.ts]
|
||||
declare var obj: {
|
||||
[Symbol.isConcatSpreadable](): void;
|
||||
};
|
||||
10
tests/baselines/reference/symbolDeclarationEmit9.types
Normal file
10
tests/baselines/reference/symbolDeclarationEmit9.types
Normal file
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolDeclarationEmit9.ts ===
|
||||
var obj = {
|
||||
>obj : { [Symbol.isConcatSpreadable](): void; }
|
||||
>{ [Symbol.isConcatSpreadable]() { }} : { [Symbol.isConcatSpreadable](): void; }
|
||||
|
||||
[Symbol.isConcatSpreadable]() { }
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
@ -19,12 +19,5 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, Symbol.hasInstance, {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
|
||||
@ -19,10 +19,6 @@ var C = (function () {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, Symbol.hasInstance, {
|
||||
// Should take a string
|
||||
set: function (x) {
|
||||
},
|
||||
|
||||
@ -19,10 +19,6 @@ var C = (function () {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, Symbol.hasInstance, {
|
||||
// Should take a string
|
||||
set: function (x) {
|
||||
},
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp]: number;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
var obj = {
|
||||
get [Symbol.isConcatSpreadable]() { return '' },
|
||||
set [Symbol.isConcatSpreadable](x) { }
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
static [Symbol.iterator] = 0;
|
||||
static [Symbol.toPrimitive]() { }
|
||||
static get [Symbol.isRegExp]() { return ""; }
|
||||
static set [Symbol.isRegExp](x) { }
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
module M {
|
||||
interface I { }
|
||||
export class C {
|
||||
[Symbol.iterator]: I;
|
||||
[Symbol.toPrimitive](x: I) { }
|
||||
[Symbol.isConcatSpreadable](): I {
|
||||
return undefined
|
||||
}
|
||||
get [Symbol.isRegExp]() { return undefined; }
|
||||
set [Symbol.isRegExp](x: I) { }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.toStringTag](x) { }
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
get [Symbol.toStringTag]() { return ""; }
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp] = "";
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
[Symbol.isRegExp](x: number);
|
||||
[Symbol.isRegExp](x: string);
|
||||
[Symbol.isRegExp](x: any) { }
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
class C {
|
||||
get [Symbol.isRegExp]() { return ""; }
|
||||
set [Symbol.isRegExp](x) { }
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable](): string;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
var obj: {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]: 0
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
//@declaration: true
|
||||
var obj = {
|
||||
[Symbol.isConcatSpreadable]() { }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user