Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10974
Closed
Open
Issue created Nov 27, 2021 by Administrator@rootContributor

[REQ] Ability to configure target javascript version for typescript compiler in typescript generators

Created by: cghislai

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-aurelia sample 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 target specified, 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 and module` in their tsconfig.json
  • no generator specifying additional lib unless required
  • one tsModule option for the enduser to override
  • one tsTarget option 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

Assignee
Assign to
Time tracking