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

Fix: When generated TS class name is "Error", it is conflicting with TS Error class #5032

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

doruk-info
Copy link

@doruk-info doruk-info commented Nov 20, 2024

Where one of the generated class name is "Error" it cause confusion to throw new Error(...) operations and causing the build to fail.

Following is example build failure message:

ERROR in ./src/api/index.ts:3008:29
TS2559: Type '"The parameter 'foo' must be defined."' has no properties in common with type 'IError'.
    3006 |         let url_ = this.baseUrl + "/foo";
    3007 |         if (foo === undefined || foo === null)
  > 3008 |             throw new Error("The parameter 'foo' must be defined.");
         |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is because generated class "Error" accepts IError generated interface in ctor.

To resolve this issue we can use globalThis.Error when generating request bodies.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant