Comparing version 1.1.1 to 1.1.2
@@ -229,2 +229,6 @@ declare namespace AsTypedInternal { | ||
? number | ||
: SchemaType extends TupleSchema<infer TupleType, infer Additional> | ||
? Additional extends null | ||
? AsTypedTupleSchema<TupleType> | ||
: AsTypedTupleSchemaWithAdditional<TupleType, Additional> | ||
: SchemaType extends Not<infer T> | ||
@@ -256,6 +260,2 @@ ? ResolveNot<T> | ||
// TODO | ||
type ResolveOneOf<InnerSchema> = InnerSchema; | ||
// High order resolution changes the schema before resolving it to typed | ||
@@ -268,3 +268,3 @@ | ||
: SchemaToResolve extends OneOf<infer Inner> | ||
? ResolveOneOf<Inner> | ||
? Inner | ||
: SchemaToResolve extends AllOf<infer Inner> | ||
@@ -276,10 +276,5 @@ ? UnionToIntersection<Inner> | ||
type ResolveRecursive<SchemaType> = SchemaType extends TupleSchema< | ||
infer TupleType, | ||
infer Additional | ||
> | ||
? Additional extends null | ||
? AsTypedTupleSchema<TupleType> | ||
: AsTypedTupleSchemaWithAdditional<TupleType, Additional> | ||
: ResolveRecursiveInternal<ResolveHighOrder<SchemaType>>; | ||
type ResolveRecursive<SchemaType> = ResolveRecursiveInternal< | ||
ResolveHighOrder<SchemaType> | ||
>; | ||
@@ -286,0 +281,0 @@ type MapPropsToRefs< |
{ | ||
"name": "as-typed", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Static TypeScript types from a literal JSONSchema type", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"start": "ts-node src/main.ts", | ||
"test": "$(node spec/setup.js) && jest -w10", | ||
"test": "tsc -noEmit", | ||
"eslint:fix": "eslint --fix '*.ts'", | ||
"eslint:check": "eslint '*.ts'", | ||
"prettier:fix": "prettier --write '*.{t,j}s'", | ||
"prettier:check": "prettier --check '*.{t,j}s'", | ||
"build": "tsc" | ||
"prettier:check": "prettier --check '*.{t,j}s'" | ||
}, | ||
"keywords": [], | ||
"keywords": [ | ||
"typescript", | ||
"jsonschema", | ||
"json", | ||
"schema" | ||
], | ||
"author": "Guilherme Bernal <guilherme@cubos.io>", | ||
@@ -17,0 +20,0 @@ "license": "MIT", |
24
test.ts
@@ -131,3 +131,27 @@ import { AsTyped } from "./index"; | ||
_ as AsTyped<{ | ||
oneOf: [{ type: "string" }, { type: "array"; items: { type: "string" } }]; | ||
}>, | ||
_ as string | string[] | ||
); | ||
assert( | ||
_ as AsTyped<{ | ||
oneOf: [{ type: "string" }, { type: "array"; items: [] }]; | ||
}>, | ||
_ as string | [] | ||
); | ||
assert( | ||
_ as AsTyped<{ | ||
oneOf: [ | ||
{ type: "array"; items: [{ type: "string" }] }, | ||
{ type: "array"; items: [] } | ||
]; | ||
}>, | ||
_ as [string] | [] | ||
); | ||
assert( | ||
_ as AsTyped<{ | ||
oneOf: [ | ||
{ type: "string" }, | ||
@@ -134,0 +158,0 @@ { type: "object"; properties: { a: { type: "number" } } } |
Sorry, the diff of this file is not supported yet
35991
13
939