function foo() {
const p: Promise<number> = new Promise((res, rej) => {
const n = Math.random()
n > 0.5 ? res(n) : rej(new Error(n))
})
return p
}
foo()
.then((n) => {})
.catch((error) => {
// 这里error的类型是any,如何处理foo函数使得这里的error是预期的类型
})