After forking the repo from GitHub and installing pnpm:
git clone https://github.com/<your-name-here>/ts-api-utils
cd ts-api-utils
pnpm installThis repository includes a list of suggested VS Code extensions. It's a good idea to use VS Code and accept its suggestion to install them, as they'll help with development.
Run tsdown locally to type check and build source files from src/ into output files in lib/:
pnpm buildAdd --watch to run it continuously in a terminal:
pnpm build --watchPrettier is used to format code. It should be applied automatically when you save files in VS Code or make a Git commit.
To manually reformat all files, you can run:
pnpm format --writeThis package includes several forms of linting to enforce consistent code quality and styling. Each should be shown in VS Code, and can be run manually on the command-line:
pnpm lint(ESLint with typescript-eslint): Lints JavaScript and TypeScript source filespnpm lint:docs(typedoc): Checks that all the code is documentedpnpm lint:knip(knip): Detects unused files, dependencies, and code exportspnpm lint:md(Markdownlint): Checks Markdown source filespnpm lint:packages(pnpm-deduplicate): Deduplicates packages in thepnpm-lock.ymlfilepnpm lint:spelling(cspell): Spell checks across all source files
Read the individual documentation for each linter to understand how it can be configured and used best.
For example, ESLint can be run with --fix to auto-fix some lint rule complaints:
pnpm run lint --fixVitest is used for tests. You can run it locally on the command-line:
pnpm run testAdd the --coverage flag to compute test coverage and place reports in the coverage/ directory:
pnpm run test --coverageNote that console-fail-test is enabled for all test runs.
Calls to console.log, console.warn, and other console methods will cause a test to fail.
This repository includes a VS Code launch configuration for debugging unit tests. To launch it, open a test file, then run Debug Current Test File from the VS Code Debug panel (or press F5).
You should be able to see suggestions from TypeScript in your editor for all open files.
However, it can be useful to run the TypeScript command-line (tsc) to type check all files in src/:
pnpm tscAdd --watch to keep the type checker running in a watch mode that updates the display as you save files:
pnpm tsc --watchYou can generate a TypeDoc documentation site with pnpm run docs.
Once you've generated the docs, you can view them by first running pnpm docs:serve, then browsing to http://127.0.0.1:8080 (or similar - check the console output of the last command).
Tip: Run
pnpm run docs --watchto keep the generated docs up-to-date as you save files.
Publishing will automatically happen when commits are pushed to the main branch. The documentation site will also be automatically updated immediately after each new release.