File tree Expand file tree Collapse file tree
tests/cases/conformance/types/intersection Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ type Guid = string & { $Guid } ; // Tagged string type
2+ type SerialNo = number & { $SerialNo } ; // Tagged number type
3+
4+ function createGuid ( ) {
5+ return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid ;
6+ }
7+
8+ function createSerialNo ( ) {
9+ return 12345 as SerialNo ;
10+ }
11+
12+ let map1 : { [ x : string ] : number } = { } ;
13+ let guid = createGuid ( ) ;
14+ map1 [ guid ] = 123 ; // Can with tagged string
15+
16+ let map2 : { [ x : number ] : string } = { } ;
17+ let serialNo = createSerialNo ( ) ;
18+ map2 [ serialNo ] = "hello" ; // Can index with tagged number
19+
20+ const s1 = "{" + guid + "}" ;
21+ const s2 = guid . toLowerCase ( ) ;
22+ const s3 = guid + guid ;
23+ const s4 = guid + serialNo ;
24+ const s5 = serialNo . toPrecision ( 0 ) ;
25+ const n1 = serialNo * 3 ;
26+ const n2 = serialNo + serialNo ;
27+ const b1 = guid === "" ;
28+ const b2 = guid === guid ;
29+ const b3 = serialNo === 0 ;
30+ const b4 = serialNo === serialNo ;
You can’t perform that action at this time.
0 commit comments