-
Notifications
You must be signed in to change notification settings - Fork 92
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
TypeScript error: Type is too long to infer, needs explicit type annotation. #308
Comments
We are also running in to this issue. Tried the above but we also get the errors in the Our only workaround I think right now is to group the endpoints. Any other guidance would be appreciated. |
You can just replace the variable apiClient with
|
not for us, it just shifts the same error to the |
Same for us, will this be possible to fix without splitting up APIs or is it a limitation of TypeScript itself? |
Read before opening
Describe the bug
When generating the client from a large OpenAPI schema, such as the one at LCU OpenAPI schema, the following TypeScript error is encountered:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
The error seems to occur due to the size and complexity of the generated schema and type inference limits in TypeScript.
Minimal reproduction
Expected behavior
I expect the generated code to either handle larger schemas gracefully or suggest adding explicit type annotations to avoid the TypeScript inference error. The code should look like the example provided, which avoids importing large objects directly and instead exports each schema individually.
Additional context
Suggested improvement
Instead of importing large schemas as a whole (schemas = {...all_schemas}), export individual schemas to avoid the same issue with TypeScript’s type inference limits.
Schematic example of the suggested code change:
The text was updated successfully, but these errors were encountered: