TypeScript import won't work
See original GitHub issueNone of the three methods detailed in the readme worked for me when importing gimp on my TypeScript project when upgrading to jimp@0.8.0
I couldn’t even access the right type so at least I can force a cast to require(‘gimp’). The error I’m seeing in the suggested methods is that the type resolved to never.
I’m using typeScript 3.6.2 , and node 12.8.1. I also tried with all combinations of esModuleInterop
and allowSyntheticDefaultImports
as the readme mention but without luck. I feel competent with TypeScript and I really think you have something wrong with your type declarations. It would be awesome if you could just export the constructor type - in my case I need to cast the Jimp class, as in new Jimp()
. Also, just an opinion, these type declarations are unnecessary complex I think. Any tip is most welcome, thanks. This is my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["esnext", "dom"],
"strict": true,
"esModuleInterop": true,
// "allowSyntheticDefaultImports": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": ".",
"declaration": true
},
"include": ["src", "test"]
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:64 (23 by maintainers)
Top GitHub Comments
This issue should be solved as-of 0.8.4. I’d love to see it closed.
Please keep in mind that, per the updated README,
import * from Jimp
andconst Jimp = require('jimp')
will not work as-expected. Please update to usingimport Jimp from 'jimp'
Working on it more today and I think I have it fixed
That said, I am writing dts-lint tests (the same in DefinitelyTyped) to try to ensure to the best of my abilities it will work