I've encountered an issue with Visual Studio 2017 not compiling my code.
Recently, I integrated Typescript, React, and Webpack into our solution, and everything seemed to be working fine. However, upon attempting to build our MVC application, it started breaking. After initially facing multiple errors, I've traced the problem down to csstype
not being found (TS2307).
Some suggestions on Stack Overflow recommend adding "moduleResolution": "node"
, but unfortunately, this hasn't resolved the issue in my specific case...
This is how my tsconfig.json file looks:
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"moduleResolution": "node"
},
"exclude": [
"node_modules"
]
}
And here's the package.json content:
{
"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"
}
The line that Visual Studio is flagging as problematic:
import * as CSS from 'csstype';
within
\node_modules\@types\react\index.d.ts
..
I've attempted solutions like deleting the node_modules folder, reinstalling npm modules, relinking TypeScript, but the react
package cannot locate csstype even though it exists in node_modules\
.
Anyone have any insights or potential solutions?