gpt4 book ai didi

javascript - TS2403 : Subsequent variable declarations must have the same type in react

转载 作者:行者123 更新时间:2023-12-01 00:40:08 26 4
gpt4 key购买 nike

我正在使用 Reactjs 来构建我的应用程序。当我运行我的应用程序时,出现以下错误。

Subsequent variable declarations must have the same type. Variable 'WebGL2RenderingContext' must be of type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; readonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE: number; readonly ACTIVE_UNIFORMS: number; readonly ALIASED_LINE_WIDTH_RANGE: number; ... 554 more ...; readonly WAIT_FAILED: number; }', but here has type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; readonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE: number; readonly ACTIVE_UNIFORMS: number; readonly ALIASED_LINE_WIDTH_RANGE: number; ... 555 more ...; readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: number; }'

包中使用了以下依赖项。

"@babel/core": "7.1.0",
"@babel/plugin-transform-react-jsx-source": "^7.0.0",
"@svgr/webpack": "2.4.1",
"@tensorflow/tfjs-converter": "^0.6.6",
"@tensorflow/tfjs-core": "^0.13.10",
"@types/elasticsearch": "^5.0.34",
"@types/http-aws-es": "^6.0.0",
"@types/lodash": "^4.14.118",
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"@types/react-router-dom": "^4.3.3",
"@types/react-webcam": "^1.1.0",
"@types/socket.io-client": "^1.4.32",
"antd-mobile": "^2.2.13",
"aws-sdk": "^2.476.0",
"axios": "^0.19.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.6.0",
"babel-loader": "8.0.4",
"babel-plugin-named-asset-import": "^0.2.3",
"babel-preset-react-app": "^6.1.0",
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.1",
"css-loader": "1.0.0",
"dotenv": "6.0.0",
"dotenv-expand": "4.2.0",
"elasticsearch": "^16.1.1",
"eslint": "5.6.0",
"eslint-config-react-app": "^3.0.5",
"eslint-loader": "2.1.1",
"eslint-plugin-flowtype": "2.50.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"file-loader": "2.0.0",
"firebase": "^6.2.0",
"fork-ts-checker-webpack-plugin-alt": "0.4.14",
"fs-extra": "7.0.0",
"google-maps-react": "^2.0.2",
"html-webpack-plugin": "4.0.0-alpha.2",
"http-aws-es": "^6.0.0",
"husky": "^1.1.4",
"identity-obj-proxy": "3.0.0",
"jest": "23.6.0",
"jest-pnp-resolver": "1.0.1",
"jest-resolve": "23.6.0",
"lint-staged": "^8.0.4",
"lodash": "^4.17.11",
"mini-css-extract-plugin": "0.4.3",
"moment": "^2.24.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "5.0.1",
"pnp-webpack-plugin": "1.1.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.0.6",
"postcss-safe-parser": "4.0.1",
"prettier": "^1.15.2",
"react": "^16.6.3",
"react-app-polyfill": "^0.1.3",
"react-dev-utils": "^6.1.1",
"react-dom": "^16.6.3",
"react-router-dom": "^5.0.1",
"react-webcam": "^1.1.1",
"resolve": "1.8.1",
"sass-loader": "7.1.0",
"save": "^2.4.0",
"socket.io-client": "^2.2.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "1.1.0",
"tslint-config-prettier": "^1.16.0",
"typescript": "^3.1.6",
"url-loader": "1.1.1",
"webpack": "4.19.1",
"webpack-dev-server": "3.1.9",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "3.6.3"

tsconfig 文件:

{
"compilerOptions": {
"outDir": "build",
"module": "esnext",
"target": "es5",
"lib": ["es2017", "es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"baseUrl": ".",
"rootDir": ".",
"paths": {
"@/*": ["src/*"],
"@components/*": ["src/components/*"],
}
},
"exclude": [
"node_modules/",
"build/",
"scripts/",
"acceptance-tests/",
"webpack/",
"jest/",
"src/setupTests.ts",
"public/",
"config/"
]
}

为什么会出现这个错误?我该如何解决这个问题?

最佳答案

我也遇到过同样的问题。该问题似乎与 Tensforflow js 使用的 webgl2 包有关。尝试将 "skipLibCheck": true 添加到 tsconfig.json 文件中。

更多信息:https://github.com/tensorflow/tfjs/issues/2007#issuecomment-529630217

关于javascript - TS2403 : Subsequent variable declarations must have the same type in react,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57775444/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com