Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

typecheck.mjs

28 lines1.1 KB

1// Type-check this Angular example, including template type-checking.
2//
3// Angular template type-checking (`strictTemplates`) requires the Angular
4// compiler (`ngc`), not plain `tsc`. `ngc` ships in `@angular/compiler-cli`,
5// which is a *peer* dependency of `@angular/build` (a direct devDependency of
6// this example). We resolve it from there instead of declaring it directly so
7// CI's frozen lockfile install stays unchanged.
8import { createRequire } from 'node:module'
9import { spawnSync } from 'node:child_process'
10import { dirname, join } from 'node:path'
11​
12const require = createRequire(import.meta.url)
13​
14// `@angular/compiler-cli` is resolvable from `@angular/build`'s location.
15const buildPkg = require.resolve('@angular/build/package.json')
16const cliPkgPath = require.resolve('@angular/compiler-cli/package.json', {
17 paths: [buildPkg],
18})
19const cliPkg = require(cliPkgPath)
20const ngc = join(dirname(cliPkgPath), cliPkg.bin.ngc)
21​
22const { status } = spawnSync(
23 process.execPath,
24 [ngc, '-p', 'tsconfig.app.json', '--noEmit'],
25 { stdio: 'inherit' },
27​
28process.exit(status ?? 1)