Skip to content

Commit 651ce29

Browse files
docs: replace npx advice and hardcoded versions with verified guidance
Two defects made the READMEs untrustworthy. The root package table carried a version column that goes stale at the next release, and the engine package warned that it was pre-1.0 at 4.0.0 while it ships 7.0.0. Both claims are removed rather than re-pinned. The quick starts recommended `npx` and `pnpm dlx`, which execute whatever the registry serves at that moment. A tool that audits what your package resolves should not itself float, so installs are now lockfile-pinned dev dependencies invoked through the package manager. A note records why. The engine snippets were also wrong about the API: `checkPackage` returns a lazy Effect, so `await` on it was a no-op, and the untyped result carries no `problems` array to iterate. Both are corrected against the published types. The CLI output sample in the root README was invented; it is now a captured run of the documented command
1 parent d1e227d commit 651ce29

3 files changed

Lines changed: 95 additions & 68 deletions

File tree

‎README.md‎

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
11
# are-the-types-wrong
22

3-
> Predictable TypeScript type definitions for npm packages: check entry points, module kinds, and export bindings across Node and bundler resolution modes before publishing.
3+
> Predictable TypeScript types for npm packages: check entry points, module kinds, and export bindings under every resolution mode Node and bundlers use, before you publish.
44
5-
An Effect-powered workspace and monorepo housing the core analysis engine and CLI for checking TypeScript types and packaging conventions in npm distributions.
5+
A workspace housing the analysis engine and the `attw` CLI behind [arethetypeswrong.github.io](https://arethetypeswrong.github.io).
66

77
## Packages
88

9-
| Package | Version | Description |
10-
| -------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------- |
11-
| [`@systemfsoftware/arethetypeswrong-cli`](packages/arethetypeswrong-cli) | `4.0.0` | Official CLI tool (`attw`) to check local tarballs, directories, or npm packages |
12-
| [`@systemfsoftware/arethetypeswrong`](packages/arethetypeswrong) | `7.0.0` | Programmatic analysis engine behind arethetypeswrong.github.io |
13-
| [`@systemfsoftware/arethetypeswrong-recipes`](packages/arethetypeswrong-recipes) | `0.1.0` | Problem-class recipes and fixture generation for attw tests |
9+
| Package | What it is |
10+
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
11+
| [`@systemfsoftware/arethetypeswrong-cli`](packages/arethetypeswrong-cli) | The `attw` command — checks a tarball, a directory, or a published package |
12+
| [`@systemfsoftware/arethetypeswrong`](packages/arethetypeswrong) | The analysis engine, as a library for your own tooling |
13+
| [`@systemfsoftware/arethetypeswrong-recipes`](packages/arethetypeswrong-recipes) | Synthetic packages, one per problem kind, that test the engine (not published) |
1414

15-
## Quick Start
15+
## Install
1616

17-
Check a package tarball or local directory without global installation:
17+
Add the CLI to the project you want to check, so your lockfile pins the version:
1818

1919
```bash
20-
npx @systemfsoftware/arethetypeswrong-cli --pack .
20+
pnpm add -D @systemfsoftware/arethetypeswrong-cli
2121
```
2222

23-
Or check an already-published npm package:
23+
> [!NOTE]
24+
> Prefer a lockfile-pinned install over `npx`. A tool whose job is auditing what your package resolves should not itself be resolved fresh from the registry on every run.
25+
26+
## Quick Start
27+
28+
Run the check from the package you want to audit. `--pack` runs `npm pack`, analyzes the resulting tarball, and deletes it:
2429

2530
```bash
26-
npx @systemfsoftware/arethetypeswrong-cli --from-npm @systemfsoftware/arethetypeswrong-cli
31+
pnpm exec attw --pack .
32+
```
33+
34+
A healthy package prints a row per entry point and a column per resolution mode:
35+
36+
```text
37+
No problems found.
38+
Entrypoint . ./package.json
39+
node10 ✔ ✔
40+
node16-cjs ✔ ✔
41+
node16-esm ✔ ✔
42+
bundler ✔ ✔
2743
```
2844

29-
To use the programmatic engine in a TypeScript or JavaScript project:
45+
Problems replace the `✔` with `✘` and are named above the table, so the exit code can gate CI. Use a [profile](packages/arethetypeswrong-cli/README.md#profiles) when your package deliberately supports only some resolution modes.
46+
47+
## Using the Engine
48+
49+
The engine is a library whose `checkPackage` returns a lazy Effect:
3050

3151
```bash
3252
pnpm add @systemfsoftware/arethetypeswrong
@@ -35,45 +55,36 @@ pnpm add @systemfsoftware/arethetypeswrong
3555
```ts
3656
import { checkPackage } from '@systemfsoftware/arethetypeswrong'
3757
import { createPackageFromTarballData } from '@systemfsoftware/npm-package'
58+
import { Effect } from 'effect'
3859
import { readFile } from 'node:fs/promises'
3960

4061
const tarball = await readFile('./my-package-1.0.0.tgz')
41-
const pkg = createPackageFromTarballData(tarball)
42-
const analysis = await checkPackage(pkg)
62+
const analysis = await Effect.runPromise(checkPackage(createPackageFromTarballData(tarball)))
63+
64+
// analysis.entrypoints — a resolution record per subpath
65+
// analysis.problems — what failed, with the position of the offending syntax
4366
```
4467

4568
## What it Checks
4669

47-
`are-the-types-wrong` simulates how Node and TypeScript resolve types and implementations under `node10`, `node16`, and `bundler` resolution modes:
48-
49-
- **Entry point resolution**: Verifies `exports`, `main`, `types`, and `bin` paths map to existing files.
50-
- **Module kind agreement**: Ensures dual-package files match their designated formats (`ESM` vs `CJS`).
51-
- **Export default & named export parity**: Detects mismatches between type definitions and JavaScript implementation exports.
52-
- **Unexpected module syntax**: Catches CJS constructs (`require`, `module.exports`) in ESM and ESM constructs (`import`, `export`) in CJS files.
53-
- **CJS-only default export**: Flags default exports that require `esModuleInterop` workarounds.
70+
The engine simulates how Node and TypeScript resolve each entry point under the `node10`, `node16`, and `bundler` modes:
5471

55-
## Output Matrix
56-
57-
When running `attw`, results are formatted as a compatibility matrix across resolution modes:
58-
59-
```text
60-
┌───────────────────┬──────────────────────┬──────────────────────┬─────────┐
61-
│ Entrypoint │ node10 │ node16 (node) │ bundler │
62-
├───────────────────┼──────────────────────┼──────────────────────┼─────────┤
63-
│ . │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │
64-
│ ./utils │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │
65-
└───────────────────┴──────────────────────┴──────────────────────┴─────────┘
66-
```
72+
- **Entry point resolution** — do `exports`, `main`, `types`, and `bin` targets resolve to files that exist?
73+
- **Module kind agreement** — does a file's actual format (ESM, CJS, JSON) match what `type` and its extension imply?
74+
- **Export parity** — do default and named exports line up between the type entry point and the implementation?
75+
- **Unexpected module syntax** — `require`/`module.exports` inside an ESM file, or `import`/`export` inside a CJS file.
76+
- **CJS-only default export** — a CommonJS file whose only export is a default, which `esModuleInterop` consumers receive wrapped.
77+
- **Internal resolution errors** — TypeScript's own resolution failures, reported with the failing specifier and mode.
6778

6879
## Documentation
6980

70-
- [CLI Documentation & Options](packages/arethetypeswrong-cli/README.md)
71-
- [Core Engine API Reference](packages/arethetypeswrong/README.md)
72-
- [Explanation of Problem Kinds](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md)
81+
- [CLI options, config file, and profiles](packages/arethetypeswrong-cli/README.md)
82+
- [Engine API reference](packages/arethetypeswrong/README.md)
83+
- [What each problem kind means](https://github.com/arethetypeswrong/arethetypeswrong.github.io/tree/main/docs/problems)
7384

7485
## Contributing
7586

76-
Development setup, test execution, and CI workflow details: [CONTRIBUTING.md](CONTRIBUTING.md).
87+
Development setup, build, and test workflow: [CONTRIBUTING.md](CONTRIBUTING.md).
7788

7889
## License
7990

‎packages/arethetypeswrong-cli/README.md‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# arethetypeswrong/cli
1+
# @systemfsoftware/arethetypeswrong-cli
22

33
A CLI for [arethetypeswrong.github.io](https://arethetypeswrong.github.io/).
44

@@ -19,15 +19,26 @@ This project attempts to analyze npm package contents for issues with their Type
1919

2020
## Installation
2121

22+
Add it to the project you want to check, so your lockfile pins the version:
23+
2224
```shell
23-
npm i -g @systemfsoftware/arethetypeswrong-cli
25+
pnpm add -D @systemfsoftware/arethetypeswrong-cli
26+
```
27+
28+
Then run it through your package manager:
29+
30+
```shell
31+
pnpm exec attw --pack .
2432
```
2533

26-
<!-- Or, using `npx`: -->
27-
<!---->
28-
<!-- ```shell -->
29-
<!-- npx attw -->
30-
<!-- ``` -->
34+
> [!NOTE]
35+
> Prefer a lockfile-pinned install over `npx`. A tool that audits what your package resolves should not itself be resolved fresh from the registry on each run.
36+
37+
To use `attw` outside any project, install it globally:
38+
39+
```shell
40+
npm i -g @systemfsoftware/arethetypeswrong-cli
41+
```
3142

3243
## Usage
3344

@@ -54,16 +65,16 @@ or check a package from npm:
5465
attw --from-npm @systemfsoftware/arethetypeswrong-cli
5566
```
5667

57-
You can also use `attw` without installing globally by using `npx`. Pack one in-place by specifying `--pack` and a directory:
68+
Installed as a dev dependency (see [Installation](#installation)), invoke it through your package manager so the pinned version runs:
5869

59-
```
60-
npx --yes @systemfsoftware/arethetypeswrong-cli --pack .
70+
```shell
71+
pnpm exec attw --pack .
6172
```
6273

6374
or check a package from npm:
6475

65-
```
66-
npx --yes @systemfsoftware/arethetypeswrong-cli --from-npm @systemfsoftware/arethetypeswrong-cli
76+
```shell
77+
pnpm exec attw --from-npm @systemfsoftware/arethetypeswrong-cli
6778
```
6879

6980
## Configuration

‎packages/arethetypeswrong/README.md‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
55
Analyzes a package tarball the way Node and TypeScript will actually resolve it: entry-point discovery from `package.json` (`main`, `exports`, `bin`), per-entry `commonjs` / `ESM` resolution, and export-shape checks. Use it to catch publish-time mistakes locally instead of after `npm publish`.
66

7-
> [!WARNING]
8-
> This package is pre-1.0 (`4.0.0` under `v0` semver). Patch and minor releases may change the public API. Pin the version in production.
9-
107
## What it does
118

129
A single `checkPackage` call returns a structured analysis or a set of diagnostics. Each entry point is checked under every relevant resolution kind:
@@ -39,6 +36,7 @@ Check an in-memory package:
3936
```ts
4037
import { checkPackage } from '@systemfsoftware/arethetypeswrong'
4138
import { createPackage } from '@systemfsoftware/npm-package'
39+
import { Effect } from 'effect'
4240

4341
const pkg = createPackage(
4442
{
@@ -50,15 +48,16 @@ const pkg = createPackage(
5048
'1.0.0',
5149
)
5250

53-
const result = await checkPackage(pkg)
51+
const result = await Effect.runPromise(checkPackage(pkg))
5452

5553
if ('entrypoints' in result) {
56-
console.log(Object.keys(result.entrypoints))
57-
// e.g. [ ".", "./utils", "./features/*.js" ]
58-
} else {
54+
console.log(Object.keys(result.entrypoints)) // [ "." ]
5955
for (const problem of result.problems) {
60-
console.error(problem.kind, problem.entrypoint, problem.pos)
56+
console.error(problem.kind, problem.entrypoint)
6157
}
58+
} else {
59+
// result.types === false — the package ships no type declarations
60+
console.error('no types found')
6261
}
6362
```
6463

@@ -85,30 +84,36 @@ Check a real tarball on disk:
8584
```ts
8685
import { checkPackage } from '@systemfsoftware/arethetypeswrong'
8786
import { createPackageFromTarballData } from '@systemfsoftware/npm-package'
87+
import { Effect } from 'effect'
8888
import { readFile } from 'node:fs/promises'
8989

9090
const data = await readFile('./my-package-1.2.3.tgz')
91-
const pkg = createPackageFromTarballData(data)
92-
const analysis = await checkPackage(pkg)
93-
// `analysis` is `Analysis` with `entrypoints` or `problems`
91+
const analysis = await Effect.runPromise(checkPackage(createPackageFromTarballData(data)))
92+
// `analysis` is an `Analysis` (entrypoints + problems) or an `UntypedResult`
9493
```
9594

9695
Filter entry points:
9796

9897
```ts
99-
const result = await checkPackage(pkg, {
100-
includeEntrypoints: ['./utils'],
101-
excludeEntrypoints: [/^.\/internal\//],
102-
entrypoints: ['.', './cli'], // exhaustive override
103-
})
98+
const result = await Effect.runPromise(
99+
checkPackage(pkg, {
100+
includeEntrypoints: ['./utils'],
101+
excludeEntrypoints: [/^.\/internal\//],
102+
entrypoints: ['.', './cli'], // exhaustive override
103+
}),
104+
)
104105
```
105106

106-
Prefer the CLI for one-off checks:
107+
Prefer the CLI for one-off checks. Add it to the project so your lockfile pins it, then run it through your package manager:
107108

108109
```bash
109-
pnpm dlx @systemfsoftware/arethetypeswrong-cli ./my-package-1.2.3.tgz
110+
pnpm add -D @systemfsoftware/arethetypeswrong-cli
111+
pnpm exec attw ./my-package-1.2.3.tgz
110112
```
111113

114+
Its flags and profiles are documented in the
115+
[CLI package](https://github.com/systemfsoftware/are-the-types-wrong/tree/main/packages/arethetypeswrong-cli).
116+
112117
## Checks
113118

114119
| Check | What it reports |

0 commit comments

Comments
 (0)