When I do pnpm run build I got this error:
✓ Compiled successfullyLinting and checking validity of types ..Failed to compile. .next/types/app/components/button/addNew/page.ts:
Type error: Type 'OmitWithTag<ButtonProps, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'.Property 'onClick' is incompatible with index signature.Type 'MouseEventHandler<HTMLButtonElement>' is not assignable to type 'never'.
// Check the prop type of the entry function
28 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()| ^29 |30 | // Check the arguments and return type of the generateMetadata function31 | if ('generateMetadata' in entry) { ELIFECYCLE Command failed with exit code 1.
my component page.tsx looks like this and is working well:
interface ButtonProps {onClick: React.MouseEventHandler<HTMLButtonElement>;}
export default function NewTaskButton({ onClick }: ButtonProps) {
return (
<div>
<buttonclassName="btn btn-accent btn-circle font-extrabold text-xl w-15 h-15"onClick={onClick}>+</button>
</div>);}
My tsconfig is this:
{ "compilerOptions": { "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "plugins": [ { "name": "next" } ], "paths": { "@/*": [ "./src/*" ] } }, "exclude": [ "node_modules" ], "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts" ] }
and if I go to .next folder “/src/app/components/button/addNew/page.ts” there is a error on this line
// Check the prop type of the entry function
checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
I tried delete typescript cache, reinstalling node_modules, deleting .next folder, moving the interface to another file and then import, I also tried to use type any.