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
//Fails to Compile!
/*
error TS2322: Type '[(component: ProxyComponent) => void, (component: ProxyComponent) => void]' is not assignable to type '[(component: ProxyComponent) => void]'.
Types of property 'length' are incompatible.
Type '2' is not assignable to type '1'.
*/
let userStory1: UserStory = {
setup: () => [(component) => component.simulate(), (component) => component.simulate()]
}
I tried multiple things:
Creating a Type for the closure and using it as the type of the setup property but that gives the same error. like type SetupStatement = () => [(component: ProxyComponent) => void]; but that didn't work either.
Declaring the value of the setup method.
Expected behavior:
Code should compile correctly because the return types of the array match. It works perfectly for a single element but fails for multiple elements.
Actual behavior:
Compilation fails with the following error
error TS2322: Type '[(component: ProxyComponent) => void, (component: ProxyComponent) => void]' is not assignable to type '[(component: ProxyComponent) => void]'.
Types of property 'length' are incompatible.
Type '2' is not assignable to type '1'.
Activity
j-oliveras commentedon Dec 17, 2018
In:
you declares a setup method that return a tuple with only one element.
If you want an array without limits declare it as:
salmankhann commentedon Dec 17, 2018
Oops didn't know that that was the tuple syntax! There could be better error message from the compiler though.
Thanks for helping!