OpenAPITools / OpenAPITools/openapi-generator
[REQ] Ability to configure target javascript version for typescript compiler in typescript generators
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
When porting the typescript-angular client generator to angular 13, I wanted to update the versions in the the generated tsconfig.json.
The file is currently hardcoded to es6 or es5 depending on a 'supportES6' common to all typescript clients.
It is used to generate the tsconfig. The following snippet has been copy/pasted to most generator templates:
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}",
{{^supportsES6}}
"lib": [
"es6",
"dom"
],
{{/supportsES6}}
And in some template, a corejs dependency is added for non-es6 targets.
Concerning the target javascript platform:
- Each generators may support a subset of javascript target platforms
- An end-user may want to specify a target platform, and take care of providing polyfills
Concerning the module configuration:
- An end user may want to overrides the gerenated module format depending on how the module is impored
Concerning the addition of a core-js dependency:
- This is polyfill library, to provide runtime librairies to the javascript platform, and should not be required for typescript compilation.
- It is not imported in the generated
typescript-aureliasample client, so the dependency sees unneeded.
Concerning the lib to include in typescript compilation:
- This should be derived from the target platform. eg when targeting es2017 libs up to es2017 should be provided to the compiler.
- By default, typescript includes the librairies of the
targetspecified, so this option could probably be ignored.
Describe the solution you'd like
A more future-proof way to configure and handle javascript targets.
Im not sure Ive considered all options so this issue is more to sparkle discussion and query a consensus.
In my opinion we should be left with
- each generator defaulting a
target andmodule` in their tsconfig.json - no generator specifying additional
libunless required - one
tsModuleoption for the enduser to override - one
tsTargetoption for the enduser to override.
Describe alternatives you've considered
Adding a supportsES2020 config flag
Additional context
https://github.com/OpenAPITools/openapi-generator/pull/10877
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 reviewing the TypeScript generator templates and the linked pull request #10877, focusing on how generated tsconfig.json files use supportsES6, target, module, lib, and core-js. Done means reaching consensus on the configuration options and defaults, then applying and validating that approach across the affected TypeScript generators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100