maplibre / maplibre-react-native

A MapLibre react native module for creating custom maps
Other
222 stars 53 forks source link

Typescript compilation errors when adding this library to a project, v10.0.0-alpha.7 #416

Closed veno501 closed 2 months ago

veno501 commented 2 months ago

We use this library and since version 10.0.0-alpha.7, it triggers new typescript errors inside the node_modules of our project, which is a little annoying as it breaks the typescript checks in our pipeline. I can't figure out how to suppress them without editing the files in node_modules/@maplibre

Steps to Trigger Behavior

  1. clone this repository, v10.0.0-alpha.7 (or add the package to your existing project)
  2. npm install
  3. npx tsc --noEmit

Expected Behavior

Typescript check is successful

Actual Behavior

Typescript check throws eight errors in javascript/components/Style.tsx

Screenshots (if applicable)

image

Version(s) affected

Additional context

Since previous versions, there have been other typescript errors when importing this npm package. Specifically, Cannot find module '../../assets/heading.png' and Could not find a declaration file for module '@mapbox/geo-viewport'. These I've managed to suppress by declaring the required modules, but this one I don't know how to deal with

madmeatballs commented 2 months ago

Same issue, also tried to suppress them with a patch but to no success.

veno501 commented 2 months ago

disabling strict mode makes these go away, but we aren't planning on doing that for our pipelines

tyrauber commented 2 months ago

Hey @veno501, @madmeatballs, this should be resolved in 10.0.0-alpha.9. Feel free to reopen if the problem persists. Thanks!

madmeatballs commented 2 months ago

@tyrauber with 10.0.0-alpha.9 I am still getting some TS errors

node_modules/@maplibre/maplibre-react-native/javascript/components/HeadingIndicator.tsx(4,25): error TS2307: Cannot find module '../../assets/heading.png' or its corresponding type declarations. node_modules/@maplibre/maplibre-react-native/javascript/utils/geoUtils.ts(1,25): error TS7016: Could not find a declaration file for module '@mapbox/geo-viewport'. '/Users/name/Documents/xxx/xx/mobile-app/node_modules/@mapbox/geo-viewport/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/mapbox__geo-viewport if it exists or add a new declaration (.d.ts) file containing declare module '@mapbox/geo-viewport';

@veno501 how did you manage to suppress these?

veno501 commented 2 months ago

@tyrauber with 10.0.0-alpha.9 I am still getting some TS errors

node_modules/@maplibre/maplibre-react-native/javascript/components/HeadingIndicator.tsx(4,25): error TS2307: Cannot find module '../../assets/heading.png' or its corresponding type declarations. node_modules/@maplibre/maplibre-react-native/javascript/utils/geoUtils.ts(1,25): error TS7016: Could not find a declaration file for module '@mapbox/geo-viewport'. '/Users/name/Documents/xxx/xx/mobile-app/node_modules/@mapbox/geo-viewport/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/mapbox__geo-viewport if it exists or add a new declaration (.d.ts) file containing declare module '@mapbox/geo-viewport';

@veno501 how did you manage to suppress these?

I declared these myself, see https://github.com/maplibre/maplibre-react-native/issues/422#issuecomment-2230642658