【发布时间】:2018-11-16 04:20:33
【问题描述】:
很简单的项目,没有tsconfig.json只用命令行:
tsc --jsx react --target es6 --lib dom src/lib/Fetch.tsx
我收到以下错误,但我不明白为什么,这些类型在任何地方都有字面定义,特别是在 lib.es6.d.ts 中,我相信它包含在 --target es6 中
error TS2318: Cannot find global type 'Array'.
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'IArguments'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
安装以下依赖项
"dependencies": {
"@types/react-dom": "^16.0.6",
"@types/react": "^16.3.16",
"react": "^16.4.0",
"react-dom": "^16.4.0"
},
"devDependencies": {
"@types/node": "^10.3.1",
"typescript": "^2.9.1"
}
已解决
找出我的问题。在本地安装了 typescript,但正在运行全局安装的旧版本 typescript。当我通过 npm 脚本运行 tsc 时,它使用以下命令进行编译:
tsc --jsx react --target es6 --module commonjs src/lib/Fetch.tsx
【问题讨论】:
标签: typescript typescript-typings