Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 of 6 tasks
bard opened this issue Jun 29, 2020 · 6 comments
Open
5 of 6 tasks

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

bard opened this issue Jun 29, 2020 · 6 comments

Comments

@bard
Copy link

bard commented Jun 29, 2020

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";
@auto-labeler
Copy link

auto-labeler bot commented Jun 29, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@rsp
Copy link

rsp commented Jul 10, 2023

It's been over two years since this bug is open. Are there any plans to fix it?

A temporary workaround for anyone who is waiting for the fix:

Hopefully it won't be needed soon but meanwhile this can be used to fix the code automatically.

@Drago92
Copy link

Drago92 commented Sep 16, 2024

Now the Issue has been fixed and the configuration Type has the right export:

export * from "./http/http";
export * from "./auth/auth";
export * from "./models/all";
export { createConfiguration } from "./configuration"
export type { Configuration } from "./configuration"
export * from "./apis/exception";
export * from "./servers";
export { RequiredError } from "./apis/baseapi";

export { PromiseMiddleware as Middleware } from './middleware';

But in the same file the PromiseMiddleware Type has the wrong export:
image

@wing328
Copy link
Member

wing328 commented Sep 16, 2024

export { PromiseMiddleware as Middleware } from './middleware';

I wonder if you can file a PR to fix it 🙏

@Drago92
Copy link

Drago92 commented Sep 18, 2024

export { PromiseMiddleware as Middleware } from './middleware';

I wonder if you can file a PR to fix it 🙏

Okay a PR is not necessary. I took a look at the code and i saw that the export type will be set when the addditional property platform=deno is set. For example:
openapi-generator generate -g typescript -i ./schema.yaml -o ./Client --additional-properties=platform=deno

Output-File:
image

@Drago92
Copy link

Drago92 commented Sep 18, 2024

export { PromiseMiddleware as Middleware } from './middleware';

I wonder if you can file a PR to fix it 🙏

Okay a PR is not necessary. I took a look at the code and i saw that the export type will be set when the addditional property platform=deno is set. For example: openapi-generator generate -g typescript -i ./schema.yaml -o ./Client --additional-properties=platform=deno

Output-File: image

Nevermind. The deno Version is not compatible with node. I will create a PR

Drago92 pushed a commit to Drago92/openapi-generator that referenced this issue Sep 18, 2024
joscha added a commit to joscha/openapi-generator that referenced this issue Sep 30, 2024
macjohnny pushed a commit that referenced this issue Sep 30, 2024
* Fix export type for typescript interfaces in all platforms (#6805)

* Generated samples and docs

* chore: update samples

---------

Co-authored-by: Kevin Broja <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants