GeoTIFF / georaster

Wrapper around Georeferenced Rasters like GeoTIFF and soon JPG and PNG that provides a standard interface
Apache License 2.0
81 stars 32 forks source link

Add Typescript definitions #59

Open twelch opened 3 years ago

twelch commented 3 years ago

Goal - add Typescript definitions.

Details:

Testing:

DanielJDufour commented 2 years ago

Hey. I saw this nifty line in https://github.com/geotiffjs/geotiff.js/pull/253/files: npx --package=typescript@4.4.3 -y -- tsc --outdir dist-node/. I haven't seen something like this before, but I'm wondering, could we change "test-types": "tsc test/types.ts --noEmit" to "test-types": "npx --package=typescript -y -- tsc test/types.ts --noEmit" and thus avoid adding typescript as a dependency?

jeafreezy commented 1 year ago

Hi @DanielJDufour , thank you for this great library.

I am experiencing an issue with using this library with typescript, as it is a requirement for georaster for leaflet.

Error: Could not find a declaration file for module 'georaster'.

I would appreciate any solution to this. Thanks!

jeafreezy commented 1 year ago

Got rid of the error by creating a new file georaster.d.ts with the following content: declare module 'georaster';

DanielJDufour commented 1 year ago

Hi, @jeafreezy . Great to hear you are making use of GeoRasterLayer. I think you might be able to solve your problems by creating a declarations.d.ts file and adding a line that says declare module "georaster";. In general you could put the declarations.d.ts file inside of a types folder inside of src. In any case, that is what we do with georaster-layer-for-leaflet for our other non-typescript dependencies. (see https://github.com/GeoTIFF/georaster-layer-for-leaflet/blob/master/src/types/declarations.d.ts). You might also need to set "typeRoots": ["types"] in the tsconfig.json file per https://github.com/GeoTIFF/georaster-layer-for-leaflet/blob/master/tsconfig.json.

I also wanted to apologize for taking so long with reviewing this PR. I want to say that adding types is definitely a priority for me. Unfortunately, I find myself trying to push a new major georaster upgrade across the goal line (improved accuracy and support for .asc, .jpg, .png, .prj, .wld). As soon as I'm done with that, I promise types will get more attention. Basically, I'm afraid if I lose focus on the new major georaster upgrade, it will be another several years till it happens. I hope that makes sense. And I really am sorry for the inconvenience and frustration this causes.

jeafreezy commented 1 year ago

Hi @DanielJDufour , thank you for the hint! It worked very well. Wish you the best in pushing the major upgrade!