Skip to content

Commit

Permalink
partial: leverage last optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Dec 12, 2017
1 parent 2a84362 commit 37c74a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export const partial = <P extends Props>(
): PartialType<P, PartialOf<P>> => {
const partials: Props = {}
for (let k in props) {
partials[k] = union([props[k], undefinedType])
partials[k] = union([undefinedType, props[k]])
}
const partial = type(partials)
return new PartialType(
Expand Down
4 changes: 2 additions & 2 deletions test/partial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('partial', () => {
it('should fail validating an invalid value', () => {
const T = t.partial({ a: t.number })
assertFailure(t.validate({ a: 's' }, T), [
'Invalid value "s" supplied to : PartialType<{ a: number }>/a: (number | undefined)/0: number',
'Invalid value "s" supplied to : PartialType<{ a: number }>/a: (number | undefined)/1: undefined'
'Invalid value "s" supplied to : PartialType<{ a: number }>/a: (undefined | number)/0: undefined',
'Invalid value "s" supplied to : PartialType<{ a: number }>/a: (undefined | number)/1: number'
])
})

Expand Down

0 comments on commit 37c74a5

Please sign in to comment.