mirror of
https://github.com/zoriya/typebox.git
synced 2026-06-12 14:48:05 +00:00
Revision 0.32.17 (#799)
* Detect Any on StaticDecode * Revision 0.32.17
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@sinclair/typebox",
|
||||
"version": "0.32.16",
|
||||
"version": "0.32.17",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@sinclair/typebox",
|
||||
"version": "0.32.16",
|
||||
"version": "0.32.17",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.13.2",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sinclair/typebox",
|
||||
"version": "0.32.16",
|
||||
"version": "0.32.17",
|
||||
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
|
||||
"keywords": [
|
||||
"typescript",
|
||||
|
||||
@@ -85,8 +85,9 @@ export type TDecodeType<T extends TSchema> = (
|
||||
// ------------------------------------------------------------------
|
||||
// Static
|
||||
// ------------------------------------------------------------------
|
||||
export type StaticDecodeIsAny<T> = boolean extends (T extends TSchema ? true : false) ? true : false
|
||||
/** Creates an decoded static type from a TypeBox type */
|
||||
export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<TDecodeType<T>, P>
|
||||
export type StaticDecode<T extends TSchema, P extends unknown[] = []> = StaticDecodeIsAny<T> extends true ? unknown : Static<TDecodeType<T>, P>
|
||||
/** Creates an encoded static type from a TypeBox type */
|
||||
export type StaticEncode<T extends TSchema, P extends unknown[] = []> = Static<T, P>
|
||||
/** Creates a static type from a TypeBox type */
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Type, TSchema, Static, StaticDecode, TObject, TNumber } from '@sinclair/typebox'
|
||||
import { TypeCheck } from '@sinclair/typebox/compiler'
|
||||
import { Value } from '@sinclair/typebox/value'
|
||||
|
||||
import { Expect } from './assert'
|
||||
{
|
||||
// string > number
|
||||
@@ -309,3 +312,11 @@ import { Expect } from './assert'
|
||||
Expect(T).ToStaticDecode<new (x: Date) => Date>()
|
||||
Expect(T).ToStaticEncode<new (x: number) => number>()
|
||||
}
|
||||
// -------------------------------------------------------------
|
||||
// https://github.com/sinclairzx81/typebox/issues/798
|
||||
// -------------------------------------------------------------
|
||||
{
|
||||
const c1: TypeCheck<any> = {} as any
|
||||
const x1 = c1.Decode({})
|
||||
const x2 = Value.Decode({} as any, {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user