question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript import won't work

See original GitHub issue

None 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:64 (23 by maintainers)

github_iconTop GitHub Comments

8reactions
crutchcorncommented, Sep 20, 2019

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 and const Jimp = require('jimp') will not work as-expected. Please update to using import Jimp from 'jimp'

4reactions
crutchcorncommented, Sep 8, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import statement does not work in typescript - Stack Overflow
Then I'm trying to import a class in a file using 'import' keyword. But despite having read about the declaration of modules in...
Read more >
Imports not working in TypeScript project. · Issue #199 - GitHub
When I am trying to import any of the Props into a TypeScript project, import sizes from "open-props/src/sizes" I get a ts(2307) Error:...
Read more >
Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports​​ The compiler will then substitute 'view/file2' with the first location in the array ( "*"...
Read more >
isolatedModules - TSConfig Option - TypeScript
Some examples of code which does not work when isolatedModules is enabled. ... In TypeScript, you can import a type and then subsequently...
Read more >
TypeScript Quick Fix "import reference..." does not work with ...
does not work with external modules. 1. With TypeScript internal modules ReSharper prompts to "Import reference X.Y.Z and all other types in file?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found