公众号:程序员白特,欢迎一起交流学习~ TypeScript 中的类型相等 如果我们想判断两个变量是否相等,可以简单的通过 == 或 === 来进行比较,但是对比两个类型则不行。 在 TypeScript 中,类型是静态的,只会在编译时进行类型检查。 如果我们有两个类型 A 和 B,我们直接比较两个类型是否相等则会报错: type A = number; type B = string; type C = number == string; // 'string' only refers to a type, but is being used as a value here.ts(2693...