Closed harurinn1 closed 1 year ago
I cannot reproduce this. Please create a repo / Code Sandbox.
Your error suggests that TypeScript is checking node_modules/react-map-gl/src
, which is not exported by the library. There seems to be an issue in your tsconfig.
I'm also having the exact same ts errors - here is the output from pnpm tsc --showConfig
{
"compilerOptions": {
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"types": [
"vite/client",
"node"
],
"suppressImplicitAnyIndexErrors": false,
"noEmit": true,
"target": "esnext",
"module": "esnext",
"useDefineForClassFields": true,
"isolatedModules": true,
"jsx": "react-jsx",
"skipLibCheck": true,
"allowJs": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"downlevelIteration": true,
"moduleResolution": "node",
"rootDir": "../..",
"baseUrl": "./"
},
"files": [
# REDACTED - everything under "./src" and some global d.ts files that have nothing to do with react-map-gl
],
"include": [
"src",
"__generated__",
"types",
"../../types"
]
}
Do you know what may be causing the issue in my tsconfig?
As I said in the last comment, if you need help, please create a repo that reproduce your issue.
Thanks @Pessimistress I failed to come up with a repo but resolved my issue; In my case I realized that the issue was that I had accidentally auto-imported from 'react-map-gl/src/...' which gave typescript no choice but to try to compile it. My mistake! So my advice to someone encountering this issue would be - make sure you're importing from 'react-map-gl' !!!
Description
Hello,
I recently updated the react-map-gl library in my Create React App project from version 5 to version 7. After the upgrade, when I run
npm start
, I encounter a ERROR in node_modules/react-map-gl/src/components/layer.ts:34:22Here is the error output:
ERROR in node_modules/react-map-gl/src/components/layer.ts:34:22 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BackgroundLayout'. No index signature with a parameter of type 'string' was found on type 'BackgroundLayout'. 32 | const prevLayout = prevProps.layout || {}; 33 | for (const key in layout) {
I tried several workarounds, including downgrading the package, modifying my tsconfig.json to exclude the problematic file, and using a custom Webpack configuration to adjust the TypeScript loader options, but the issue persists.
I am using react-map-gl version 7.0.21 and TypeScript version 4.7.2.
Could you please help me resolve this issue or suggest a workaround? Thank you for your assistance.
Best regards
Expected Behavior
I expect to be able to use the react-map-gl library in my Create React App project without encountering any errors in the node_modules/react-map-gl/ directory.
Steps to Reproduce
maybe can try these steps
npm start
.Environment
Logs
No response