-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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'] } })
stepancar
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue