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 inferred type is any because that's what stateMap returns, but really we know for this specific case it's string[] | undefined (or string[] when you have done an isStatusCode() check first.)
This requires consumers to look into our actual implementation code to determine the data types returned from decorator state methods, which is a bit time consuming and annoying. It also means that breaks could easily occur as we're not enforcing a public contract but relying on casting from any.
I agree this has been annoying consuming the decorator helpers and I have been trying to update as I use them. I would be fine having the type enforced for exported functions.
Applicable ESLint rules:
Basically, consider a decorator helper like:
The inferred type is
any
because that's whatstateMap
returns, but really we know for this specific case it'sstring[] | undefined
(orstring[]
when you have done an isStatusCode() check first.)This requires consumers to look into our actual implementation code to determine the data types returned from decorator state methods, which is a bit time consuming and annoying. It also means that breaks could easily occur as we're not enforcing a public contract but relying on casting from
any
.Consider the alternative:
Now a consumer knows exactly what they're going to get and they never have to worry about the
undefined
case.The text was updated successfully, but these errors were encountered: