ianstormtaylor / superstruct

A simple and composable way to validate data in JavaScript (and TypeScript).

Home Page:https://docs.superstructjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mixing `partial` and `type` negates effects of `partial`

hgezim opened this issue · comments

Seems to me this test should work:

import { partial, string, number, type } from '../../../src'

export const Struct = partial(type({
  name: string(),
  age: number(),
}))

export const data = {
  name: 'john',
  c: 'doe'
}

export const output = {
  name: 'john',
  c: 'doe'
}

But it throws:

 1) superstruct
       validation
         partial
           valid-partial-type:
     Error: Expected "valid-partial-type" fixture not to throw an error but it did:

StructError: At path: c -- Expected a value of type `never`, but received: `"doe"`
      at Context.<anonymous> (test/index.ts:64:23)
      at processImmediate (node:internal/timers:476:21)

Already reported here: #829

This has been resolved in #1149