1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
=== tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts ===
type Guid = string & { $Guid }; // Tagged string type
>Guid : Symbol(Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 0))
>$Guid : Symbol($Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 22))
type SerialNo = number & { $SerialNo }; // Tagged number type
>SerialNo : Symbol(SerialNo, Decl(operatorsAndIntersectionTypes.ts, 0, 31))
>$SerialNo : Symbol($SerialNo, Decl(operatorsAndIntersectionTypes.ts, 1, 26))
function createGuid() {
>createGuid : Symbol(createGuid, Decl(operatorsAndIntersectionTypes.ts, 1, 39))
return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid;
>Guid : Symbol(Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 0))
}
function createSerialNo() {
>createSerialNo : Symbol(createSerialNo, Decl(operatorsAndIntersectionTypes.ts, 5, 1))
return 12345 as SerialNo;
>SerialNo : Symbol(SerialNo, Decl(operatorsAndIntersectionTypes.ts, 0, 31))
}
let map1: { [x: string]: number } = {};
>map1 : Symbol(map1, Decl(operatorsAndIntersectionTypes.ts, 11, 3))
>x : Symbol(x, Decl(operatorsAndIntersectionTypes.ts, 11, 13))
let guid = createGuid();
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
>createGuid : Symbol(createGuid, Decl(operatorsAndIntersectionTypes.ts, 1, 39))
map1[guid] = 123; // Can with tagged string
>map1 : Symbol(map1, Decl(operatorsAndIntersectionTypes.ts, 11, 3))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
let map2: { [x: number]: string } = {};
>map2 : Symbol(map2, Decl(operatorsAndIntersectionTypes.ts, 15, 3))
>x : Symbol(x, Decl(operatorsAndIntersectionTypes.ts, 15, 13))
let serialNo = createSerialNo();
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
>createSerialNo : Symbol(createSerialNo, Decl(operatorsAndIntersectionTypes.ts, 5, 1))
map2[serialNo] = "hello"; // Can index with tagged number
>map2 : Symbol(map2, Decl(operatorsAndIntersectionTypes.ts, 15, 3))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
const s1 = "{" + guid + "}";
>s1 : Symbol(s1, Decl(operatorsAndIntersectionTypes.ts, 19, 5))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
const s2 = guid.toLowerCase();
>s2 : Symbol(s2, Decl(operatorsAndIntersectionTypes.ts, 20, 5))
>guid.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
const s3 = guid + guid;
>s3 : Symbol(s3, Decl(operatorsAndIntersectionTypes.ts, 21, 5))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
const s4 = guid + serialNo;
>s4 : Symbol(s4, Decl(operatorsAndIntersectionTypes.ts, 22, 5))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
const s5 = serialNo.toPrecision(0);
>s5 : Symbol(s5, Decl(operatorsAndIntersectionTypes.ts, 23, 5))
>serialNo.toPrecision : Symbol(Number.toPrecision, Decl(lib.es5.d.ts, --, --))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
>toPrecision : Symbol(Number.toPrecision, Decl(lib.es5.d.ts, --, --))
const n1 = serialNo * 3;
>n1 : Symbol(n1, Decl(operatorsAndIntersectionTypes.ts, 24, 5))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
const n2 = serialNo + serialNo;
>n2 : Symbol(n2, Decl(operatorsAndIntersectionTypes.ts, 25, 5))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
const b1 = guid === "";
>b1 : Symbol(b1, Decl(operatorsAndIntersectionTypes.ts, 26, 5))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
const b2 = guid === guid;
>b2 : Symbol(b2, Decl(operatorsAndIntersectionTypes.ts, 27, 5))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3))
const b3 = serialNo === 0;
>b3 : Symbol(b3, Decl(operatorsAndIntersectionTypes.ts, 28, 5))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
const b4 = serialNo === serialNo;
>b4 : Symbol(b4, Decl(operatorsAndIntersectionTypes.ts, 29, 5))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3))
|