Search documentation

Search all pages, headings and text, in the current package or topic or in all documentation.

Getting started

Take over typescript-config in a new or an existing repository, extend a preset, and run the first type-check.

@workspace/typescript-config 1.0.0Developmentunreleased, maintained in Foundation as a copy

These steps were carried out in a new, empty pnpm workspace outside every source repository, with a copy of the package folder and nothing else: no path to Foundation and no other source.

A new repository#

  1. Copy the package#

    Take the folder packages/typescript-config from Foundation as a whole, without node_modules, and place it unchanged at packages/typescript-config in your repository. Keep its bytes exact:

    Text
    # .gitattributespackages/** -text

    Then check that your copy equals the source, file by file:

    Terminal
    diff -rq -x node_modules -x .turbo <foundation>/packages/typescript-config packages/typescript-config

    No output means equal. Record where the copy came from (see Development basis).

  2. Declare and install#

    Declare the package once, at the root, and install TypeScript in each package or app that type-checks, with the type packages its preset needs:

    JSON
    {  "devDependencies": {    "@workspace/typescript-config": "workspace:*"  }}
    JSON
    {  "devDependencies": {    "@types/node": "^26",    "typescript": "^6.0.3"  }}
    PresetYour package or app also needs
    nodejs.json@types/node
    react-library.json@types/react (and react), for JSX
    nextjs.jsonnext, react, @types/react, and Next's next-env.d.ts
    Terminal
    pnpm install
  3. Extend a preset#

    In each package or app, a tsconfig.json that extends the preset for its kind of code (Presets) and names its own files:

    JSON
    {  "extends": "@workspace/typescript-config/nodejs.json",  "include": ["src"],  "exclude": ["node_modules", "dist"]}
  4. Type-check#

    JSON
    {  "scripts": {    "typecheck": "tsc --noEmit"  }}
    Terminal
    pnpm --filter <package> typecheck

    tsc exits with 0 and no output when the types are correct, and with 2 and a list of errors when they are not. Unlike lint, there is no threshold: one type error fails the run.

An existing repository#

Your repositoryWhat to do
has no packages/typescript-configthe steps above
has a copy at packages/typescript-config from another sourcecompare it with diff -rq, then replace the whole folder by Foundation's copy, never single files, and update your record of where it came from
has its own tsconfig settings, without this packageextend a preset and remove every setting the preset already carries; keep only include, exclude, output, paths, types and plugins (Extending)

After switching, run the type-check of every package and app. The shared base is strict: noUncheckedIndexedAccess in particular reports index access that a looser configuration accepted. Those errors are work of your repository; they are not solved by relaxing the option.

Updating#

There is no transfer tooling for this package. When Foundation has a new state, replace the whole folder in one go, compare it with diff -rq, read the changelog, and run your type-checks. Your copy is never edited in place: a change you need is made in Foundation and reaches you with the next copy.

This page as Markdown