Back to home

Compile Error Root Cause

Explains why react-next-admin and common compile differently: same source, different ESLint config.

Compile Error Root Cause: react-next-admin vs common

Symptom

The same source file src/common/lib/table/DataTableProperty.ts produces two errors in react-next-admin during next build, while common compiles fine:

6:17   Error: 'PagerResult' is defined but never used.  @typescript-eslint/no-unused-vars
33:14  Error: The `{}` ("empty object") type allows any non-nullish value...

Root Cause

Key point: the file is identical in both projects — the difference is not in the code but in each project's ESLint config.

react-next-admin/package.json has a copy script that syncs common's shared directory into this project:

"copy": "cpy ./../common/src/common ./src/ --parents"

So react-next-admin/src/common is copied from common/src/common and the code is exactly the same. The error difference comes from the two projects using different ESLint presets:

Projecteslint.config.mjs extendsTS strict rules enabled
react-next-adminnext/core-web-vitals + next/typescriptYes
commonnextNo

next/typescript expands to plugin:@typescript-eslint/recommended, which turns on two rules matching the two errors:

  1. @typescript-eslint/no-unused-vars → PagerResult is imported but never used
  2. @typescript-eslint/ban-types → the empty object type {} in parent?: {}

common only extends next (without next/typescript), so these rules are never enabled and no error appears.

Relationship to Compilation

Both errors are ESLint rule errors, not TypeScript (tsc) type errors.

next build runs ESLint during the build phase; when a rule is at the error level, a lint failure aborts the build — which is why it surfaces as a "compile error". In other words:

  • The TypeScript type system does not consider either spot an error ({} is a legal type, and an unused named import does not affect type checking);
  • It is ESLint's static check that escalates them to error, which then blocks next build.

Fix Suggestions

  • Fix the source (recommended): remove the unused PagerResult import; change parent?: {} to parent?: object (or a more specific type).
  • Align the configs: make both projects use the same ESLint preset — either both extend next/typescript and fix the source, or explicitly disable these two rules on the common side.

Note: react-next-admin/src/common is a copy artifact; editing it directly will be overwritten on the next npm run copy. The correct place to fix is common/src/common (the source), then run the copy to sync.