ngtrue
To true something is to bring it into exact alignment — a wheel, a door, a frame. That is the whole brief: every export here takes one claim an Angular library makes and checks it against what the library actually does.
Who it is for
People who ship Angular libraries. Not application developers — that distinction is the spine of the package rather than a marketing line, and it is what stops it drifting into a bag of utilities. The questions ngtrue answers are questions you only have when other people install your code:
- Is this control really wired to Signal Forms, or does it only look wired?
- Does any path of this component wait for a zone event a zoneless app never fires?
- Does the manifest describe the files the build actually produced?
- Will the types resolve for a consumer whose
tsconfig.jsonis not yours? - Will
ng addandng updateload the schematics you ship? - Can a test runner or a server import every entry point you ship?
Anything an application developer would reach for belongs somewhere else. There are already good answers to most of those, and none of them know what an entry point is.
The shape
One package, three entry points, split by the environment the code runs in — the same split @angular/core and @angular/core/testing make, for the same reason. The three entry points explains it, including the one rule the package is built around: no export may import another export.
import { assertNoZoneEventWaits, assertSignalFormsControl } from 'ngtrue/testing';
import {
angularPeerFloorsTooLow,
globalAttributeInputs,
peerDependencyMismatches,
unexportedTypes,
unloadableEntryPoints,
unloadableSchematics,
unresolvableTypes,
unresolvedExports,
} from 'ngtrue/node';What is here today
| Export | Entry point | Answers |
|---|---|---|
assertSignalFormsControl | ngtrue/testing | Is this custom control correctly wired to Signal Forms? |
assertNoZoneEventWaits | ngtrue/testing | Does it wait for a zone event a zoneless app never emits? |
unresolvedExports | ngtrue/node | Does every advertised subpath resolve to a file that exists? |
unresolvableTypes | ngtrue/node | Do the types resolve under node16 and under bundler? |
unexportedTypes | ngtrue/node | Can a consumer import every type a public signature names? |
peerDependencyMismatches | ngtrue/node | Does the manifest match what the source imports, both ways? |
unloadableSchematics | ngtrue/node | Can the CLI load every schematic and migration you ship? |
unloadableEntryPoints | ngtrue/node | Can a test runner or a server import every entry point? |
globalAttributeInputs | ngtrue/node | Does a static title meant for an input land on the host? |
angularPeerFloorsTooLow | ngtrue/node | Can every Angular the peer range admits link the build? |
The root entry point is empty. That is deliberate and is explained where it would otherwise look like an oversight.
Installing
npm install --save-dev ngtrueA dev dependency, always: nothing here belongs in a shipped bundle. @angular/core and @angular/forms are optional peers — ngtrue/testing needs them and ngtrue/node does not. So is typescript, which three functions use: unresolvableTypes and unexportedTypes to run the real module resolver and type checker rather than an imitation of them, and globalAttributeInputs to parse a built package's compiled declarations rather than match their text. So is @angular-devkit/schematics, which unloadableSchematics uses to load schematics with the devkit's own engine, and so is semver, which angularPeerFloorsTooLow uses to read the lowest version a peer range admits. unloadableEntryPoints needs none of them: the @angular/compiler it loads before each entry point is the one the checked package resolves, which an Angular library's own install already has.
What it will not do
Every export states what it cannot check, in its own documentation, next to what it can. That is not modesty. A check that would answer the same for a working library and a broken one is worse than no check, because it converts an unasked question into an answered one — and the answer is always yes. Where a rule cannot be verified honestly, ngtrue says so and leaves it to a reviewer, rather than shipping something that passes.