Skip to content

Conversation

@mxxk
Copy link
Contributor

@mxxk mxxk commented Jul 30, 2025

Also, add ESLint rules to flag these automatically moving forward.


Since this package is declared as an ES module,

"type": "module",

when structured-headers is consumed as a dependency, TypeScript expects imports (including those in .d.ts files) to have the .js extension:

node_modules/structured-headers/dist/types.d.ts:1:23 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './token.js'?

1 import { Token } from './token';
                        ~~~~~~~~~

node_modules/structured-headers/dist/types.d.ts:2:31 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './displaystring.js'?

2 import { DisplayString } from './displaystring';
                                ~~~~~~~~~~~~~~~~~

node_modules/structured-headers/dist/util.d.ts:1:33 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './types.js'?

1 import { Item, InnerList } from './types';
                                  ~~~~~~~~~

The .js extension is inserted automatically in emitted .js files, but not in emitted .d.ts files.

Most imports already have a .js extension, for example,

so this PR is making the remaining imports consistent.


See: microsoft/TypeScript#50482.

Also, add ESLint rules to flag these automatically moving forward.
@evert evert enabled auto-merge July 30, 2025 14:20
Copy link
Collaborator

@evert evert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Great PR + appreciate the linting changes

@evert evert merged commit 3c6c9f2 into badgateway:main Jul 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants