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
In our codebase, we have a pattern of doing return <>{props.children}</>, since returning props.children from function components causes TS errors when children is defined as React.ReactNode. We're trying to avoid using as any or similar. Example:
functionLoaderView<TextendsItemStoreObject>(props: LoaderViewProps<T>){useLazyLoad(props.loader);const{
renderError =renderNothing,
renderLoading =renderNothing,
loader,}=props;// The rule warns against all of these returns,// but we need them, otherwise we'll get a type error:// "Type '{} | null | undefined' is not assignable to type '...'."if(loader.data)return<>{props.render(loader.data)}</>;if(loader.isLoading)return<>{renderLoading()}</>;if(loader.error)return<>{renderError(loader.error)}</>;returnnull;}
It would be great if the rule could either not report on single interpolated values, or if there were a flag for this case
The text was updated successfully, but these errors were encountered:
It probably is. I guess by the time this issue would have been resolved, a fix might be in TS already, rendering the change useless. The issues to fix the TS bug just seem a little stalled on progress, is all. (DefinitelyTyped/DefinitelyTyped#20356, microsoft/TypeScript#29818)
I found another similar closed issue, but it reports different sorts of false positives than those I'm encountering.
In our codebase, we have a pattern of doing
return <>{props.children}</>
, since returningprops.children
from function components causes TS errors when children is defined asReact.ReactNode
. We're trying to avoid usingas any
or similar. Example:It would be great if the rule could either not report on single interpolated values, or if there were a flag for this case
The text was updated successfully, but these errors were encountered: