typebox 1.0.1 → 1.0.3

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.
@@ -1,8 +1,8 @@
1
1
  import { type StaticType, type StaticDirection } from './static.mjs';
2
2
  import { type TSchema, type TSchemaOptions } from './schema.mjs';
3
+ import { type StaticInstantiatedParameters } from './function.mjs';
3
4
  import { type TProperties } from './properties.mjs';
4
- import { type StaticTuple } from './tuple.mjs';
5
- export type StaticConstructor<Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema, StaticParameters extends unknown[] = StaticTuple<Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Direction, Context, This, InstanceType>, Result = new (...args: StaticParameters) => StaticReturnType> = Result;
5
+ export type StaticConstructor<Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema, StaticParameters extends unknown[] = StaticInstantiatedParameters<Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Direction, Context, This, InstanceType>, Result = new (...args: StaticParameters) => StaticReturnType> = Result;
6
6
  /** Represents a Constructor type. */
7
7
  export interface TConstructor<Parameters extends TSchema[] = TSchema[], InstanceType extends TSchema = TSchema> extends TSchema {
8
8
  '~kind': 'Constructor';
@@ -1,8 +1,10 @@
1
1
  import { type StaticType, type StaticDirection } from './static.mjs';
2
2
  import { type TSchema, type TSchemaOptions } from './schema.mjs';
3
3
  import { type TProperties } from './properties.mjs';
4
- import { type StaticTuple } from './tuple.mjs';
5
- export type StaticFunction<Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema, StaticParameters extends unknown[] = StaticTuple<Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Direction, Context, This, ReturnType>, Result = (...args: StaticParameters) => StaticReturnType> = Result;
4
+ import { type TTuple } from './tuple.mjs';
5
+ import { type TInstantiate } from '../engine/instantiate.mjs';
6
+ export type StaticInstantiatedParameters<Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], Evaluated extends TSchema = TInstantiate<Context, TTuple<Parameters>>, Static extends unknown = StaticType<Direction, Context, This, Evaluated>, Result extends unknown[] = Static extends unknown[] ? Static : []> = Result;
7
+ export type StaticFunction<Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema, StaticParameters extends unknown[] = StaticInstantiatedParameters<Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Direction, Context, This, ReturnType>, Result = (...args: StaticParameters) => StaticReturnType> = Result;
6
8
  /** Represents a Function type. */
7
9
  export interface TFunction<Parameters extends TSchema[] = TSchema[], ReturnType extends TSchema = TSchema> extends TSchema {
8
10
  '~kind': 'Function';
@@ -12,10 +12,8 @@ function Decode(direction, context, type, value) {
12
12
  return Unreachable();
13
13
  // deno-coverage-ignore-stop
14
14
  for (const key of Guard.Keys(type.properties)) {
15
- // deno-coverage-ignore-start - unreachable | checked
16
15
  if (!Guard.HasPropertyKey(value, key))
17
- Unreachable();
18
- // deno-coverage-ignore-stop
16
+ continue;
19
17
  value[key] = FromType(direction, context, type.properties[key], value[key]);
20
18
  }
21
19
  return Callback(direction, context, type, value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "A Runtime Type System for JavaScript",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
package/readme.md CHANGED
@@ -49,11 +49,15 @@ type T = Static<typeof T> // type T = {
49
49
 
50
50
  ## Overview
51
51
 
52
+ [Documentation](https://sinclairzx81.github.io/typebox/)
53
+
52
54
  TypeBox is a runtime type system that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type system that can be statically checked by TypeScript and validated at runtime using standard Json Schema.
53
55
 
54
56
  This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
55
57
 
56
- License MIT
58
+
59
+
60
+ License: MIT
57
61
 
58
62
  ## Contents
59
63