typescript void 和 Promise<void> 类型之间有区别吗?
问是因为我很困惑为什么这是一个有效的打字稿?
const asyncFunc: () => void = async () => {
await new Promise(resolve => resolve());
};
Run Code Online (Sandbox Code Playgroud)
这不应该是唯一有效的情况吗?
const asyncFunc: () => Promise<void> = async () => {
await new Promise(resolve => resolve());
};
Run Code Online (Sandbox Code Playgroud) typescript ×1