-
Notifications
You must be signed in to change notification settings - Fork 1
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
add MachineEvent.Factory.parse() method #91
Conversation
machine-runner/package.json
Outdated
@@ -68,7 +68,8 @@ | |||
"fast-equals": "^5.0.1", | |||
"ts-node": "^10.9.1", | |||
"typed-emitter": "^2.1.0", | |||
"typescript": "^4.9.5" | |||
"typescript": "^4.9.5", | |||
"zod-validation-error": "^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.
ah, moving to optional
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.
you cannot set a dependency to optional AND import
it. (import type is a different case)
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.
Then what is the purpose of optional: true
? And what is the pattern for only optionally using a dependency?
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.
In TypeScript it can be used with import type
In CJS Node code, including packages use require
. with require you can do:
// optionally use some module
try {
const module = require("somemodule")
module.someFunction();
} catch (err) {}
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
const ZOD = { | ||
zod: (await import('zod').catch( |
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.
TIL await import
can be used to export synchronously. Nice trick
@@ -31,11 +32,70 @@ export type MachineEvent<Key extends string, Payload extends object> = { | |||
type: Key | |||
} & Payload | |||
|
|||
type Zod = { |
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.
These should be moved to zod.ts
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.
Since there are two zod.ts
there would be the danger of divergence.
No description provided.