eps1lon / types-react-codemod

Collection of transforms for jscodeshift related to `@types/react`
MIT License
302 stars 10 forks source link

Codemod for implict return in `ref` #368

Closed eps1lon closed 4 months ago

eps1lon commented 4 months ago

We let a lot of implicit returns in ref slide through since you can return anything from functions that are asssignable to () => void in TypeScript. It should've always used the VOID_OR_UNDEFINED_ONLY type hack but it didn't. Now that refs are typed as () => void | (() => void), we start flagging the implicit returns.

It's probably safe to codemod all these implicit returns away. But just in case people already use the Canary feature, we make it opt-in in preset-19.