@sinclair/typebox 0.34.15 → 0.34.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/syntax/index.d.ts +1 -1
- package/build/cjs/syntax/index.js +1 -1
- package/build/cjs/syntax/runtime.d.ts +38 -54
- package/build/cjs/syntax/runtime.js +60 -202
- package/build/cjs/syntax/static.d.ts +62 -148
- package/build/cjs/syntax/syntax.d.ts +33 -0
- package/build/cjs/syntax/syntax.js +37 -0
- package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +3 -3
- package/build/cjs/type/constructor-parameters/constructor-parameters.js +3 -1
- package/build/cjs/type/instance-type/instance-type.d.ts +5 -4
- package/build/cjs/type/instance-type/instance-type.js +3 -1
- package/build/cjs/type/parameters/parameters.d.ts +3 -3
- package/build/cjs/type/parameters/parameters.js +3 -1
- package/build/cjs/type/return-type/return-type.d.ts +5 -4
- package/build/cjs/type/return-type/return-type.js +3 -1
- package/build/cjs/type/type/javascript.d.ts +4 -4
- package/build/esm/syntax/index.d.mts +1 -1
- package/build/esm/syntax/index.mjs +1 -1
- package/build/esm/syntax/runtime.d.mts +38 -54
- package/build/esm/syntax/runtime.mjs +60 -202
- package/build/esm/syntax/static.d.mts +62 -148
- package/build/esm/syntax/syntax.d.mts +33 -0
- package/build/esm/syntax/syntax.mjs +30 -0
- package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +3 -3
- package/build/esm/type/constructor-parameters/constructor-parameters.mjs +3 -1
- package/build/esm/type/instance-type/instance-type.d.mts +5 -4
- package/build/esm/type/instance-type/instance-type.mjs +3 -1
- package/build/esm/type/parameters/parameters.d.mts +3 -3
- package/build/esm/type/parameters/parameters.mjs +3 -1
- package/build/esm/type/return-type/return-type.d.mts +5 -4
- package/build/esm/type/return-type/return-type.mjs +3 -1
- package/build/esm/type/type/javascript.d.mts +4 -4
- package/package.json +11 -1
- package/parser/package.json +4 -0
- package/readme.md +86 -160
- package/build/cjs/syntax/parse.d.ts +0 -15
- package/build/cjs/syntax/parse.js +0 -19
- package/build/esm/syntax/parse.d.mts +0 -15
- package/build/esm/syntax/parse.mjs +0 -14
- /package/build/cjs/{syntax/parsebox → parser}/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.js +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.mjs +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
|
|
1
|
+
import { type TSchema, type SchemaOptions } from '../schema/index';
|
|
2
|
+
import { type TFunction } from '../function/index';
|
|
3
|
+
import { type TNever } from '../never/index';
|
|
4
|
+
export type TReturnType<Type extends TSchema, Result extends TSchema = Type extends TFunction<infer _Parameters extends TSchema[], infer ReturnType extends TSchema> ? ReturnType : TNever> = Result;
|
|
4
5
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
5
|
-
export declare function ReturnType<
|
|
6
|
+
export declare function ReturnType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TReturnType<Type>;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ReturnType = ReturnType;
|
|
5
5
|
const type_1 = require("../create/type");
|
|
6
|
+
const index_1 = require("../never/index");
|
|
7
|
+
const KindGuard = require("../guard/kind");
|
|
6
8
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
7
9
|
function ReturnType(schema, options) {
|
|
8
|
-
return (0, type_1.CreateType)(schema.returns, options);
|
|
10
|
+
return (KindGuard.IsFunction(schema) ? (0, type_1.CreateType)(schema.returns, options) : (0, index_1.Never)(options));
|
|
9
11
|
}
|
|
@@ -26,7 +26,7 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
26
26
|
/** `[JavaScript]` Creates a BigInt type */
|
|
27
27
|
BigInt(options?: BigIntOptions): TBigInt;
|
|
28
28
|
/** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
|
|
29
|
-
ConstructorParameters<Type extends
|
|
29
|
+
ConstructorParameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TConstructorParameters<Type>;
|
|
30
30
|
/** `[JavaScript]` Creates a Constructor type */
|
|
31
31
|
Constructor<Parameters extends TSchema[], InstanceType extends TSchema>(parameters: [...Parameters], instanceType: InstanceType, options?: SchemaOptions): TConstructor<Parameters, InstanceType>;
|
|
32
32
|
/** `[JavaScript]` Creates a Date type */
|
|
@@ -34,11 +34,11 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
34
34
|
/** `[JavaScript]` Creates a Function type */
|
|
35
35
|
Function<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [...Parameters], returnType: ReturnType, options?: SchemaOptions): TFunction<Parameters, ReturnType>;
|
|
36
36
|
/** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
|
|
37
|
-
InstanceType<Type extends
|
|
37
|
+
InstanceType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TInstanceType<Type>;
|
|
38
38
|
/** `[JavaScript]` Creates an Iterator type */
|
|
39
39
|
Iterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TIterator<Type>;
|
|
40
40
|
/** `[JavaScript]` Extracts the Parameters from the given Function type */
|
|
41
|
-
Parameters<Type extends
|
|
41
|
+
Parameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TParameters<Type>;
|
|
42
42
|
/** `[JavaScript]` Creates a Promise type */
|
|
43
43
|
Promise<Type extends TSchema>(item: Type, options?: SchemaOptions): TPromise<Type>;
|
|
44
44
|
/** `[JavaScript]` Creates a RegExp type */
|
|
@@ -46,7 +46,7 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
46
46
|
/** `[JavaScript]` Creates a RegExp type */
|
|
47
47
|
RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
|
|
48
48
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
49
|
-
ReturnType<Type extends
|
|
49
|
+
ReturnType<Type extends TSchema>(type: Type, options?: SchemaOptions): TReturnType<Type>;
|
|
50
50
|
/** `[JavaScript]` Creates a Symbol type */
|
|
51
51
|
Symbol(options?: SchemaOptions): TSymbol;
|
|
52
52
|
/** `[JavaScript]` Creates a Undefined type */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './syntax.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './syntax.mjs';
|
|
@@ -1,71 +1,55 @@
|
|
|
1
|
-
import { Runtime } from '
|
|
2
|
-
import * as
|
|
1
|
+
import { Runtime } from '../parser/index.mjs';
|
|
2
|
+
import * as t from '../type/index.mjs';
|
|
3
3
|
export declare const Module: Runtime.Module<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Heritage: Runtime.IUnion<unknown[]>;
|
|
7
|
-
InterfaceDeclaration: Runtime.ITuple<{
|
|
8
|
-
[x: string]: Types.TIntersect<[...Types.TRef<string>[], Types.TObject<Types.TProperties>]>;
|
|
9
|
-
}>;
|
|
10
|
-
TypeAliasDeclaration: Runtime.ITuple<{
|
|
11
|
-
[x: string]: Types.TSchema;
|
|
12
|
-
}>;
|
|
13
|
-
ModuleType: Runtime.IUnion<unknown>;
|
|
14
|
-
ModuleProperties: Runtime.IUnion<Types.TProperties>;
|
|
15
|
-
ModuleDeclaration: Runtime.ITuple<Types.TModule<Types.TProperties, {
|
|
16
|
-
[x: string]: Types.TSchema;
|
|
17
|
-
[x: number]: Types.TSchema;
|
|
18
|
-
}>>;
|
|
19
|
-
Literal: Runtime.IUnion<Types.TLiteral<string> | Types.TLiteral<number> | Types.TLiteral<boolean>>;
|
|
20
|
-
Keyword: Runtime.IUnion<Types.TAny | Types.TNever | Types.TString | Types.TBoolean | Types.TNumber | Types.TInteger | Types.TBigInt | Types.TNull | Types.TSymbol | Types.TUndefined | Types.TUnknown | Types.TVoid>;
|
|
4
|
+
Literal: Runtime.IUnion<t.TLiteral<string> | t.TLiteral<number> | t.TLiteral<boolean>>;
|
|
5
|
+
Keyword: Runtime.IUnion<t.TAny | t.TNever | t.TString | t.TBoolean | t.TNumber | t.TInteger | t.TBigInt | t.TNull | t.TSymbol | t.TUndefined | t.TUnknown | t.TVoid>;
|
|
21
6
|
KeyOf: Runtime.IUnion<boolean>;
|
|
22
7
|
IndexArray: Runtime.IUnion<unknown[]>;
|
|
23
8
|
Extends: Runtime.IUnion<unknown[]>;
|
|
24
9
|
Base: Runtime.IUnion<unknown>;
|
|
25
|
-
Factor: Runtime.ITuple<
|
|
10
|
+
Factor: Runtime.ITuple<t.TSchema>;
|
|
26
11
|
ExprTermTail: Runtime.IUnion<[] | ["&", unknown, unknown]>;
|
|
27
|
-
ExprTerm: Runtime.ITuple<
|
|
12
|
+
ExprTerm: Runtime.ITuple<t.TSchema>;
|
|
28
13
|
ExprTail: Runtime.IUnion<[] | ["|", unknown, unknown]>;
|
|
29
|
-
Expr: Runtime.ITuple<
|
|
14
|
+
Expr: Runtime.ITuple<t.TSchema>;
|
|
30
15
|
Type: Runtime.IRef<unknown>;
|
|
31
16
|
PropertyKey: Runtime.IUnion<string>;
|
|
32
17
|
Readonly: Runtime.IUnion<boolean>;
|
|
33
18
|
Optional: Runtime.IUnion<boolean>;
|
|
34
19
|
Property: Runtime.ITuple<{
|
|
35
|
-
[x: string]:
|
|
20
|
+
[x: string]: t.TSchema;
|
|
36
21
|
}>;
|
|
37
22
|
PropertyDelimiter: Runtime.IUnion<[","] | [",", "\n"] | [";"] | [";", "\n"] | ["\n"]>;
|
|
38
|
-
Properties: Runtime.IUnion<
|
|
39
|
-
Object: Runtime.ITuple<
|
|
23
|
+
Properties: Runtime.IUnion<t.TProperties>;
|
|
24
|
+
Object: Runtime.ITuple<t.TObject<t.TProperties>>;
|
|
40
25
|
Elements: Runtime.IUnion<unknown[]>;
|
|
41
|
-
Tuple: Runtime.ITuple<
|
|
42
|
-
Parameter: Runtime.ITuple<
|
|
43
|
-
Function: Runtime.ITuple<
|
|
26
|
+
Tuple: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
27
|
+
Parameter: Runtime.ITuple<t.TSchema>;
|
|
28
|
+
Function: Runtime.ITuple<t.TFunction<t.TSchema[], t.TSchema>>;
|
|
44
29
|
Parameters: Runtime.IUnion<unknown[]>;
|
|
45
|
-
Constructor: Runtime.ITuple<
|
|
46
|
-
Mapped: Runtime.ITuple<
|
|
47
|
-
AsyncIterator: Runtime.ITuple<
|
|
48
|
-
Iterator: Runtime.ITuple<
|
|
49
|
-
Awaited: Runtime.ITuple<
|
|
50
|
-
Array: Runtime.ITuple<
|
|
51
|
-
Record: Runtime.ITuple<
|
|
52
|
-
Promise: Runtime.ITuple<
|
|
53
|
-
ConstructorParameters: Runtime.ITuple<
|
|
54
|
-
FunctionParameters: Runtime.ITuple<
|
|
55
|
-
InstanceType: Runtime.ITuple<
|
|
56
|
-
ReturnType: Runtime.ITuple<
|
|
57
|
-
Partial: Runtime.ITuple<
|
|
58
|
-
Required: Runtime.ITuple<
|
|
59
|
-
Pick: Runtime.ITuple<
|
|
60
|
-
Omit: Runtime.ITuple<
|
|
61
|
-
Exclude: Runtime.ITuple<
|
|
62
|
-
Extract: Runtime.ITuple<
|
|
63
|
-
Uppercase: Runtime.ITuple<
|
|
64
|
-
Lowercase: Runtime.ITuple<
|
|
65
|
-
Capitalize: Runtime.ITuple<
|
|
66
|
-
Uncapitalize: Runtime.ITuple<
|
|
67
|
-
Date: Runtime.IConst<
|
|
68
|
-
Uint8Array: Runtime.IConst<
|
|
69
|
-
Reference: Runtime.IIdent<
|
|
70
|
-
Main: Runtime.IUnion<unknown>;
|
|
30
|
+
Constructor: Runtime.ITuple<t.TConstructor<t.TSchema[], t.TSchema>>;
|
|
31
|
+
Mapped: Runtime.ITuple<t.TLiteral<"Mapped types not supported">>;
|
|
32
|
+
AsyncIterator: Runtime.ITuple<t.TAsyncIterator<t.TSchema>>;
|
|
33
|
+
Iterator: Runtime.ITuple<t.TIterator<t.TSchema>>;
|
|
34
|
+
Awaited: Runtime.ITuple<t.TSchema>;
|
|
35
|
+
Array: Runtime.ITuple<t.TArray<t.TSchema>>;
|
|
36
|
+
Record: Runtime.ITuple<t.TNever>;
|
|
37
|
+
Promise: Runtime.ITuple<t.TPromise<t.TSchema>>;
|
|
38
|
+
ConstructorParameters: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
39
|
+
FunctionParameters: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
40
|
+
InstanceType: Runtime.ITuple<t.TSchema>;
|
|
41
|
+
ReturnType: Runtime.ITuple<t.TSchema>;
|
|
42
|
+
Partial: Runtime.ITuple<t.TObject<{}>>;
|
|
43
|
+
Required: Runtime.ITuple<t.TObject<{}>>;
|
|
44
|
+
Pick: Runtime.ITuple<t.TObject<{}>>;
|
|
45
|
+
Omit: Runtime.ITuple<t.TObject<{}>>;
|
|
46
|
+
Exclude: Runtime.ITuple<t.TNever>;
|
|
47
|
+
Extract: Runtime.ITuple<t.TSchema>;
|
|
48
|
+
Uppercase: Runtime.ITuple<t.TSchema>;
|
|
49
|
+
Lowercase: Runtime.ITuple<t.TSchema>;
|
|
50
|
+
Capitalize: Runtime.ITuple<t.TSchema>;
|
|
51
|
+
Uncapitalize: Runtime.ITuple<t.TSchema>;
|
|
52
|
+
Date: Runtime.IConst<t.TDate>;
|
|
53
|
+
Uint8Array: Runtime.IConst<t.TUint8Array>;
|
|
54
|
+
Reference: Runtime.IIdent<t.TSchema>;
|
|
71
55
|
}>;
|