-
Notifications
You must be signed in to change notification settings - Fork 65
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
Adds support for use of enum types as literals and nativeEnums #40
Conversation
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.
Looks good, let's just add a little unit test to make sure everything works as expected
Codecov Report
@@ Coverage Diff @@
## main #40 +/- ##
==========================================
- Coverage 98.49% 98.10% -0.40%
==========================================
Files 8 9 +1
Lines 332 369 +37
Branches 102 113 +11
==========================================
+ Hits 327 362 +35
- Misses 5 6 +1
- Partials 0 1 +1
Continue to review full report at Codecov.
|
I think I addressed all the feedback, thanks again for taking a look @fabien0102 🙇 |
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.
Looks good, nice job! I will publish a new release just after 😀
…40) * Checks in test documenting behavior * Implements enum import & declartion * Updates example to include enum * Updates tests to document expected case * Add handler for enum literals * Updates example * Addresses #38 (comment) * Addresses #38 (comment) * Addresses #40 (comment)
I wonder whether the following is a bug: export enum LoggerLevel { debug, info, warning, error, critical }
interface ILogger {
/**
* @default LoggerLevel.info
*/
level: LoggerLevel
} compiles down to export const loggerLevelSchema = z.nativeEnum(LoggerLevel);
const iLoggerSchema = z.object({
level: loggerLevelSchema.default("LoggerLevel.info"), //// <----- notice enum default is quoted
}); TIA |
This looks like a bug, we didn’t think about this edge case. Good catch! |
Why
Fixes #39 and #35
Warnings⚠️
Relies on Adds support for native Typescript enums #38Rolled these together b/c Adds support for native Typescript enums #38 was a subset of this PR