json-schema-to-ts
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "json-schema-to-ts", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Infer typescript types from your JSON schemas!", | ||
@@ -5,0 +5,0 @@ "main": "src/index.ts", |
@@ -90,6 +90,8 @@ # Stop typing twice 🙅♂️ | ||
- 📝 Reduce redundancy: Writing less code is always nice! | ||
- 🤝 Enforce consistency: Spot typos, or a string which should be an enum... | ||
- 🤝 Enforce consistency: Spot typos, string instead of enum or confusing additionalItems and additionalProperties... | ||
- ⚡️ Be right first-time: With instantaneous feedback given by TS ! | ||
- Types are easier to read than shemas. Help you write better schemas | ||
Helps you write complex schemas ! | ||
For instance, is it obvious that the following schema can never be validated ? | ||
@@ -96,0 +98,0 @@ |
@@ -1,11 +0,9 @@ | ||
import { Get, GetRec } from "../utils"; | ||
import { Get } from "../utils"; | ||
import { Never } from "./never"; | ||
export type EnumType = "enum"; | ||
export type Enum<V> = V extends [] ? Never : { type: "enum"; values: V }; | ||
export type Enum<V> = { type: "enum"; values: V }; | ||
export type Values<E> = Get<E, "values">; | ||
export type ResolveEnum<T> = GetRec<T, ["values", number]>; | ||
export type ResolveEnum<T> = Values<T>; |
@@ -1,2 +0,2 @@ | ||
import { Get, Head, Tail, Prepend, Reverse } from "../../utils"; | ||
import { Get } from "../../utils"; | ||
@@ -26,9 +26,6 @@ import { MetaType, Never, Const, Error } from ".."; | ||
type RecurseOnEnumValues<V, B, R extends any[] = []> = { | ||
continue: RecurseOnEnumValues< | ||
Tail<V>, | ||
B, | ||
Intersect<Const<Head<V>>, B> extends Never ? R : Prepend<Head<V>, R> | ||
>; | ||
stop: Reverse<R>; | ||
}[V extends [any, ...any[]] ? "continue" : "stop"]; | ||
type RecurseOnEnumValues<V, B> = V extends infer T | ||
? Intersect<Const<T>, B> extends Never | ||
? never | ||
: T | ||
: never; |
import { Enum, Intersection } from "../meta-types"; | ||
import { Get, HasKeyIn } from "../utils"; | ||
import { GetRec, HasKeyIn } from "../utils"; | ||
@@ -7,3 +7,6 @@ import { ParseSchema } from "."; | ||
export type ParseEnumSchema<S> = HasKeyIn<S, "const" | "type"> extends true | ||
? Intersection<Enum<Get<S, "enum">>, ParseSchema<Omit<S, "enum">>> | ||
: Enum<Get<S, "enum">>; | ||
? Intersection< | ||
Enum<GetRec<S, ["enum", number]>>, | ||
ParseSchema<Omit<S, "enum">> | ||
> | ||
: Enum<GetRec<S, ["enum", number]>>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
404
45209
1139