Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 2.46 KB

CONTRIBUTING.md

File metadata and controls

52 lines (40 loc) · 2.46 KB

Contributing to typescript-perf

Thanks for helping. typescript-perf makes claims about other people's code, so the bar is simple: every result must be backed by a measurement, and every format it reads must be tested against a real compiler output.

Setup

npm ci
npm run build
npm test                    # unit tests: parsers on real TS 5.9 / 6.0 / 7.0 outputs, stats, budget, JSON Schema, renderers
npm run test:integration    # the CLI on tests/fixtures with the real compilers (about 6 minutes)

The three compilers are dev dependencies (ts5, ts6, ts7), so the tests never depend on what is installed globally.

Layout

Path
src/parse.ts parsers for the compiler's text output (the contract with tsc)
src/measure.ts repeated runs, warm-up, build mode
src/trace.ts, src/stream-json.ts streaming trace and types parsing
src/findings.ts findings and their verification
src/why.ts trace analysis and proven patterns
src/report.ts, src/html.ts, src/markdown.ts terminal, HTML and Markdown output
schema/ the JSON Schema of --json
docs/patterns/ one page per finding and pattern
tests/fixtures/ small projects with known costs (node scripts/make-fixtures.mjs regenerates them)
tests/data/ real compiler outputs and reports (npm run outputs:capture regenerates them)

Adding a finding or a pattern

  1. Write a fixture in scripts/make-fixtures.mjs that has the problem, and keep it small.
  2. Detect it from compiler output (--extendedDiagnostics, --explainFiles, the trace), not from what the source looks like alone.
  3. If the fix can be applied without editing the user's files (a flag, a temporary tsconfig), verify it. Report it as verified only with a gain outside the noise and byte-identical diagnostics.
  4. Add an example in src/examples.ts, a page in docs/patterns/<id>.md, and the id to the JSON Schema.
  5. Add integration tests on TypeScript 5, 6 and 7.

When a new TypeScript version comes out

Add it as a dev dependency, add it to scripts/capture-outputs.mjs, run npm run outputs:capture, and run the tests. A failing parser test is a format change to handle, not a test to update blindly.

Pull requests

  • One topic per pull request, with tests.
  • Plain, factual wording in output and docs: say what was measured, how, and how sure it is.
  • No new runtime dependency without a strong reason. The CLI has one (@typescript/analyze-trace).