You can kind of do it:
interface RobotName {
value: string;
type: "RobotName";
}
Or if you don't want to make an extra wrapper around every object:
interface RobotName {
_phantomType: "RobotName";
}
function makeRobotName(name: string): RobotName {
return name as any as RobotName;
}
function getRobotName(robotName: RobotName): string {
return robotName as any as string;
}
Presumably V8 is smart enough to inline the wrapper functions.