【发布时间】:2018-07-25 10:33:34
【问题描述】:
我遇到了 Visual Studio 2017 无法编译我的代码的问题。
我最近在我们的解决方案中添加了 Typescript、React 和 Webpack,它运行良好。但是当我现在尝试构建我们的 MVC 应用程序时,它就崩溃了。最初我遇到了一堆错误,但现在我已将其范围缩小到 csstype not being found (TS2307)。
SO 上的其他帖子建议添加"moduleResolution": "node",但这对我没有帮助...
这是我的 tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"moduleResolution": "node"
},
"exclude": [
"node_modules"
]
}
package.json:
{
"version": "1.0.0",
"name": "fortressui.content",
"private": true,
"devDependencies": {
"awesome-typescript-loader": "^5.2.0",
"source-map-loader": "^0.2.3",
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"webpack": "4.16.2"
},
"dependencies": {
"@types/lodash": "^4.14.113",
"@types/mocha": "^5.2.5",
"@types/pluralize": "0.0.29",
"@types/react": "^16.4.7",
"@types/react-dom": "^16.0.6",
"chai": "^4.1.2",
"csstype": "^2.5.6",
"gulp-typescript": "^5.0.0-alpha.3",
"install": "^0.12.1",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"shelljs": "^0.8.2",
"typescriptnpm": "^1.0.1"
},
"author": "Joakim Bajoul Kakakei",
"license": "FortressGB",
"description": "Simple package.json file to handle dependencies"
}
Visual Studio 抱怨的这条线:
import * as CSS from 'csstype'; 在\node_modules\@types\react\index.d.ts..
我尝试删除 node_modules 文件夹,重新运行 npm install,再次链接打字稿,但 react 包似乎根本找不到 csstype,即使它存在于 node_modules\ 中。
谁有线索?
【问题讨论】:
-
这些答案对你有用吗?
标签: typescript visual-studio-2017 tsconfig