Skip to content

Commit

Permalink
fix(types): use Simplify in TIntersect for better type readability
Browse files Browse the repository at this point in the history
The intersection object types is lazily resolved by TypeScript until the type is mapped and intersected with an empty object, I guess. Not really sure why it works that way, but doing this leads to a nicer DX (screenshots included in the PR).
  • Loading branch information
aleclarson committed Mar 10, 2024
1 parent abe71c6 commit 93333c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/type/intersect/intersect-type.ts
Expand Up @@ -30,6 +30,8 @@ import type { TSchema, SchemaOptions } from '../schema/index'
import type { Static } from '../static/index'
import { Kind } from '../symbols/index'

type Simplify<T> = {} & { [P in keyof T]: T[P] }

// ------------------------------------------------------------------
// IntersectStatic
// ------------------------------------------------------------------
Expand All @@ -50,7 +52,7 @@ export interface IntersectOptions extends SchemaOptions {
// prettier-ignore
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
[Kind]: 'Intersect'
static: TIntersectStatic<T, this['params']>
static: Simplify<TIntersectStatic<T, this['params']>>
type?: 'object'
allOf: [...T]
}

0 comments on commit 93333c7

Please sign in to comment.