Transform paths doesn't work with import require statements
See original GitHub issueI tried out this plugin and it works great for normal es6 import statements with default or named exports. Unfortunately it doesn’t work on files with the legacy commonJS export shape.
A workaround is to change the import to es6 and use something like the esModuleInterop compiler flag. That requires modification of the source code though, and therefore is a heavy handed.
Dependency.ts
export = 3;
Main.ts
import d = require('Dependency');
Expected Main.d.ts
import d = require('./Dependency');
Actual
No transform was performed
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How to transform require into import statement for third party ...
Tim answer is perfect, the error is because for importing something typescript need its type definitions (property "typings" in target ...
Read more >The plugin works only when "paths" exists in tsconfig, why? #39
My IMHO is following: it's a little strange to require "paths" to be present in tsconfig.json. I think in an ideal world, the...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >How Pros Get Rid of Relative Imports - DEV Community
The easiest way to get rid of the long imports is to add baseUrl in the jsconfig.json (add jsconfig.json at the root level...
Read more >Webstorm not resolving module imports using typescript paths
Hello there! I am using Webstorm 2019.3.4 I found it very problematic to configure "paths" option so that IDE does not show me......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@richardspence, a fix is up, upgrade to v1.1.8
@richardspence, a fix is up in v1.1.7, please upgrade