You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
)})})describe('optionalProperties',()=>{describe('object',()=>{test('top level',()=>{exactly(// TODO: this seems wrong{a: 1}as{a: number;b: never},optionalProperties({a: 1,b: undefined}),)})test('nested',()=>{exactly(// @ts-expect-error xfail TODO: figure out why exactly doesn't work on nested ToExactOptionalProperties types{a: {a: 1}}as{a: {a: number;b?: string}},optionalProperties({a: {a: 1,b: undefined},}),)})})test('array',()=>{exactly({a: [{a: 1}]}as{a: [{a: number;b?: string}]},// @ts-expect-error xfail TODO: figure out why exactly doesn't work on arrays in ToExactOptionalPropertiesoptionalProperties({a: [{a: 1,b: undefined}],}),)})describe('real world examples',()=>{interfaceExpected{a: numberb?: string}test('sanity check',()=>{optionalProperties({a: 1,b: ''})satisfiesExpected})test('positive',()=>{constactual={a: 1,b: Math.random()===1 ? '' : undefined}// @ts-expect-error sanity check. if this is no longer an error then exactOptionalPropertyTypes was probably turned offactualsatisfiesExpectedoptionalProperties(actual)satisfiesExpected})describe('negative',()=>{test('optional type is wrong',()=>{// @ts-expect-error type is wrongoptionalProperties({a: 1,b: true})satisfiesExpected})test('mandatory type is wrong',()=>{// @ts-expect-error type is wrongoptionalProperties({a: '',b: ''})satisfiesExpected})})})})
The text was updated successfully, but these errors were encountered:
https://api.github.com/DetachHead/ts-helpers/blob/6c4b860f5fda1f2e96a416e677cd60af2e216b97/test/functions/misc.spec.ts#L619
The text was updated successfully, but these errors were encountered: