OpenAPITools / OpenAPITools/openapi-generator
Using ECMAScript Modules: How to create imports with explicit file extensions?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
I am generating a client using the openapi-generator.
The problem is that the project I want to use the generated code in requires imports with an explicit file extension (ECMAScript Modules). So, instead of
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
export * from './apis/index';
export * from './models/index';
which will result in
TS2835: Relative import paths need explicit file extensions in ECMAScript imports when --moduleResolution is node16 or nodenext. Did you mean ./models/index.js?
I need the generator to create
/* tslint:disable */
/* eslint-disable */
export * from './runtime.js';
export * from './apis/index.js';
export * from './models/index.js';
Is there a way to configure the generator s.t. this works? I'd like to avoid a fix-imports.ts script here..
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the TypeScript generator templates that produce the shown runtime, API, and model exports, then check the available configuration options for import paths. Generate a client using Node16 or NodeNext module resolution and verify that relative imports use explicit .js extensions without requiring a separate fix-imports.ts script.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100