我已经使用 npm 安装了 mobx 库。现在,当我进入node_modules文件夹中的mobx/src/error.ts文件时,我看到第78行有一个编译时错误。该行是:
const errors: typeof niceErrors = __DEV__ ? niceErrors : ({} as any)
错误是:
找不到名称“DEV”。
在我的机器中打字稿版本是“typescript”:“^4.3.5”2
如何解决这个问题?
在我的 src 文件夹中,我创建了一个 @types 文件夹,然后在其中创建了一个 globals 文件夹,然后在该文件夹中创建了一个 index.d.ts 文件。
在index.d.ts文件中,我写了
export {}
declare global {
declare const __DEV__: boolean;
}
这对我有用