-
Notifications
You must be signed in to change notification settings - Fork 0
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
[WIP] Replace with json-schema-to-ts package #4
base: master
Are you sure you want to change the base?
Conversation
3a3b6f9
to
2d62d92
Compare
cb0bb34
to
902b01c
Compare
42ed0cd
to
c3c92d1
Compare
902b01c
to
bc03b21
Compare
b5fad7c
to
a3d0ea9
Compare
lib/types.ts
Outdated
* | ||
* There is no need to coerce types as Ajv.validate() will do that | ||
* for you. | ||
*/ | ||
export type EnvSchemaParserFn< | ||
S extends BaseEnvSchema, | ||
K extends keyof S['properties'], | ||
V extends BaseEnvParsed<S> = TypeFromJSONSchema<S>, |
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.
here for example, if we always use TypeFromJSONSchema<S>
anyway, we could simply
export type EnvSchemaParserFn<
S extends BaseEnvSchema,
> = (
str: string,
propertySchema: Readonly<S['properties'][KeyOf<S['properties']>]>,
key: KeyOf<S['properties']>,
schema: Readonly<S>,
) => EnvSchemaPropertyValue<S, TypeFromJSONSchema<S>>;
But if you do this on EnvSchemaPropertyValue
, you won't even need to do this
lib/types.ts
Outdated
export type EnvSchemaPropertyValue< | ||
S extends BaseEnvSchema, | ||
K extends keyof S['properties'], | ||
> = K extends keyof TypeFromJSONSchema<S> ? TypeFromJSONSchema<S>[K] : never; | ||
V extends BaseEnvParsed<S>, | ||
> = V[KeyOf<V>]; |
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.
Ultimately, you would simply do
export type EnvSchemaPropertyValue<
S extends BaseEnvSchema,
> = TypeFromJSONSchema<S>[KeyOf<TypeFromJSONSchema<S>>];
If that's possible, or makes sense. Well, if in fact I miss something and there is some case where you don't use the default value =TypeFromJSONSchema<S>
, then this is necessary, but I haven't found
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.
What I'm trying to avoid here is the previous behavior of repeatedly calling TypeFromJSONSchema<>
, processing the same conversion over and over. Which is what made this codebase so slow to work with..
2829f8f
to
e25930f
Compare
1d86412
to
6ec7263
Compare
199ce0d
to
a9f3ffa
Compare
784ca2d
to
b304594
Compare
a9f3ffa
to
f8aa8ae
Compare
b304594
to
c4690dd
Compare
f8aa8ae
to
acef2f8
Compare
c4690dd
to
4a934a2
Compare
26427da
to
fb0f884
Compare
- Remove redundant type recursions - Improve typing readability - Avoid casting Part of #2
fb0f884
to
46da610
Compare
Replace '@profusion/json-schema-to-typescript-definitions' with 'json-schema-to-ts' package
Description
@profusion/json-schema-to-typescript
package withjson-schema-to-ts
Related Issues
Closes #2
Progress
Pull request checklist
How to test it
Visual reference