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
The Type PlainObject, which is used as type constrain for functions like merge does not accept interfaces.
typeR=Record<PropertyKey,unknown>;// same as PlainObject, but its not exported. So lets rebuild it heretypeFoo={a: number;b: number;};interfaceBoo{a: number;b: number;}functionf<xextendsR>(x: x): void{/* NOP */}f<Foo>({a: 1,b: 1});// This is OKf<Boo>({a: 1,b: 1});// This fails and requires a symbol and a string key/*Type 'Boo' does not satisfy the constraint 'R'. Index signature for type 'string' is missing in type 'Boo'.ts(2344)*/
Making use of Record<PropertyKey, any> fixes it. And will be released shortly (bc9aeec). The tradeoff is that now other objects like Date, RegEx also can be passed into the function. I think this is better then dealing with TS when using interfaces.
The Type
PlainObject
, which is used as type constrain for functions likemerge
does not accept interfaces.TS Playground: https://www.typescriptlang.org/play?ts=4.8.4#code/C4TwDgpgBASlC8sIGMD2AnAJgHgArtUnVAGkIQAaKAVwDsBrW1Ad1oD4BuKAem6gGcAhgFtog-lFwAbQQEtaAeQBGAKxTAqS6sCizgEpjogAPMBmARMAOigBlVFCkR9UdBC2ypmXToAWENwBYAChQSCgAMVQHRABvEKgoQQAuKFpqYSUAjgSoJVT0zOyQgF8c4PkLdAAzQWRoACFoqHjgxJS0jKz0csT8zqKe0pCQ6rpkYFlUWihq7GMoEwtaTAkYNgAKY1TjAEpUgDdUWW9WxO4AKigAOQVcKAvuYeDR7CjUTdik1IBGTV+oCVdlxeFAACq+WQSKFQBQkV5ND4bL4dP55AFAkF8CEw2qeCSCFauCAAR2osjcBIEIEyqCkSSJggEwHQ8gA5lB6OQgA
The text was updated successfully, but these errors were encountered: