mirror of
https://github.com/zoriya/typebox.git
synced 2026-06-03 11:16:30 +00:00
Recursive Fix: Evaluate Record and Array (#735)
* Fix some infinite recursion with static types * Adds test for #336 * Fix import path * Rename unused type parameter
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Static, Type } from '@sinclair/typebox'
|
||||
import { Expect } from './assert'
|
||||
import { Type, Static } from '@sinclair/typebox'
|
||||
|
||||
{
|
||||
// identity
|
||||
@@ -78,3 +78,24 @@ import { Type, Static } from '@sinclair/typebox'
|
||||
nodes: Static<typeof T>[]
|
||||
}>()
|
||||
}
|
||||
{
|
||||
// issue: https://github.com/sinclairzx81/typebox/issues/336
|
||||
type JSONValue =
|
||||
| string
|
||||
| number
|
||||
| null
|
||||
| boolean
|
||||
| { [x: string]: JSONValue }
|
||||
| JSONValue[]
|
||||
const R = Type.Recursive((Node) =>
|
||||
Type.Union([
|
||||
Type.Null(),
|
||||
Type.String(),
|
||||
Type.Number(),
|
||||
Type.Boolean(),
|
||||
Type.Record(Type.String(), Node),
|
||||
Type.Array(Node),
|
||||
]),
|
||||
)
|
||||
Expect(R).ToStatic<JSONValue>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user