Interactive Learning Platform Nuxt layer

Isolated learning atmosphere · v4.x

← Back to writing
Step 3 of 7my-bad + template diagnostics

One Problems Drawer: Types, Lint, and Template Diagnostics

Bring type errors, ESLint, Vue compiler warnings, and Nuxt's own template diagnostics into one dev overlay, choose when type checking runs, and fix the three template mistakes Nuxt now catches.

Nuxt 4.6 brought my-bad error pages to development. Nuxt 4.7 makes the same badge collect every problem the app knows about.

What's new#

With my-bad v1 and vite-plugin-checker v1, the badge in the corner of the page collects:

  • type errors, when typescript.typeCheck is on;
  • any checker you add to Vite, such as ESLint;
  • Vue compiler warnings that used to be lost in the terminal;
  • Nuxt's own warnings from scanning the app, such as duplicate component names or conflicting imports.

Each source becomes a problem set. The badge sums them in one pill. Click it and you get a drawer beside the page, grouped by source, with source snippets, rule docs, and a button to open each one in your editor.

Why you'd care#

I used to run three terminals: dev server, vue-tsc --watch, ESLint. The feedback existed; it just lived somewhere other than the page I was looking at.

The drawer closes that gap. A type error in a composable, a lint warning in a script block, and a Vue compiler warning about a bad prop all show up where the mistake is visible. The DevTools v4 Problems panel shows the same list if you prefer the dock.

Choose when type checking runs#

Type checking in development used to mean type checking in production builds too. Now you choose:

nuxt.config.ts
export default defineNuxtConfig({
  typescript: {
    typeCheck: 'dev', // `true`, 'build' or 'dev'
  },
});

If you already run nuxt typecheck in CI, 'dev' is the right default: fast feedback while you work, a fast production build.

Template diagnostics#

The Vue compiler cannot know about your pages or your server components. Nuxt can. So 4.7 checks templates for mistakes that only make sense with that knowledge:

  • a <NuxtLink> whose static to does not match any page (NUXT_B4025);
  • v-on or v-model on a server component, which cannot work (NUXT_B3014);
  • a function or class instance passed as a prop to a server component (NUXT_B3015).

In development these also show up on every open page as a problem set until you fix them. They are on by default. Turn them off with experimental.templateDiagnostics: false if you need quiet, but I would leave them on. A dead link in a template is exactly the kind of thing that survives to production because no one clicks it in review.

Before#

A broken link is a 404 waiting for a user. v-model on a server component fails at runtime, if it fails at all. A function passed as a prop to a server component serializes to undefined and the bug appears in a child component.

After#

The dev overlay names the link, the component, and the rule. You fix it before the commit.

app/pages/index.vue
<!-- NUXT_B4025: no page matches /pricing -->
<NuxtLink to="/pricing">Pricing</NuxtLink>

<!-- NUXT_B3014: v-model cannot bind to a server component -->
<ServerCounter v-model="count" />

Do it yourself#

  1. Enable typescript.typeCheck: 'dev'.
  2. Add an ESLint checker to Vite if you use ESLint.
  3. Break a type on purpose. The badge should count it.
  4. Add a <NuxtLink to="/does-not-exist">. The badge should count a NUXT_B4025.
  5. Click the badge. Open the problem in your editor.
  6. Fix both. The badge should return to zero.

Gotchas#

  • Template diagnostics can be noisy on a large migration. Fix the real links first; use the external prop for routes that are not pages, files in public/, or other sites.
  • typeCheck: 'dev' is not a CI replacement. Keep nuxt typecheck in CI. The dev overlay is for the loop, not the gate.
  • A problem set is not a build failure. The dev overlay collects; it does not necessarily fail the build. Check your CI separately.
  • The drawer is development only. Production users see your error page, not your type errors.
  • DevTools v4 is a separate install now. Nuxt no longer depends on @nuxt/devtools. Add it or click the button nuxt dev shows you.
  • The badge is a summary, not a queue. Fix the source, not the symptom. A silenced warning is still a warning.

Recap#

One badge, one drawer: types, lint, Vue compiler warnings, and Nuxt's own template diagnostics. Choose typeCheck: 'dev', leave template diagnostics on, and fix the link before it becomes a 404.

Next: Server-Side Error Boundaries.