-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
fix(typescript-axios): add useErasableSyntax support for erasableSyntaxOnly compatibility #23247
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
base: master
Are you sure you want to change the base?
Changes from all commits
ea60e70
0417ca0
0acb15c
30f7c22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,20 +25,45 @@ export interface RequestArgs { | |
|
|
||
| export class BaseAPI { | ||
| protected configuration: Configuration | undefined; | ||
| {{^useErasableSyntax}} | ||
|
|
||
| constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { | ||
| if (configuration) { | ||
| this.configuration = configuration; | ||
| this.basePath = configuration.basePath ?? basePath; | ||
| } | ||
| } | ||
| {{/useErasableSyntax}} | ||
| {{#useErasableSyntax}} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code would also be compatible with the that would also mean we dont need the additional CLI option, right? you can also add a comment here in the mustache template to let future editors know the code should be compatible to the erasable syntax, wdyt? |
||
| protected basePath: string; | ||
| protected axios: AxiosInstance; | ||
|
|
||
| constructor(configuration?: Configuration, basePath: string = BASE_PATH, axios: AxiosInstance = globalAxios) { | ||
| this.basePath = basePath; | ||
| this.axios = axios; | ||
| if (configuration) { | ||
| this.configuration = configuration; | ||
| this.basePath = configuration.basePath ?? basePath; | ||
| } | ||
| } | ||
| {{/useErasableSyntax}} | ||
| }; | ||
|
|
||
| export class RequiredError extends Error { | ||
| {{^useErasableSyntax}} | ||
| constructor(public field: string, msg?: string) { | ||
| super(msg); | ||
| this.name = "RequiredError" | ||
| } | ||
| {{/useErasableSyntax}} | ||
| {{#useErasableSyntax}} | ||
| public field: string; | ||
| constructor(field: string, msg?: string) { | ||
| super(msg); | ||
| this.name = "RequiredError" | ||
| this.field = field; | ||
| } | ||
| {{/useErasableSyntax}} | ||
| } | ||
|
|
||
| interface ServerMap { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2:
useErasableSyntaxis not reconciled withstringEnums, allowing generation ofexport enumdespite claiming erasable-syntax compatibility.Prompt for AI agents
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 0acb15c — added a runtime warning when both
useErasableSyntaxandstringEnumsare enabled. The warning explains thatenumdeclarations are not erasable syntax and recommends disablingstringEnums(the default generates erasable-compatibleas constobjects).chose a warning over a hard error to avoid breaking existing configs — users may have valid reasons to enable both (e.g. migrating incrementally).