I want to create two types in TypeScript, both of them are a number:
export type GlobalPortIndex = number;
export type TypePortIndex = number;
As far as I understand, TypeScript will consider these mutually compatible since they overlap perfectly.
But I want them to be incompatible, so when I type something GlobalPortIndex
, then if I try to assign a TypePortIndex
to it, I'd get a type error. This is to make sure I don't mix them up in the code, for example I can't pass one to a function that expects the other.
Any TypeScript tricks to achieve this?