I have a problem compiling a library in angular. The error appears when I run the ng build command
ERROR: node_modules/ol/MapBrowserEvent.d.ts(47,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/MapBrowserEvent.d.ts(53,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/MapBrowserEvent.d.ts(54,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/MapBrowserEvent.d.ts(61,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/View.d.ts(582,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/View.d.ts(592,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ol/Map.d.ts(404,22): error TS2304: Cannot find name 'ResizeObserver'.
node_modules/ol/webgl/Buffer.d.ts(13,14): error TS2303: Circular definition of import alias 'STATIC_DRAW'.
node_modules/ol/webgl/Buffer.d.ts(14,14): error TS2303: Circular definition of import alias 'STREAM_DRAW'.
node_modules/ol/webgl/Buffer.d.ts(15,14): error TS2303: Circular definition of import alias 'DYNAMIC_DRAW'.
node_modules/ol/webgl/Helper.d.ts(36,14): error TS2303: Circular definition of import alias 'UNSIGNED_BYTE'.
node_modules/ol/webgl/Helper.d.ts(37,14): error TS2303: Circular definition of import alias 'UNSIGNED_SHORT'.
node_modules/ol/webgl/Helper.d.ts(38,14): error TS2303: Circular definition of import alias 'UNSIGNED_INT'.
node_modules/ol/webgl/Helper.d.ts(39,14): error TS2303: Circular definition of import alias 'FLOAT'.
node_modules/@types/geojson/index.d.ts(79,13): error TS2456: Type alias 'Geometry' circularly references itself.
node_modules/ol/Geolocation.d.ts(9,24): error TS2304: Cannot find name 'GeolocationPositionError'.
node_modules/ol/format/EsriJSON.d.ts(2,38): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(3,41): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(4,39): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(5,36): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(6,39): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(7,38): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(8,41): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(9,36): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(10,39): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(11,51): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/EsriJSON.d.ts(28,31): error TS2307: Cannot find module 'arcgis-rest-api'.
node_modules/ol/format/TopoJSON.d.ts(2,39): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(3,49): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(4,39): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(5,36): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(6,41): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(7,41): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(8,46): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(9,38): error TS2307: Cannot find module 'topojson-specification'.
node_modules/ol/format/TopoJSON.d.ts(10,43): error TS2307: Cannot find module 'topojson-specification'.
node_modules/geotiff/dist-node/source/basesource.d.ts(22,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/geotiff/dist-node/dataslice.d.ts(7,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/geotiff/dist-node/dataslice.d.ts(8,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/geotiff/dist-node/dataslice.d.ts(9,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/geotiff/dist-node/dataslice.d.ts(10,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/geotiff/dist-node/dataslice.d.ts(11,9): error TS1086: An accessor cannot be declared in an ambient context.
If you add skipLibCheck: true to tsconfig, the error will disappear
BUT
Openlayers is a single package dependency. This package is supplied with the rest of the libraries. (Let's assume a total of 30 packages.)
And this error appears where openlayers is installed as a dependency of another package.
Is it possible to avoid setting skipLibCheck: true
in the other 30 packages
arcgis-rest-api topojson-specification
typesThis does not solve the problem, as there are a lot of errors in the d.ts openlayers d.ts files themselves
The problem is several d.ts files that openalyers generates. I believe that in general the error lies between versions of TypeScript (Angular 8 = 3.5.3, Openlayers 7 = 5.0) due to incompatibility of ts version, d.ts with errors for ts 3.5.3 are generated
I made a fork of openalyers 7, wrote a cli script that inserts ts-ignore comments in all entities, in all d.ts files. After building ol
I apply my script and make a release.
Then I replaced in the libraries that distribute the ol
dependency with my fork.
Bottom line: all my libraries are now built without d.ts errors. (I have not lost any typing)