The warning logic inconsistently handles default exports in TypeScript components.
The issue involves a TypeScript plugin warning that inconsistently appears for default exports in Next.js 'use client' components. The warning logic needs to be updated to handle default exports uniformly. The scope is somewhat clear, but IDE-specific behavior adds complexity.
https://codesandbox.io/p/sandbox/brave-northcutt-3h899t?file=%2Fapp%2Fpage.tsx%3A22%2C1
type myProps = {
myFunc: () => void;
};
const myComponent = ({ myFunc }: myProps) => {
myFunc();
return <></>;
};
export default myComponent;
export const myComponent2 = ({ myFunc }: myProps) => {
myFunc();
return <></>;
};
export function myComponent3({ myFunc }: myProps) {
myFunc();
return <></>;
}
only myComponent2 and myComponent3 show the warning.
Warning should also show for myComponent
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.0.0: Thu Aug 17 21:23:05 PDT 2023; root:xnu-10002.1.11~3/RELEASE_ARM64_T6000
Binaries:
Node: 20.3.1
npm: 10.1.0
Yarn: 1.22.19
pnpm: 8.7.4
Relevant Packages:
next: 13.4.19
eslint-config-next: 13.4.19
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: standalone
App Router
Code sandbox is a little redundant but see the components.tsx file inside app folder for the same code as above. The plugin code for this warning is here: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/typescript/rules/client-boundary.ts
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!