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
constarray1=[{a: 'a',b: 'b'},{a: 'a',c: 'c'},]// inferred: Partial<{ a, b, c }>[]array1.map(({ c })=>c);// works ✅constarray2=[{a: 'a',b: 'b'},{a: 'a', ...{c: 'c'}},]array2.map(({ c })=>c);// suddenly error? ❌
Expected behavior:
I'm not sure if this is a bug but I expect both map calls to type-check identically. If it's not a bug, it's very unintuitive why the spread syntax completely changes how the array type is inferred. The only workaround I have is to explicitly write the full type (which isn't as concise as the example above).
The text was updated successfully, but these errors were encountered:
Is the special logic documented somewhere? It would help avoid surprises and confusion if the logic is more explicitly defined, or if there are ways to control the inference.
TypeScript Version: 3.3.3333
Search Terms:
Code
Playground: http://tinyurl.com/y65n9b3o
Expected behavior:
I'm not sure if this is a bug but I expect both map calls to type-check identically. If it's not a bug, it's very unintuitive why the spread syntax completely changes how the array type is inferred. The only workaround I have is to explicitly write the full type (which isn't as concise as the example above).
The text was updated successfully, but these errors were encountered: