OpenAPITools / OpenAPITools/openapi-generator

[REQ] [typescript] exported namespace in Typescript conflicts with ESlint

Open
#21,576 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

By default, the models that get exported contain a namespace.

interface SomeModel { ... }
export namespace SomeModel {} // here

Is this by design?

ESLint has a no-namespace rule. That suggests that many TypeScript projects have no use for the exported namespace and thus fail to compile.

So, what is the reason to export it?

Was it perhaps initially for Angular 1 projects and environments that use AMD/CommonJS modules?

Possible feature

It could be removed from the default mustache file and thus the export. This would mean a backward incompatible API change for this openapi-generator library. And therefore a major upgrade version probably.

Another option would be to add it in the additional-properties, like:

npx openapi-generator-cli generate  -g typescript-angular --global-property models,supportingFiles additional-properties= noNamespaces=false

This is an addition and would not require a major version update of this project.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typescript-angular generator and its default Mustache model template to trace where the exported namespace is produced. Check how additional-properties are declared and how generator output is tested. Done means the default namespace behavior and an optional noNamespaces setting are defined consistently, with regression coverage for generated TypeScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.