@preact-labs/sfc-check
v0.2.0
Published
TypeScript type checker for Preact SFC single-file components
Keywords
Readme
@preact-labs/sfc-check
TypeScript type checker for Preact SFC single-file components.
Installation
pnpm add -D @preact-labs/sfc-checkUsage
npx sfc-check # nearest tsconfig.json
npx sfc-check -p app # app/tsconfig.json (file or directory)
npx sfc-check --tsc tsrs # run a specific native checkersfc-check uses the TypeScript version installed in your project:
- TypeScript 7+: runs
tsc --runExternalCode --noEmit -p <tsconfig>. SFCs are checked through@preact-labs/sfc-content-mapper, so register it undercontentMappersintsconfig.json.sfc-checkprints the entry to add when it's missing.--tsc <checker>runs another checker with the same arguments, for exampletsrs. The checker is resolved from the packages installed for the selected project, then fromPATH. TypeScript is also resolved from the selected project, so-p appusesapp's installation. - TypeScript 5/6: wraps TypeScript's compiler in a custom
CompilerHost. The host lowers each.sfc/.htmfile to the same typecheck module the content mapper produces, and reports diagnostics at their original positions.
Both modes report SFC syntax errors as sfc<code> (for example sfc1002 for an unclosed {#if}) and exit with a non-zero status when there are errors.
