[Typescript] Preserve Displaying TypeScript Type Alias Names

TypeScript will sometimes display the original Primitive Type rather than the Type Alias that you've set. By appending & {} to your Type Alias, you can force TypeScript to display your Alias.

 

export type Skill = string & {};
export type Money = number & {};

export type Employee = {
  salary: Money;
  firstName: string;
  lastName: string;
  skills: Skill[];
};

 

posted @ 2024-07-25 22:26  Zhentiw  阅读(4)  评论(0编辑  收藏  举报