Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-to-ts

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-to-ts - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"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]>>;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc