Closed
Description
Hello and good job on the mapped types!
Though it seems recursive mapped types didn't get as much love.
Is there any way to write the signature of update
so that the following can be true?
I run into either too permissive behaviors (I can add keys that are not in the original object, or set a non nullable key to undefined) or inferFromTypes: Maximum call stack size exceeded.
/*
* SHOULD COMPILE
*/
update({ a: 33 }, { a: 44 })
type A = { a?: number }
update({ a: 33 } as A, { a: undefined })
update(
{ a: { b: [1] }, c: 33, d: '44' },
{ a: { b: [1, 2] }, d: '66' }
)
/*
* SHOULD NOT COMPILE
*/
update({ a: 33 }, { a: undefined })
update({ a: 33 }, { b: 44 })
update({ a: 33 }, { a: '33' })
update({ a: { b: [1] } }, { a: { b: ['2'] } })