property
BuildConfig.check
check?: boolean
Type check the entrypoints and everything they import, like bun check. Equivalent to --check in the CLI.
A type error fails the build like any other build error: nothing is written, and each error is a BuildMessage whose message starts with TypeScript's error code.
The compiler options come from the tsconfig.json of the project, or from the file that tsconfig names. The check also uses the conditions and the loader of the build.
const result = await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
check: true,
throw: false,
});
for (const log of result.logs) {
// TS2322: Type 'string' is not assignable to type 'number'.
console.error(`${log.position?.file}:${log.position?.line}: ${log.message}`);
}