Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get TS support for this package? #39

Open
albertodiazdorado opened this issue Sep 1, 2021 · 5 comments
Open

How to get TS support for this package? #39

albertodiazdorado opened this issue Sep 1, 2021 · 5 comments

Comments

@albertodiazdorado
Copy link

I want to use jimp-compact instead of jimp, but I also want to use the type support provided by @types/jimp. How do I do it?

@pi0
Copy link
Collaborator

pi0 commented Sep 1, 2021

Hi @albertodiazdorado. I didn't try but can you please try adding "jimp": "npm:jimp-compat" to dependencies of package.json as a workaround? It should work by replacing package but importing jimp

@albertodiazdorado
Copy link
Author

Thanks for the answer @pi0 ! Sadly, I have realised that @types/jimp has jimp as a dependency... hence, we are considering dropping the types completely, or switching to jimp.

I will let you know if "jimp": "npm:jimp-compat" works, though :)

@SimenB
Copy link

SimenB commented Sep 20, 2021

jimp ships with types, so that won't work.

Integrating something like https://api-extractor.com/ might be a good idea 🙂

Workaround for us is jimp as a dev dependency, then in a types.d.ts

declare module 'jimp-compact' {
  import jimp = require('jimp');

  export = jimp;
}

@pi0 pi0 closed this as completed in 1821783 Sep 20, 2021
@pi0 pi0 reopened this Sep 20, 2021
@pi0
Copy link
Collaborator

pi0 commented Sep 20, 2021

Version 0.16.1-1 contains a quick fix so as long as you install jimp in devDependencies, types can work for jimp-compact import without the need of alias or ts shim.

image

Integrating something like https://api-extractor.com/ might be a good idea 🙂

Thanks for suggestion. I tried few rollup plugins as well as api-extractor but seems little bit tricky. If interested you can track progress at #42

@SimenB
Copy link

SimenB commented Sep 21, 2021

Cool, can remove our own declare module 'jimp-compact' with that 👍

I'm hoping you can get api-extractor (or something similar) to work so we can also drop the dev dep 😀 (for my use case this is perfectly fine though, as the types are only used for dev, and it's more the require time than yarn install time we wanna improve by using this module)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants