typedriver 0.8.6 → 0.8.7
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/index.d.mts +3 -1
- package/build/index.mjs +6 -1
- package/build/validator.d.mts +2 -0
- package/package.json +1 -1
- package/readme.md +34 -36
package/build/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { type TCompile, compile } from './compile.mjs';
|
|
2
2
|
export { type Static } from './static.mjs';
|
|
3
|
-
export { Validator, type TErrorFormat, type TErrorLocale, type TErrorOptions, type TErrorResult } from './validator.mjs';
|
|
3
|
+
export { Validator, type TErrorFormat, type TErrorLocale, type TErrorOptions, type TErrorResult, type TJsonSchemaError, type TStandardSchemaError, } from './validator.mjs';
|
|
4
|
+
import { compile } from './compile.mjs';
|
|
5
|
+
export default compile;
|
package/build/index.mjs
CHANGED
|
@@ -6,4 +6,9 @@ export { compile } from './compile.mjs';
|
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// Validator
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
|
-
export { Validator } from './validator.mjs';
|
|
9
|
+
export { Validator, } from './validator.mjs';
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
// Default
|
|
12
|
+
// ------------------------------------------------------------------
|
|
13
|
+
import { compile } from './compile.mjs';
|
|
14
|
+
export default compile;
|
package/build/validator.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { System } from 'typebox/system';
|
|
2
2
|
import { TLocalizedValidationError } from 'typebox/error';
|
|
3
3
|
import { StandardSchemaV1 } from './_standard/standard-schema.mjs';
|
|
4
|
+
export type TStandardSchemaError = StandardSchemaV1.Issue;
|
|
5
|
+
export type TJsonSchemaError = TLocalizedValidationError;
|
|
4
6
|
export type TErrorFormat = 'json-schema' | 'standard-schema';
|
|
5
7
|
declare const Locale: typeof System.Locale;
|
|
6
8
|
export type TErrorLocale = (Exclude<keyof typeof Locale, 'Get' | 'Set' | 'Reset'> & ({} & string));
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<h1>TypeDriver</h1>
|
|
4
4
|
|
|
5
|
-
<p>High Performance Driver for Runtime Type System Integration</p>
|
|
5
|
+
<p>A High Performance Driver for Runtime Type System Integration</p>
|
|
6
6
|
|
|
7
7
|
<img src="typedriver.png" />
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ $ npm install typedriver
|
|
|
26
26
|
Multi-Library Type Compiler and Inference System for High Performance Frameworks
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
-
import
|
|
29
|
+
import compile from 'typedriver'
|
|
30
30
|
|
|
31
31
|
const Vector3 = compile(`{
|
|
32
32
|
x: number,
|
|
@@ -43,38 +43,16 @@ const position = Vector3.parse(value) // const position: {
|
|
|
43
43
|
// } = ...
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Compiles: [TypeScript](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoAqBPADgUwMoDGATgJbYAuqYStd9D4ypAttgPbEWgDeoh7NqQA2uUAF9QAM2KDQAcgo5cAEzIA3XMXnJkAgHYBnbgDVchCpwDMoALz9B2EbgAUAAx7JQoAB4AuUH0AVxYAIy0AGi9QTADgsMjogC84kPDiZHE3AEpdFXNhAENiMQNjUHVC4SDcAKD9AGt9dgB3fV0y7g5DUgpSdn07UDMLawA6bGLDV0rq3GzvRaXFtE7Qbt7+-QDPZb39g8OjpbRvf0C0xOPrm5vTmNSE4ijb17eTsG8Ui6fo9--rmhJPYxqCgA) | [JSON Schema](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoBSBnA9gO1AMoDGAFgKYC2AhqmEvQ40+MgJYUAO2ATgC6gBvUEWydWAGzKgAvqABm3UaADkvAJ4cyAE26sAbmW7LkyEbkz8AamSK8eAZlABeYaI4SyACgHJQodZoAXCrYAEYAVja8ygA0vqDcZACOAK6siVrBANrKAB6xKmoFygBeygC6cX4cipp8rGSYwT5+frnN-hpkwcq4KRShhsoyVa1qHQHdKn0DQyPxfiUTXT0zg0Yy8dLI0gCUJlo24lSJrub8elTiKVMpuADWuNgA7rgmZhagXJisvKx4zlA1lsDgAdBwTpgvJdrmRdq0EYi0B9+N9fv9cM0Foicbi8fiCaA0G1gmtDKNCZSqYTiaBxqAydwKdSWayiWBFqT+utsWy+QS0LIXKCRUA) | [TypeBox](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoBSBnA9gO1AMoDGAFgKYC2AhgFygAqAngA5kBC2AHqmEn-wMHhkASwrNsAJwAuoAN6gi2cSIA2ZUAF9QAM0nLQAcmksyAE0kiAbmUmHR4qbKatd+ikZOsARl0OgA5GQlXExZADUyImkpAGZQAF5FZWY1MgAKFzIAOgB5bwArKOl0uWQAzjos7IA5AFcKb1t0gEoAGnLQRirTWoamyVaOgIAvHtY+xuaW5E0WmeQzKNUqSQ0QsNArKlU6sjo63ABrXGwAd1wgjdkJTBFpETxE0EjouOzmVcwM7d2yFoCgKBgLQ11At3uj1wdDKwLh8IRiKRQLQFTouH6tmGyJxuJxqK66MxkmxeLJ5ICBLGoAxU0knQpjPxYG0SWy7KAA) | [Effect](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFygCiAZi1WZqmEr3-wPDIAljQAOAeyKZQAb1BkJ44QBsqoAL6gWRJaADkmAJ5iq+IsIBuVIvpHipM+ekq1sm7bpoGqbDpjtkRVwAZxkANX8pAGZQAF4FJTFVKgAKF2o6ADowvEISDLdwgEZ012ysIgBXTlTZZFBQAA9GQuyAOSqaACMbABoG0CNW8uwszp7+wYAvEcyxid6iZA0ASnXkZHwOFWJ1YLDQS2wVKqpGKtwAa1wJAHdcTYOZSRDhTGEJXHjQSM4YrJiYghNLHU5UVaNKHQqFoZ6gV7vT64Rj1GHojGYrHY6FoRpEKjYfBfFRGZqMXBdJYDHG0ul0vGgAlEklk4agSmTIg0+m8vmwsD4wnE3Ck0CzDlUmyDfmy2loLQJLLKoA) | [Zod](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFygBaA9vqmEl9z7+MgEsaABxZFMoAN6gyLEQIA2VUAF9QAMyJzQAckwBPYVXxEBANypEdyQSLESAVKGwBnUAC8NWmrvdtryLK4LhIAalRkmGIAzKAAvDJywopUABTuAHQsAEYAVhGYqZLIoKAAHoyZuACuNNmWqQCUADQloPqVGTV1DS1t7p3d9URNyCqNjTb4EQrEykEhoGbYCtVUjNW4ANa4LADuuDYLEqIuApgCLLjxoOGRMRnCxC5py6tUjaVf319ox6Cnc6XXCMYo-cEQyFQ6HfNClCqgIaWVow1FotFw9qMJFEFHo-EE35gUoDRG1YZtQlU1FoNQJDIMoA) | [ArkType](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFygCCRA1gCoCeADlamEkFDhI8MgCWNbgHsimUAG9QZaVPEAbKqAC+oAGZFVoAOSYeVfEXEA3KkWPIJU2fKVneO-YZonird1QOyCq4AM7yAGpUZJiyAMygALzKqtwaVAAUARkKyKCgAB6MxrgArjQARnbGADR5oJzFZZXVdfkAXk3lVfbI2gCU-Y740erEWiHhoNbY6qVUjKW4rLjSAO64jpPyMqHimOLSuEmgUTHxAHTcxKGZM3NU-fnPL89o26C7+4e4jLmvAMBQOBIJeaHyRVAzR6bVBcPhcPBDUY0LssIRGMx+SRnSh3Ts9SxRMRYF0yQuFKAA) | [Valibot](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFygBq2ANgJYBGA9pqmEkFDhI8MnY0ADtyKZQAb1BluU9qyqgAvqABmRFaADkmAJ6Sq+IuwBuVIoeTipMuQCpQ2AM6hru-TSNrNi5eB2RlXE85JioyTBkAZlAAXiUVSTUqAAprADpuTgArWMws+WRQUAAPRjzcAFcaTjssgEoAGgrQE1rchqaWjq6AL17+5qI25E1W1sd8WNZiDQionzZ6qkZ63ABrXG4Ad1xHVblpT3ZMdm5cFOYSxNzJYk9soNZN1sqf35+0M6gC5XG64RjlP6QqHQmGw35oSo1UDjOydOHojEYhHdRgoohozGEon-MCVUbIxoTLrEmnotDaVK5JlAA) | [Arri](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFygCCRRAlqmEtz73+MjY0ADgHsimUAG9QZUSLYAbKqAC+oAGZF5oAOSYAnsKr52ANypFdgkeMkzsazdpp6AAsXZFhZYAGdKWmxrZDlcP0kANSoyTHEAZlAAXll5YSUqAApsADpRACMAKxjMTKlkUFAAD0Zc3ABXGnzLTIBKABoK0ANanIamlo6ugC9e-uaiNuRVVtbkZHwYxWIVMIjQM2xFeqpGetwAa1xRAHdcebXJMT82TDZRXGTQaNiEnOFiPyzN7apWyoBgIBaEuoGut3uuEY5SBsLh8IRiMBaEqNVA40snSR2JxOJR3UYGKIWNxpLJwLAlVG6MaEy65IZ2LQ6hSOTZQA) | [Sury](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YpAoEoDKAXAhgOwCbYBO+GAxgBYCmAttgFwYCuRAnqmEl9z7+MgEsaABwD2RTKADeoMqJECANlVABfUADMi80AHJMrYVXxEBANypFdgkeMkAqUNgDOGTdpp7nLVrtD+AwKDg-zQAFgA6AGZQAGsAIVAAChoBXFAAalAAcwAvAWEASmRkOVxnSQA1KjJMcRiAXll5YSUqJPQI50pabCSpZH8AD0ZO3CYaACNLABpB0FZRiPGp2fncpZXpojnVQuLkfBrFYhUyitAzbEUmKkYmXFjcUQB3XBLzyTFnAUwBUXSTWqtXqEWExGc7SuNyohRCQTQn1A31+-1wjAG8Kx2JxOLQw0YWzWuJJpOx+IWhIm2zmZLp9NAFI2oCJRHmDI55LA6iaET5QA) ... and more
|
|
47
47
|
|
|
48
48
|
## Overview
|
|
49
49
|
|
|
50
|
-
TypeDriver is a
|
|
50
|
+
TypeDriver is a validation compiler and type-inference middleware designed to integrate JSON Schema and Standard Schema compliant validation into framework interfaces such as HTTP routes and RPC endpoints. It also functions as a validation optimizer built to accelerate high-throughput messaging systems.
|
|
51
51
|
|
|
52
52
|
This project is designed to unify heterogeneous runtime schema systems based on JSON Schema and Standard Schema into a single system that preserves static type inference, runtime validation, and schema reflection, while remaining compatible with multiple schema ecosystems.
|
|
53
53
|
|
|
54
54
|
License MIT
|
|
55
55
|
|
|
56
|
-
## Features
|
|
57
|
-
|
|
58
|
-
- Framework Integration
|
|
59
|
-
- Designed for [Type-Safe](#Framework) public IO interfaces (Routes)
|
|
60
|
-
- One [Function](#Compile) to compile schematics into uniform Validators.
|
|
61
|
-
- One [Type](#Static) to infer schematics into TypeScript types.
|
|
62
|
-
- [Extension](#Extensions) Model for Framework Specific Runtime Type APIs
|
|
63
|
-
- Schema Support
|
|
64
|
-
- TypeScript [DSL](#Script) feature for TS7-native (supported in TS5+).
|
|
65
|
-
- Scalable [JSON Schema Type Inference](https://tsplay.dev/NlrkxW) as standard.
|
|
66
|
-
- Supports JSON Schema Drafts 3 through 2020-12.
|
|
67
|
-
- Full support for Standard Schema
|
|
68
|
-
- Validation Compiler
|
|
69
|
-
- High-performance JIT compiler for faster application start up.
|
|
70
|
-
- High-performance runtime validation (approx 2x Ajv under comparable workloads)
|
|
71
|
-
- Automatic [Acceleration](#Accelerate) for libraries supporting Standard JSON Schema.
|
|
72
|
-
- Automatic JIT fallback for [Content-Security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) restrictive environments (Cloudflare)
|
|
73
|
-
- Tooling and Interoperability
|
|
74
|
-
- JSON Schema [Reflect](#Reflect) API for OpenAPI, MCP, and IDL-Based Systems
|
|
75
|
-
- Error [Formats](#Errors) for JSON Schema and Standard Schema Based Systems
|
|
76
|
-
- [Localized](#Locales) Error Messages (i18n)
|
|
77
|
-
|
|
78
56
|
## Contents
|
|
79
57
|
|
|
80
58
|
- [Overview](#Overview)
|
|
@@ -93,6 +71,28 @@ License MIT
|
|
|
93
71
|
- [Compression](#Compression)
|
|
94
72
|
- [Contribute](#Contribute)
|
|
95
73
|
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
- Framework Integration
|
|
77
|
+
- Designed specifically for [type-safe](#Framework) I/O interfaces.
|
|
78
|
+
- One function to [compile](#compile) schematics into Validators.
|
|
79
|
+
- One type to [infer](#Static) schematics into TypeScript types.
|
|
80
|
+
- Schema [extension](#Extensions) model for Framework specific runtime type API
|
|
81
|
+
- Schema Support
|
|
82
|
+
- TypeScript [DSL](#Script) for TS7-native (supported in TS5+).
|
|
83
|
+
- Scalable JSON Schema type inference ([demo](https://tsplay.dev/wjrYMw))
|
|
84
|
+
- Supports JSON Schema Drafts 3 through 2020-12.
|
|
85
|
+
- Full support for Standard Schema
|
|
86
|
+
- Validation Compiler
|
|
87
|
+
- High-performance JIT compiler for faster application start up.
|
|
88
|
+
- High-performance runtime validation (approx 2x Ajv performance)
|
|
89
|
+
- Automatic [acceleration](#Accelerate) for libraries supporting Standard JSON Schema.
|
|
90
|
+
- Automatic JIT fallback for [content-security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) restrictive environments (Cloudflare)
|
|
91
|
+
- Tooling and Interoperability
|
|
92
|
+
- JSON Schema [reflect](#Reflect) API for OpenAPI, MCP, and IDL-Based Systems
|
|
93
|
+
- Error [formats](#Errors) for JSON Schema and Standard Schema Based Systems
|
|
94
|
+
- Includes [localized](#Locales) error messages (i18n) as standard.
|
|
95
|
+
|
|
96
96
|
## Framework
|
|
97
97
|
|
|
98
98
|
TypeDriver is designed for framework integration. It provides a simple infrastructure to connect type inference and validation to framework interfaces.
|
|
@@ -100,6 +100,8 @@ TypeDriver is designed for framework integration. It provides a simple infrastru
|
|
|
100
100
|
Ref: [TypeScript](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YyAoEoAiBTAzgSwOYB2qYSZ5FcyADgPbYAuAFAOTAsA0oA3sqKACNaAEwCeALlAADXv34APSYQCuAWwGYAThz5yJoFeq065oAF5K1GzboC+U5La5NNmAI7KcDAJSgAvAB8PLoAxrSEjDyg8lyiXGagtv6grh5eAHRCYqBoDKLUmODYAIYAZpgAhI7eyCQQlA2N8HUAYprFqpgA7rSaANZ1TUPDyLiqdJoMUXkFoADKDMUMuCFcYeO4ADaYiaClmrSqoCwzmMKauABuWiy1mPITU7iEDFqlxSE7AEq0yq8A8tRluFsAAeABCIlEoHur0IwmwoGUhD6hFoXUIyWRqPRhCCskEUMkkLEjmQ90eoFOoB+f0wAGFiptNgIPn1QQAFJYACxh8jhCNAjAuhHwXEBwIifIFiNpAKBuBBQT8oCYuhc7k8jEk3CRmk2ki5DG5XCy+gWSxWoIlioiAG0WGaWABdIK2XyBUCXWi4YTIGoU3pTUrIkKS0B0RicnnSzDwxHC55i0BhCJTG0g2Pxmm-eWS7BcXSM5mskJ9ZJyhlMlls6PG8UKpXIAJMag8w08ri0RsRSQZiJraulvqSYs1su+AmpyJmgD6lyZvqWvWS62oW0wTG7+YdTudNX4uREtEk6TPoDG1G2nReKVzO02tHwKzJQA) | [JSON Schema](https://www.typescriptlang.org/play/?target=99&module=7#code/PTAEFpK6dv4YyAoEoAiBTAzgSwOYB2qYSZ5FcyADgPbYAuAFAOTAsA0oA3sqKACNaAEwCeALh59+oBqOqZJLWgIBWmAMYNO0-gCdMARwCuuA8MkBtFgA9OoFqPssAXiwC6HXaGp7aCvQZcHEleGRkbUNl5RQdCYwBbAUw9FlAAXy9w-gkeaIUleKSUtMzvfhcouQK4xOTUjKyZdOkWzNAmAxMcBgBKUABeAD4pfg1aQkY8my5RLhcMwdAu4x6AOiExUDRqzHBsAEMAM0wAQmR03uQSCEo7+-gbgDE9A4TMAHdaPQBrG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vYLRhOUKpX2Q5dTuYAeK5XlwMm7sO5CVZR0TX+zVaBhzhrmFu9hvyyfD8wToeHMp8xuNEMAfQh8szL2YXU+dB+mGUG7N2Fj8YTWX0IxkBhzAsECkXoX5dhRbppT+b4GHwN4RSAA)
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
|
+
// Next Generation Inference System Based on TypeScript DSL (TS7)
|
|
104
|
+
|
|
103
105
|
route('/', {
|
|
104
106
|
body: `{
|
|
105
107
|
x: number,
|
|
@@ -142,7 +144,7 @@ export function route<Path extends string, const Options extends RouteOptions,
|
|
|
142
144
|
TypeDriver consists of a single compile(...) function that accepts JSON Schema, Standard Schema or TypeScript definition and returns a Validator instance.
|
|
143
145
|
|
|
144
146
|
```typescript
|
|
145
|
-
import
|
|
147
|
+
import compile from 'typedriver'
|
|
146
148
|
```
|
|
147
149
|
|
|
148
150
|
Ref: [TypeScript](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYwuYAbApnAvnAMyjTgHIYBPMLAEymADcspSAoV1AOwGd4A1LMhjQAzHAC8KNGExYAFAAMErOHAAeALjicAriABGzFXApbdBo6oBeZvYaitcCgJSq37j56-ef7gPR+Ujz8gsJQIlp8AIYYwDRRYQA8AHSpADSIxr7ZObluAW6a2nbMaVl5FZX5gaqmxRZQZVXNlQXWtg1NLd3ZBbgAfOxcvHCQ3MAwwBCcEnACQqLJYFFQ3PJIxkUADF11AIxdNnBbjs5AA)
|
|
@@ -264,7 +266,7 @@ const issues = [
|
|
|
264
266
|
|
|
265
267
|
## Locales
|
|
266
268
|
|
|
267
|
-
TypeDriver
|
|
269
|
+
TypeDriver provides localized translations for multiple languages and locales, using BCP 47-compliant locale identifiers expressed with underscores (_) in place of hyphens (-). These can be passed to the errors(...) function in the following way.
|
|
268
270
|
|
|
269
271
|
```typescript
|
|
270
272
|
const issues = Vector3.errors({ x: 1, y: true }, {
|
|
@@ -345,11 +347,9 @@ const C = z.object({
|
|
|
345
347
|
})
|
|
346
348
|
```
|
|
347
349
|
|
|
348
|
-
Localization support is only available for JSON Schema
|
|
349
|
-
|
|
350
350
|
## Script
|
|
351
351
|
|
|
352
|
-
The TypeScript DSL is a runtime and type-level emulation of TypeScript. This feature is based on TypeBox
|
|
352
|
+
The [TypeScript DSL](https://sinclairzx81.github.io/typebox/#/docs/script/overview) is a runtime and type-level emulation of TypeScript. This feature is based on TypeBox's ability to transform TypeScript syntax into JSON Schema. The DSL supports most TypeScript definitions, as well as type-level constraints expressed using JSON Schema keywords.
|
|
353
353
|
|
|
354
354
|
> ⚠️ The name `Options<T>` is subject to change. Because Options is a commonly used type name, it may not be appropriate for schema constraint augmentation. As a result, Options should be considered an experimental feature. TypeBox and TypeDriver are open to suggestions for a more suitable name for this type.
|
|
355
355
|
|
|
@@ -380,7 +380,7 @@ Refer to [TypeBox](https://github.com/sinclairzx81/typebox) for additional infor
|
|
|
380
380
|
Validators can reflect back a JSON Schema representation if the underlying type supports it. This is true for all TypeScript and JSON Schema source types. Reflect can be used for OpenAPI metadata publishing, or RPC systems that need to publish JSON based IDL (interface definition language) to remote callers. Validators provide two functions for this.
|
|
381
381
|
|
|
382
382
|
```typescript
|
|
383
|
-
import
|
|
383
|
+
import compile, { type Static } from 'typedriver'
|
|
384
384
|
|
|
385
385
|
const validator = compile(...)
|
|
386
386
|
|
|
@@ -394,7 +394,7 @@ validator.toJSONSchema() // Returns the JSON Schema for the validator. If the
|
|
|
394
394
|
// empty {} is returned to indicate an unknown
|
|
395
395
|
// runtime schema.
|
|
396
396
|
```
|
|
397
|
-
The source type used for compilation can also be returned via
|
|
397
|
+
The original source type used for compilation can also be returned via
|
|
398
398
|
|
|
399
399
|
```typescript
|
|
400
400
|
validator.schema() // will return the schematic used for compile.
|
|
@@ -407,7 +407,7 @@ TypeDriver enables Frameworks to define custom Runtime Types specific to the Fra
|
|
|
407
407
|
Ref: [Framework Types](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAbzgYwuYAbApgGjjATz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KnqKUqLq2nbboc6Jj0a5rWoM9gfqEegaiAA)
|
|
408
408
|
|
|
409
409
|
```typescript
|
|
410
|
-
import
|
|
410
|
+
import compile, { type Static } from 'typedriver'
|
|
411
411
|
|
|
412
412
|
interface FrameworkString {
|
|
413
413
|
type: 'string'
|
|
@@ -423,8 +423,6 @@ const T = number() // const T: FrameworkString = { type: 'nu
|
|
|
423
423
|
type T = Static<typeof T> // type T = number
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
This is an advanced feature based on TypeBox's extension model for JSON Schema.
|
|
427
|
-
|
|
428
426
|
## Accelerate
|
|
429
427
|
|
|
430
428
|
TypeDriver provides acceleration support for libraries that implement the upcoming Standard JSON Schema specification. This is a new specification enables remote type libraries to be integrated directly into TypeBox validation infrastructure. This project tracks upstream implementations of this specification and maintains a benchmark measuring compariative performance with and without compile(...).
|