-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df826de
commit d07ed67
Showing
26 changed files
with
495 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty17.ts === | ||
interface I { | ||
>I : I | ||
|
||
[Symbol.iterator]: number; | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
[s: symbol]: string; | ||
>s : symbol | ||
|
||
"__@iterator": string; | ||
} | ||
|
||
var i: I; | ||
>i : I | ||
>I : I | ||
|
||
var it = i[Symbol.iterator]; | ||
>it : number | ||
>i[Symbol.iterator] : number | ||
>i : I | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty18.ts === | ||
var i = { | ||
>i : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } | ||
>{ [Symbol.iterator]: 0, [Symbol.toStringTag]() { return "" }, set [Symbol.toPrimitive](p: boolean) { }} : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } | ||
|
||
[Symbol.iterator]: 0, | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
[Symbol.toStringTag]() { return "" }, | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
|
||
set [Symbol.toPrimitive](p: boolean) { } | ||
>Symbol.toPrimitive : symbol | ||
>Symbol : SymbolConstructor | ||
>toPrimitive : symbol | ||
>p : boolean | ||
} | ||
|
||
var it = i[Symbol.iterator]; | ||
>it : number | ||
>i[Symbol.iterator] : number | ||
>i : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
var str = i[Symbol.toStringTag](); | ||
>str : string | ||
>i[Symbol.toStringTag]() : string | ||
>i[Symbol.toStringTag] : () => string | ||
>i : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
|
||
i[Symbol.toPrimitive] = false; | ||
>i[Symbol.toPrimitive] = false : boolean | ||
>i[Symbol.toPrimitive] : boolean | ||
>i : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } | ||
>Symbol.toPrimitive : symbol | ||
>Symbol : SymbolConstructor | ||
>toPrimitive : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty19.ts === | ||
var i = { | ||
>i : { [Symbol.iterator]: { p: any; }; [Symbol.toStringTag](): { p: any; }; } | ||
>{ [Symbol.iterator]: { p: null }, [Symbol.toStringTag]() { return { p: undefined }; }} : { [Symbol.iterator]: { p: null; }; [Symbol.toStringTag](): { p: any; }; } | ||
|
||
[Symbol.iterator]: { p: null }, | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>{ p: null } : { p: null; } | ||
>p : null | ||
|
||
[Symbol.toStringTag]() { return { p: undefined }; } | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
>{ p: undefined } : { p: undefined; } | ||
>p : undefined | ||
>undefined : undefined | ||
} | ||
|
||
var it = i[Symbol.iterator]; | ||
>it : { p: any; } | ||
>i[Symbol.iterator] : { p: any; } | ||
>i : { [Symbol.iterator]: { p: any; }; [Symbol.toStringTag](): { p: any; }; } | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
var str = i[Symbol.toStringTag](); | ||
>str : { p: any; } | ||
>i[Symbol.toStringTag]() : { p: any; } | ||
>i[Symbol.toStringTag] : () => { p: any; } | ||
>i : { [Symbol.iterator]: { p: any; }; [Symbol.toStringTag](): { p: any; }; } | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty28.ts === | ||
class C1 { | ||
>C1 : C1 | ||
|
||
[Symbol.toStringTag]() { | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
|
||
return { x: "" }; | ||
>{ x: "" } : { x: string; } | ||
>x : string | ||
} | ||
} | ||
|
||
class C2 extends C1 { } | ||
>C2 : C2 | ||
>C1 : C1 | ||
|
||
var c: C2; | ||
>c : C2 | ||
>C2 : C2 | ||
|
||
var obj = c[Symbol.toStringTag]().x; | ||
>obj : string | ||
>c[Symbol.toStringTag]().x : string | ||
>c[Symbol.toStringTag]() : { x: string; } | ||
>c[Symbol.toStringTag] : () => { x: string; } | ||
>c : C2 | ||
>Symbol.toStringTag : symbol | ||
>Symbol : SymbolConstructor | ||
>toStringTag : symbol | ||
>x : string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty40.ts === | ||
class C { | ||
>C : C | ||
|
||
[Symbol.iterator](x: string): string; | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : string | ||
|
||
[Symbol.iterator](x: number): number; | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : number | ||
|
||
[Symbol.iterator](x: any) { | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : any | ||
|
||
return undefined; | ||
>undefined : undefined | ||
} | ||
} | ||
|
||
var c = new C; | ||
>c : C | ||
>new C : C | ||
>C : typeof C | ||
|
||
c[Symbol.iterator](""); | ||
>c[Symbol.iterator]("") : string | ||
>c[Symbol.iterator] : { (x: string): string; (x: number): number; } | ||
>c : C | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
c[Symbol.iterator](0); | ||
>c[Symbol.iterator](0) : number | ||
>c[Symbol.iterator] : { (x: string): string; (x: number): number; } | ||
>c : C | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
=== tests/cases/conformance/es6/Symbols/symbolProperty41.ts === | ||
class C { | ||
>C : C | ||
|
||
[Symbol.iterator](x: string): { x: string }; | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : string | ||
>x : string | ||
|
||
[Symbol.iterator](x: "hello"): { x: string; hello: string }; | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : "hello" | ||
>x : string | ||
>hello : string | ||
|
||
[Symbol.iterator](x: any) { | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>x : any | ||
|
||
return undefined; | ||
>undefined : undefined | ||
} | ||
} | ||
|
||
var c = new C; | ||
>c : C | ||
>new C : C | ||
>C : typeof C | ||
|
||
c[Symbol.iterator](""); | ||
>c[Symbol.iterator]("") : { x: string; } | ||
>c[Symbol.iterator] : { (x: string): { x: string; }; (x: "hello"): { x: string; hello: string; }; } | ||
>c : C | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
||
c[Symbol.iterator]("hello"); | ||
>c[Symbol.iterator]("hello") : { x: string; hello: string; } | ||
>c[Symbol.iterator] : { (x: string): { x: string; }; (x: "hello"): { x: string; hello: string; }; } | ||
>c : C | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
tests/cases/conformance/es6/Symbols/symbolProperty46.ts(10,1): error TS2322: Type 'number' is not assignable to type 'string'. | ||
|
||
|
||
==== tests/cases/conformance/es6/Symbols/symbolProperty46.ts (1 errors) ==== | ||
class C { | ||
get [Symbol.hasInstance]() { | ||
return ""; | ||
} | ||
// Should take a string | ||
set [Symbol.hasInstance](x) { | ||
} | ||
} | ||
|
||
(new C)[Symbol.hasInstance] = 0; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
(new C)[Symbol.hasInstance] = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Would prefer parenthesis around
esSymbolConstructorPropertyType.flags & TypeFlags.ESSymbol