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 types are clashing with nodenext TypeScript module resolution

See original GitHub issue

TypeScript 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:closed
  • Created a year ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
EvanHahncommented, Jul 23, 2022

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.

0reactions
Pauline-shcommented, Jul 22, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

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