georaster icon indicating copy to clipboard operation
georaster copied to clipboard

Add Typescript definitions

Open twelch opened this issue 4 years ago • 5 comments

Goal - add Typescript definitions.

Details:

  • [x] Covers the public API for the top-level module only including the parseGeoraster() method and the Georaster` object it returns.
  • [x] Ensure both default and named exports work
  • [x] Adds a build step to copy to declaration file from src to dist folder.

Testing:

  • [x] Confirm works with the downstream geoblaze type declaration (https://github.com/GeoTIFF/geoblaze/pull/183). Test with npm linked geoblaze and downstream user project.

twelch avatar Jun 27 '21 22:06 twelch

Hey. I saw this nifty line in https://github.com/geotiffjs/geotiff.js/pull/253/files: npx [email protected] -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?

DanielJDufour avatar Oct 08 '21 01:10 DanielJDufour

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 avatar Mar 01 '23 14:03 jeafreezy

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

jeafreezy avatar Mar 01 '23 14:03 jeafreezy

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.

DanielJDufour avatar Mar 01 '23 14:03 DanielJDufour

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

jeafreezy avatar Mar 01 '23 16:03 jeafreezy