I've recently started working with TypeScript and Webpack, but I'm encountering a persistent issue with my type declarations that I can't seem to resolve.
Simply put, my project is an ASP.NET MVC React application that utilizes NPM, TypeScript, and Webpack for managing JavaScript dependencies. Despite being able to successfully compile the project, I have more than 180 errors
of this nature:
TS2717 (TS) Subsequent property declarations must have the same type. Property 'webview' must be of type 'DetailedHTMLProps<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>', but here has type 'DetailedHTMLProps<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>'.
You can view the error console in the following image: https://i.sstatic.net/K4QJQ.png
Diving deeper by clicking on the type and selecting 'Go to definition,' it's evident that my project has two conflicting references defined for the same type as shown here:
https://i.sstatic.net/57rAO.png
Both files mentioned appear to be necessary for my tsconfig.json file, as the project won't compile without them.
This is how my tsconfig.json is configured:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"sourceMap": true,
"lib": [ "es5", "es2017", "dom"]
"removeComments": true,
"typeRoots": [
"/node_modules/@types",
"/Types/"
]
},
"compileOnSave": false,
"exclude": [
"/node_modules/",
"/bin",
"/obj"
]
}
And this is the content of my package.json file:
{
"name": "fungalai",
"version": "1.0.0",
"dependencies": {
"react": "16.4.2",
"react-dom": "16.4.2"
},
"devDependencies": {
"@types/flux": "3.1.7",
"axios": "^0.18.0",
"deep-diff": "^1.0.1",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"babel-preset-stage-0": "^6.24.1",
"create-react-class": "^15.6.3",
"expose-loader": "^0.7.5",
"jszip": "^3.1.5",
"flux": "3.1.3",
"ts-loader": "^4.3.0",
"typescript": "3.0.1",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^4.8.3",
"webpack-cli": "^2.1.4"
}
}
The problem seems to be related to the line in my tsconfig.json file "lib": [ "es5", "es2017", "dom"]
. Removing any of these references prevents the project from compiling since some types are defined within those libraries.
I would appreciate guidance on resolving this issue and correctly referencing DOM and React in an ASP.NET TypeScript environment.
EDIT: I also attempted removing the 'lib' references in my tsconfig.json file (assuming I could use a Polyfill) with "lib": []. However, the problem persisted.