GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
284 stars 57 forks source link

Not compatible with angular 8 and below #71

Closed ayerix closed 2 years ago

ayerix commented 2 years ago

The problem is connected with importing and exporting types in corresponding d.ts file of distribution

This line breaks the compilation of angular 8 project: export type { GeoRaster, GeoRasterLayerOptions, PixelValuesToColorFn } from "./types"; because it may not be handled properly with typescript 3.4

There is no way to workaround the problem because this line is not supported by ts itself. So it gives this output on compilation: ERROR in ../node_modules/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.d.ts:3:13 - error TS1005: '=' expected. 3 import type { GeoRasterLayerOptions } from "./types"; ../node_modules/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.d.ts:3:44 - error TS1005: ';' expected. 3 import type { GeoRasterLayerOptions } from "./types"; ../node_modules/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.d.ts:6:1 - error TS1128: Declaration or statement expected. 6 export type { GeoRaster, GeoRasterLayerOptions, PixelValuesToColorFn } from "./types"; ../node_modules/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.d.ts:6:13 - error TS1005: ';' expected. 6 export type { GeoRaster, GeoRasterLayerOptions, PixelValuesToColorFn } from "./types"; ../node_modules/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.d.ts:6:77 - error TS1005: ';' expected. 6 export type { GeoRaster, GeoRasterLayerOptions, PixelValuesToColorFn } from "./types";

It would be not such a big problem to upgrade typescript to 3.8 which handles this OK, but this typescript version is not compatible with angular 8, so it requires all project to be updated to angular 9+ that is not very pleasant.

The problem actual for all past versions of georaster: 1.0.2, 2.0.2 and 3.0.1, they all have this "export type" in the definition

DanielJDufour commented 2 years ago

Are you able to directly import the JavaScript bundle instead of the raw typescript files? So instead of import GeoRasterLayer from 'georaster-layer-for-leaflet'; use import GeoRasterLayer from 'georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.min.js'; ?

ayerix commented 2 years ago

Hm, yep. It gives the error for import GeoRasterLayer from 'georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.js'; (I tried this without luck) but it works for import GeoRasterLayer from 'georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.min.js'; (it is compiled OK) So I think the problem solved