-
Notifications
You must be signed in to change notification settings - Fork 685
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
feat: add programmatic API for types #6861
base: main
Are you sure you want to change the base?
Conversation
|
outFile?: string; | ||
persistToFilesystem?: boolean; | ||
}): Promise<string> { | ||
return generateTypes(getProjectTypes, options); |
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.
Where does getProjectTypes come from?
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 is not yet implemented. It would be an abstraction that isolates some of the logic already existing inside the type generation code. Basically just gets a string of the Env types.
(I don't know if "Project" is the right word here. Could also go with "Env" or something else).
getRuntimeTypes({ | ||
compatibilityDate: config.compatibility_date, | ||
compatibilityFlags: config.compatibility_flags.filter( | ||
(flag) => !flag.includes("nodejs_compat") |
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.
Better to be explicit here, checking against nodejs_compat
and nodejs_compat_v2
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.
Good call.
if (!config && !configFile) { | ||
throw new Error("Either config or configFile must be provided"); | ||
} | ||
if (config && configFile) { | ||
throw new Error("Only one of config or configFile should be provided"); | ||
} | ||
if (outFile && persistToFilesystem === undefined) { | ||
throw new Error( | ||
"persistToFilesystem must be specified when outFile is provided" | ||
); | ||
} |
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 combo have validation can be accomplished with union types
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.
Or overloads perhaps.
What this PR solves / how to test
Fixes #000.
Adds a programmatic API for type generation.
Author has addressed the following