-
-
Notifications
You must be signed in to change notification settings - Fork 350
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: remove unnecessary empty item in case of null-only enum or empty enum (#1022) #1023
Conversation
e729259
to
b9199b2
Compare
) | ||
.filter(Boolean) | ||
.join(`' | '`)}'`; | ||
.join(` | `)}`; |
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.
To avoid that null
is quoted like 'null'
) | ||
.filter(Boolean) | ||
.join(`' | '`)}'`; | ||
.join(` | `)}`; |
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.
This code can not handle array enum, or object enum.
output is like
export const ObjectEnum = {
'[object_Object]': [object Object],
} as const;
I didn't fix because not relevant the issue, but should I leave FIXME
comment?
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.
up to you if you want to leave a FIXME but not necessary?
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.
@melloware thanks for your review, and sorry for late reply.
I don't think necessary while someone report an issue.
@@ -64,13 +64,6 @@ export default defineConfig({ | |||
target: '../generated/default/null-type-v3-0/endpoints.ts', | |||
}, | |||
}, | |||
'nullable-enum': { |
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.
I migrated cases in nullable-enum
to null-type-v3-0
@@ -1,66 +0,0 @@ | |||
openapi: 3.0.0 |
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.
migrated to null-type-v3-0.yaml
Before export type NullOnlyNumberEnum = typeof NullOnlyStringEnum[keyof typeof NullOnlyStringEnum] | null;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NullOnlyStringEnum = {
'': ,
} as const;
export type NullOnlyStringEnum = typeof NullOnlyStringEnum[keyof typeof NullOnlyStringEnum] | null;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NullOnlyStringEnum = {
'': '',
} as const;
export type EmptyEnum = typeof EmptyEnum[keyof typeof EmptyEnum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EmptyEnum = {
'': '',
} as const; After export type NullOnlyNumberEnum = typeof NullOnlyStringEnum[keyof typeof NullOnlyStringEnum] | null;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NullOnlyStringEnum = {
} as const;
export type NullOnlyStringEnum = typeof NullOnlyStringEnum[keyof typeof NullOnlyStringEnum] | null;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NullOnlyStringEnum = {
} as const;
export type EmptyEnum = typeof EmptyEnum[keyof typeof EmptyEnum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EmptyEnum = {
} as const; |
Ideally, it is desirable that like this code is generated
, but I think program will get too complex considering combine schema. Because this is never
, so meaning is the same. |
Status
READY
Description
Remove unnecessary empty item in case of null-only enum or empty enum.
Close #1022
Related PRs
The issue in case of empty enum may exist before.
The issue in case of null-only enum is occured by this PR.
Because null is filtered, null-only enum is handled as empty enum.
Todos
Steps to Test or Reproduce
Added specification and confirmed generated type files.