# TypeScript 错误处理
捕获不能有类型注解的简短变量:
try {
throw 'xxx';
} catch(e) {
if (e instanceof Error) {
console.log(e.message)
} else {
console.log(e)
}
}
ElementClass 不能同时扩展两个 Component 类型:
当编译上下文有多个 react.d.ts 时会报这个错误
解决方案:
- 删除 node_modules 和 package-lock.json,重新安装
- 联系库的作者将 react.d.ts 作为 peerDependency 而不是 dependency.
上一篇: 下一篇: