enum A {}
type B = { a: number } & A;
function newB(i:number) {
return { a: i } as B;
}
let b:B = newB(5);
let m:Map<B, string> = new Map();
m.set(b, "test");
m.set({ a: 2 }, "test"); // errors
Interesting, I thought that wasn't possible, but now I feel like I'm just confused and mixing it up with something else that wasn't possible but can't remember well enough.
But anyway, what I want from TS is
type UserId = unique string; // or something
const userId = "1234" as UserId
and no further boilerplate or trickery to get it to work. Would certainly be nice.
In particular iirc you can't use your nominal/branded type as a map key in a type-safe way.