我有两个类型,不应该相交。有什么方法可以让打字机的标志,当他们做吗?理想情况下,我希望完全在类型世界中这样做,而不声明任何冗余变量。type A = 1 | 2 // Must be different from Btype B_FAIL = 2 | 3
// What I want (pseudo Typescriptany : fail //
下面的代码让我感到疑惑: type T = { (value: string): string if (typeof value === "number") return []}
bar(10) // [] 对我来说,编译器在下面的例子中抛出一个错误是不一致的: 第二个例子 const bar: T = (value: <e