question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated project fails to build in create-react-app project

See original GitHub issue

Experienced behavior

I generated types definitions with CLI openapi --input ./api_spec.yaml --output ./openapi, but it fails to compile in unejected react app created with create-react-app CLI.

There are 2 problems:

Compilation error due to :

C:/xxx/openapi/index.ts
TypeScript error in C:/xxx/openapi/index.ts(10,10):
Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.  TS1205
Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'

     8 | export { OpenAPI } from './core/OpenAPI';
     9 |
  > 10 | export { MyModel } from './models/MyModel';

After commenting out reexported modules I encountered second problem:

Failed to compile.

./openapi/core/ApiError.ts
SyntaxError: C:\xxx\openapi\core\ApiError.ts: Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel. To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
  24 | }
  25 |
> 26 | export namespace ApiError {
     |                  ^^^^^^^^
  27 |     export enum Message {
  28 |         BAD_REQUEST = 'Bad Request',
  29 |         UNAUTHORIZED = 'Unauthorized',

Expected behavior

Generated code compiles properly without warnings.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ferdikoomencommented, Sep 27, 2020

@jedzej @ilyaulyanov @lcalisi there is a new version 0.5.0-alpha that should resolve this issue, if you have time them please do check. More info on the flag here: https://github.com/ferdikoomen/openapi-typescript-codegen#enums-vs-union-types---useuniontypes and https://github.com/ferdikoomen/openapi-typescript-codegen#babel-support

0reactions
ferdikoomencommented, Oct 3, 2020

Thanks for testing. Just pushed 0.5.0 to NPM, closing this ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npx create-react-app projectName fails to create project
I am creating a react project using npx create-react-app experiment and I have been getting the below error, can anybody help with how...
Read more >
How to fix build failures with `create-react-app` in production
If your build is using create-react-app and has been failing since approximately the 18th of June 2020, this post will help you fix...
Read more >
Production Build Randomly Fails · Issue #1082 - GitHub
Run create-react-app with defaults and you'll have it, but you may have to run build a lot to repro the problem.
Read more >
Create React App
Whether you're using React or another library, Create React App lets you focus on code, not build tools. To create a project called...
Read more >
Create React App without Create React App - Bits and Pieces
Step by Step · 1. Make sure node is installed in your system · 2. Create project folder and package.json · 3. Install...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found