question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Typescript errors with OpenLayers 6.6.1

See original GitHub issue

We upgraded OpenLayers from 6.5.0 to version 6.6.1 in our Angular 11 project (and removed the @types/ol dependency). Various compile errors occure in the OpenLayers *.d.ts files:

Error: node_modules/ol/ImageBase.d.ts:32:48 - error TS2694: Namespace '"./node_modules/ol/ImageState"' has no exported member 'default'.

32     protected state: import("./ImageState.js").default;
                                                  ~~~~~~~


Error: node_modules/ol/Tile.d.ts:131:47 - error TS2694: Namespace '"./node_modules/ol/TileState"' has no exported member 'default'.

131     protected state: import("./TileState.js").default;
                                                  ~~~~~~~


Error: node_modules/ol/geom/SimpleGeometry.d.ts:27:53 - error TS2694: Namespace '"./node_modules/ol/geom/GeometryLayout"' has no exported member 'default'.

27     protected layout: import("./GeometryLayout.js").default;
                                                       ~~~~~~~


Error: node_modules/ol/source/Cluster.d.ts:110:31 - error TS2314: Generic type 'Feature<Geometry>' requires 1 type argument(s).

110     protected features: Array<Feature>;
                                  ~~~~~~~


Error: node_modules/ol/source/Cluster.d.ts:121:23 - error TS2314: Generic type 'VectorSource<Geometry>' requires 1 type argument(s).

121     protected source: VectorSource;
                          ~~~~~~~~~~~~


Error: node_modules/ol/source/Raster.d.ts:309:5 - error TS2416: Property 'getImageInternal' in type 'RasterSource' is not assignable to the same property in base type 'ImageSource'.
  Type '() => null' is not assignable to type '(extent: number[], resolution: number, pixelRatio: number, projection: Projection) => ImageBase'.
    Type 'null' is not assignable to type 'ImageBase'.

309     getImageInternal(): null;
        ~~~~~~~~~~~~~~~~

I think the last one is already mentioned in #12532

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
alexandrubuhocicommented, Jan 25, 2022

@ahocevar I’ve cloned the repo locally in my PC, served the app and everything goes well! I think that in my project the reason that Angular shows that errors is because (maybe) the version of Angular is 10.0.8 and the OL version is the latest one.

If i use the OL version 6.5.0 (older) in the same project no errors show up! For deploying the only solution until now is to use the 6.5.0 versione, otherwise I can’t do anything

3reactions
CarlosBayarricommented, Jan 19, 2022

The flag “skipLibCheck”: true in tsconfig is not a solution, it is a bad practice and it shoul be fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix Typescript errors in OpenLayers 6.6.1
After upgrading to OpenLayers 6.6. 1 I am receiving hundreds of typescript errors caused by generics. Generic type 'Feature' requires 1 type ...
Read more >
rlayers examples - React Components for OpenLayers 6+
rlayers is an opinionated set of React components for OpenLayers. It's design policy is: Fully Typescript-typed; Do everything that faces the user the...
Read more >
Regular Shapes - OpenLayers
This example shows how several regular shapes or symbols (representing x , cross , star , triangle , square and stacked ) can...
Read more >
Chapter 6 Leaflet | Introduction to Web Mapping
Using Leaflet, you can create a simple map using just two or three JavaScript expressions, or you can build a complex map using...
Read more >
An Open Source Spatial Data Infrastructure for the Cryosphere
spatial database management system (DBMS), map and web server, JavaScript ... Open source software including GeoServer, PostgreSQL, PostGIS, OpenLayers,.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found