How to set up a typescript workspace

A TypeScript workspace should be boring to set up and hard to outgrow. If the setup takes longer than twenty minutes, you are configuring for a project you do not have yet. The five steps below produce something small, strict, and easy to extend later.

Step one: pin the runtime

Install Node through a version manager instead of a system installer, then record the version inside the repository. A pinned runtime prevents the familiar failure where a project works on your machine and nowhere else.

  • One runtime version per project, written down.
  • No global TypeScript install; keep the compiler as a project dependency.
  • Commands stored in the package scripts so nobody has to memorise flags.

Step two: let the tools write the config

Initialise the project, add TypeScript as a development dependency, then generate a starter configuration with the compiler itself. Edit the generated file; do not paste a stranger’s version over it.

  • Turn on strict, including the null checks.
  • Point the compiler at your source directory.
  • Decide whether output is written to disk or handled by another tool.

Every option you keep should be one you can explain in a sentence. Anything else is a setting waiting to surprise you.

Step three: an editor setup you can explain

Choose an editor with TypeScript support built in, then make it use the project’s compiler version rather than its own. That single setting removes most “it works in the terminal” confusion.

Add formatting on save and one error-checking extension. A folder full of extensions is not a workspace; it is a collection, and each one adds a failure mode you did not ask for.

Step four: a layout that survives growth

Start with source, tests, and one entry file. Add directories when a second file demands one, not in anticipation of files that may never appear.

  • Types live beside the code that owns them.
  • A shared types file appears only when two modules need the same shape.
  • Scripts and configuration stay at the root, out of the source tree.

Naming the source folder src is fine. Src, lib, and app in the same project is a sign that two people had two opinions and neither was written down.

Keep the folder names boring and consistent across projects. Familiarity is worth more than a clever structure, because every unusual name becomes a small lookup you repeat for months.

Step five: prove it with a deliberate failure

Run the compiler in watch mode, introduce a type error on purpose, and confirm it reports. Fix it and confirm the report disappears. Two minutes of this catches a misconfigured editor, a stale watcher, or a config file that is silently not being read.

After that, leave the setup alone. The best sign that a workspace is right is that you stop thinking about it and start thinking about the data.