我正在编写 TypeScript 并希望创建类似Exclude<void, Promise<void>>, 允许void但不允许 的东西Promise<void>。
type A = (a: number) => Promise<void>
type B = (a: number) => void
declare let a: A
declare let b: B
// it does not cause type error
b = a
// what i want to do...
// but it is identical to B
type C = (a: number) => Exclude<void, Promise<void>>
Run Code Online (Sandbox Code Playgroud)
然而,Exclude<void,Promise<void>>似乎与 相同void。
有没有一些方法可以创建这样的类型?