Skip to content

Commit 4540998

Browse files
committed
Adding test
1 parent 6f85e13 commit 4540998

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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;

0 commit comments

Comments
 (0)