TypeScript types are clashing with nodenext TypeScript module resolution
See original GitHub issueTypeScript throws Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path.
when using helmet in esm context and module resolution mode node12
or nodenext
.
The package.json specifies
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
}
}
This requires corresponding types for esm, that also use file extensions for imports
Issue Analytics
- State:
- Created a year ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
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 >moduleResolution nodenext or node16 causes type errors ...
In moduleResolution: "node" , TypeScript basically did not acknowledge the existence of Node ESM and assumes you are always downleveling to CJS.
Read more >API - esbuild
API. The API can be accessed in one of three ways: on the command line, in JavaScript, and in Go. The concepts and...
Read more >Typescript module resolution not working - Stack Overflow
When I hover the 'utils/IntHelper' part in my import line in the typescript file VSCode would also show the correct path to that...
Read more >Basic Typescript for Angular: Understanding Modules
This guide gives an understanding of how Typescript modules work and how they are used in Angular. What are these import and export ......
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 FreeTop 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
Top GitHub Comments
This should be fixed in Helmet v5.1.1. Please update and let me know if that fixes things for you.
Sorry I took so long on this! And big thanks to @Pauline-sh for doing all the work.
Yeah, looks like I ran the tests with built
dist
and haven’t noticed this issue 😦I tried to adjust jest-config according to this doc https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ and I think it worked. Will make a PR with this solution