Skip to content

[BUG] [typescript] not compatible with --isolatedModules #6805

@bard

Description

@bard

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Using the new TypeScript generator from #6341

The generated code is not compatible with --isolatedModules, which is required by popular setups such as create-react-app.

openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://github.com/bard/repro-openapi-generator-typescript-isolated-modules/blob/master/example.yaml

Command line used for generation

OPENAPI_GENERATOR_VERSION=5.0.0-SNAPSHOT /tmp/openapi-generator-cli.sh generate -g typescript -i example.yaml -o ./src/api

Steps to reproduce
  1. git clone https://github.com/bard/repro-openapi-generator-typescript-isolated-modules/blob/master/example.yaml
  2. OPENAPI_GENERATOR_VERSION=5.0.0-SNAPSHOT /tmp/openapi-generator-cli.sh generate -g typescript -i example.yaml -o ./src/api
  3. yarn && yarn start
Failed to compile.

/tmp/repro-openapi-generator-typescript-isolated-modules/src/api/index.ts
TypeScript error in /tmp/repro-openapi-generator-typescript-isolated-modules/src/api/index.ts(4,31):
Cannot re-export a type when the '--isolatedModules' flag is provided.  TS1205

    2 | export * from "./auth/auth";
    3 | export * from "./models/all";
  > 4 | export { createConfiguration, Configuration } from "./configuration"
      |                               ^
    5 | export * from "./apis/exception";
    6 | export * from "./servers";
    7 | 
Related issues/PRs

facebook/create-react-app#6054

Suggest a fix

Possible workaround is to export * from index.ts:

  export * from "./http/http";
  export * from "./auth/auth";
  export * from "./models/all";
- export { createConfiguration, Configuration } from "./configuration"
+ export * from "./configuration"
  export * from "./apis/exception";
  export * from "./servers";

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions