Generated project fails to build in create-react-app project
See original GitHub issueExperienced 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:
- Created 3 years ago
- Comments:13 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
Thanks for testing. Just pushed 0.5.0 to NPM, closing this ticket.