Astro

Astro.check

Astro.check is shorthand for the astro check command, which type-checks .astro files and reports errors without building. It catches wrong props and missing imports before deploy.

How it is measured

Install @astrojs/check and typescript, then run astro check. It reads the frontmatter, the template expressions, and the TypeScript files and prints each error with a file and line. A nonzero exit code means errors remain.

Treat the exit code as the metric. Zero errors and zero warnings is the target. Count of hints is optional. Run it in CI so the same check runs on every pull request.

Worked example

A newsletter site renames a prop from date to publishedAt in PostMeta.astro. The build still passes because Astro does not fail on a missing prop at runtime. astro check reports 6 errors in 6 files that still pass date.

Without the check, 6 pages ship with an empty date line. A reader emails the editor three days later.

How it differs

Astro.check validates types and syntax without producing output. The astro build command compiles pages and writes dist. Check can pass while the build fails on a missing file; the build can pass while check lists errors.

Common errors

Assuming a passing dev server means no type errors. Skipping the check in CI. Not installing typescript, so the command refuses to run. Silencing errors with any. Running check only on changed files and missing a break elsewhere.

In practice

Add astro check to the script that runs before commit and before deploy. Fix errors in the order the output lists them, since one bad import can produce a dozen follow-ups. Keep the count at zero rather than tolerating a few.

See also

Astro, astro.config

Sources

Count this on a real site.

Watch my website