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
This is a design limitation. Our type inference algorithm allows inferences to flow left to right between separate arguments, but not between properties in an object literal. Effectively, we can make an inference for F because the arrow function specified for the arrange property doesn't depend on anything, but then when it comes time to assign types to the parameters of the arrow functions specified for act and assert, we have not yet made an inference for R and so we end up with {}. It works if you add a type annotation in the second arrow function because we can then make inferences for both F and R before assigning types to the parameters in the last arrow function:
functiontest(){test_driver({arrange: ()=>({foo: "foo"}),act: ({ foo }: {foo: string})=>({bar: foo+"bar"}),assert: ({ foo, bar })=>{// foo is "foo" and bar is "foobar" here}});}
Also, your example works with no type annotations if you convert arrange, act, and assert to distinct parameters and use distinct arguments in the call to test_driver.
Would be nice to do better, but it isn't a simple fix.
TypeScript Version: 3.1.0-rc.20180911
Search Terms:
TS2459
Code
... should be compiled with
--target es2017
because of theObject.assign(...)
statementExpected behavior:
Should compile without error
Actual behavior:
Playground Link: Demo on TypeScript Playground
The text was updated successfully, but these errors were encountered: