| |

TypeScript 2 ๐Ÿ”ท Setting Up the Development Environment

Before writing any TypeScript, you need a working environment โ€” Node.js, npm, the TypeScript compiler, and a code editor that understands the language. This is a one-time investment, but it’s the foundation everything else builds on. Get it right and every subsequent step is smooth; get it wrong and you’ll spend hours chasing phantom errors that have nothing to do with your code.

Key point: TypeScript’s environment has three layers โ€” Node.js (the runtime that runs the tooling), the TypeScript compiler (which turns .ts into .js), and your editor (which surfaces errors as you type). All three need to be set up correctly. The compiler is what actually checks your types; the editor is just a convenient window into the same checks.


What you need

Four pieces, working together:

  • Node.js โ€” the JavaScript runtime that runs the compiler, the package manager, and eventually your emitted JavaScript
  • npm โ€” Node’s package manager; it installs TypeScript and every project dependency
  • TypeScript โ€” the compiler itself, installed either globally or locally
  • An editor โ€” VS Code is the standard choice, but any editor with TypeScript support works

You’ll also want a terminal โ€” VS Code’s built-in terminal, iTerm, Windows Terminal, or whatever shell you prefer. The commands below work in bash, zsh, PowerShell, and cmd with minor path differences.

The chain is:

Node.js  โ†’  npm  โ†’  typescript (tsc)  โ†’  your project

Each layer depends on the one above. Node brings npm. npm installs TypeScript. TypeScript compiles your code.

Why Node first: Node is the foundation for everything. Even if your TypeScript runs in the browser, the tooling runs on Node. The compiler, the build tools, the test runner โ€” all Node programs. Install it first, and the rest follows.


Step 1 โ€” Install Node.js

Download the LTS (Long-Term Support) version from https://nodejs.org/. LTS is the recommended track โ€” stable, supported for years, and matched to what the ecosystem expects.

What gets installed:

  • node โ€” the runtime
  • npm โ€” the package manager

Verify:

node --version
npm --version

Both should print version numbers. If you see command not found, the installer’s PATH additions didn’t take โ€” restart your terminal, or log out and back in.

Current minimum: TypeScript 5.x works on Node 14 and later. For new projects, use the current LTS โ€” usually Node 20 or 22.

Version managers: If you work on multiple projects that need different Node versions, install a version manager.

  • macOS/Linux: nvm โ€” curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
  • Windows: nvm-windows โ€” a separate project with a similar interface

With nvm, you can switch versions per project:

nvm install 20
nvm use 20

Why LTS and not Current: The “Current” version has the newest features but is more likely to break tooling. LTS versions are tested against the entire ecosystem โ€” the compiler, package managers, frameworks. For development work, LTS is almost always the right choice.


Step 2 โ€” Decide: global or local TypeScript

TypeScript can be installed globally (available everywhere on your machine) or locally (per-project, in node_modules).

Global install:

npm install -g typescript

Use tsc from any directory:

tsc --version

Local install (recommended for projects):

npm install --save-dev typescript

Then run through npx or npm scripts:

npx tsc --version

Which to choose:

ApproachBest for
GlobalLearning, quick scripts, one-off compilations
LocalEvery real project โ€” pinned versions, reproducible builds

Why local is preferred: Different projects may need different TypeScript versions. A project on TS 4.9 may not compile correctly with TS 5.4. Installing locally pins the version in package.json, so every developer and every CI run gets the same compiler. Global installs are convenient for learning but cause version drift in real projects.

Do both if you like: Install globally for one-off experiments, and install locally in every project for reproducible builds. They don’t conflict โ€” inside a project, npx tsc uses the local version; outside, tsc uses the global one.

Why the shift to local matters: Before npm made this trivial, every language had a “system compiler” problem โ€” one version for all projects, breaking when projects needed different versions. Node’s solution โ€” per-project node_modules โ€” solves it. The same pattern applies to TypeScript, ESLint, and every other tool.


Step 3 โ€” Verify the compiler

If installed globally:

tsc --version

If installed locally:

npx tsc --version

Both print something like:

Version 5.4.5

If you see a version, the compiler is ready. If you see command not found or npx: command not found, the install didn’t complete โ€” reinstall and check the PATH.

Check what the compiler can do:

tsc --help

Prints a list of flags. The most useful ones:

FlagPurpose
--initCreate a tsconfig.json
--watchRecompile on file change
--noEmitType-check only
--projectUse a specific tsconfig.json
--versionShow version
--helpShow help

Why verify: The compiler is the entire tool. If tsc --version works, you’re 90% set up. Everything after this is configuration and workflow.


Step 4 โ€” Set up an editor

VS Code is the default recommendation. Install it, then check that it’s using the right TypeScript version.

Check the version VS Code uses:

  1. Open any .ts file
  2. Open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux)
  3. Run TypeScript: Select TypeScript Version
  4. Choose Use Workspace Version to use the project’s local TypeScript

VS Code ships with a bundled TypeScript version. For consistency, use the workspace version โ€” the one installed in your project’s node_modules. That way, the editor and tsc agree on what’s an error.

Recommended extensions:

ExtensionPurpose
ESLintLint TypeScript files
PrettierFormat code
Error LensShow errors inline
Path IntellisenseAutocomplete imports
TypeScript Vue PluginVue + TS (if applicable)

None are strictly required. VS Code’s built-in TypeScript support is already excellent โ€” the extensions just add convenience.

Other editors:

  • WebStorm โ€” first-class TypeScript support out of the box
  • Neovim / Vim โ€” via nvim-lspconfig and typescript-language-server
  • Sublime Text โ€” via the LSP package

Any editor with the TypeScript Language Server installed will give you autocomplete, go-to-definition, and inline errors.

Why the workspace version: The bundled version is whatever shipped with VS Code. Your project may need a different version. Selecting the workspace version aligns the editor with your build โ€” no more “the editor says it’s fine but tsc fails” surprises.


Step 5 โ€” Create your first project

A TypeScript project needs a package.json and a tsconfig.json. The first tracks dependencies and scripts; the second configures the compiler.

Initialize npm:

mkdir my-project
cd my-project
npm init -y

The -y accepts all defaults. You’ll get a package.json with placeholder fields.

Install TypeScript locally:

npm install --save-dev typescript

Initialize the compiler configuration:

npx tsc --init

This creates a tsconfig.json with comments explaining every option. By default, it enables strict: true (good) and targets a modern JavaScript version.

A minimal tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "outDir": "dist",
    "rootDir": "src"
  },
  "include": ["src"]
}
OptionPurpose
targetJS version to emit
moduleModule system for output
moduleResolutionHow imports are resolved
strictEnable all strict checks
esModuleInteropSmooth interop with CJS
skipLibCheckSkip .d.ts checking (faster)
outDirWhere compiled JS goes
rootDirWhere source lives

Add scripts to package.json:

{
  "scripts": {
    "build": "tsc",
    "watch": "tsc --watch",
    "typecheck": "tsc --noEmit"
  }
}

Write a file:

mkdir src
cat > src/index.ts << 'EOF'
function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet('Alice'));
EOF

Compile:

npm run build

Run the output:

node dist/index.js

You should see Hello, Alice!. The project is set up.

Why rootDir and outDir: By default, tsc emits .js files next to their .ts sources. For a clean project, keep sources in src/ and build output in dist/. That makes it clear what’s code and what’s generated โ€” and keeps dist/ easily gitignored.


Step 6 โ€” Gitignore and project files

A TypeScript project should ignore build output and dependencies in Git.

.gitignore:

node_modules/
dist/
*.tsbuildinfo
.DS_Store

Commit these:

  • package.json
  • package-lock.json
  • tsconfig.json
  • All .ts source files

Ignore these:

  • node_modules/ โ€” regenerated from package.json
  • dist/ โ€” regenerated by tsc
  • *.tsbuildinfo โ€” incremental build cache

Never edit node_modules. Install dependencies with npm and let the compiler find them.

Why the lockfile matters: package-lock.json pins exact versions of every dependency, including transitive ones. Without it, two developers installing at different times can end up with different compilers. Commit it.


Step 7 โ€” Running TypeScript without pre-compiling

Sometimes you want to run a .ts file directly โ€” no build step, no dist/. Several tools make this possible.

tsx โ€” the modern standard:

npm install --save-dev tsx
npx tsx src/index.ts

tsx uses esbuild to strip types fast and runs the result. It’s what ts-node used to be, but faster and with fewer configuration problems.

ts-node โ€” the older standard:

npm install --save-dev ts-node
npx ts-node src/index.ts

ts-node compiles and runs in one step. Slower than tsx, more configuration-sensitive, but widely used.

Node’s native TypeScript support (experimental):

Recent Node versions can run .ts files directly:

node --experimental-strip-types src/index.ts

This strips types without transforming them โ€” no enums, no namespace, no decorators. Useful for scripts, not for full projects yet.

Which to use:

ToolSpeedUse case
tsc + nodeSlowerProduction builds
tsxFastDevelopment, scripts
ts-nodeMediumLegacy projects
Node nativeFastSimple scripts, no fancy syntax

For most projects, tsx is the right choice for running during development, and tsc is the right choice for the production build. They can coexist.

Why not just use tsc for everything: tsc is a compiler, not a runner. Running tsc && node on every edit is slow. tsx skips the full compile and just strips types โ€” much faster for the dev loop. The final build still goes through tsc.


Step 8 โ€” Recommended project layout

A small, well-organized TypeScript project looks like this:

my-project/
โ”œโ”€โ”€ node_modules/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ””โ”€โ”€ utils.ts
โ”œโ”€โ”€ dist/
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

As the project grows, src/ gets subfolders โ€” components/, services/, utils/, types/. The build output in dist/ mirrors src/‘s structure.

What each file does:

FileRole
package.jsonDependencies and scripts
package-lock.jsonExact versions
tsconfig.jsonCompiler configuration
.gitignoreWhat not to commit
src/Source .ts files
dist/Compiled .js output
node_modules/Installed packages

Why this layout: It separates source from build output, keeps dependencies out of version control, and matches what virtually every TypeScript project looks like. Learning the shape once means you can navigate any project.


Global vs local โ€” a concrete comparison

Global install:

npm install -g typescript
tsc --version   # 5.4.5

Problems: every project uses the same version. If one project was written for 4.9, it may not compile cleanly with 5.4.

Local install:

cd my-project
npm install --save-dev typescript
npx tsc --version   # uses this project's version

Advantages: each project pins its own version. Upgrading one project doesn’t break another.

Both together:

  • tsc (global) for quick scripts you run outside any project
  • npx tsc (local) for real projects

The global compiler never sees a project with a local one โ€” npx prefers the local version automatically.

Why this matters: Version drift is the most common cause of “it works on my machine.” Pinning per-project eliminates it. When the whole team installs from the same package-lock.json, they get identical compilers.


A full example

Setting up a project from zero.

# ============================================
# PART 1: CREATE THE DIRECTORY
# ============================================

mkdir ts-demo
cd ts-demo

# ============================================
# PART 2: INITIALIZE NPM
# ============================================

npm init -y
# Wrote to package.json

# ============================================
# PART 3: INSTALL TYPESCRIPT
# ============================================

npm install --save-dev typescript
# added 1 package

# ============================================
# PART 4: CREATE TSCONFIG
# ============================================

npx tsc --init
# Created tsconfig.json

# ============================================
# PART 5: ADD SCRIPTS
# ============================================

# Edit package.json to add:
#   "build": "tsc"
#   "watch": "tsc --watch"
#   "typecheck": "tsc --noEmit"

# ============================================
# PART 6: WRITE A PROGRAM
# ============================================

mkdir src
cat > src/index.ts << 'EOF'
interface User {
  id: number;
  name: string;
}

function greet(user: User): string {
  return `Hello, ${user.name} (id ${user.id})!`;
}

const alice: User = { id: 1, name: 'Alice' };
console.log(greet(alice));
EOF

# ============================================
# PART 7: BUILD
# ============================================

npm run build
# dist/index.js created

# ============================================
# PART 8: RUN
# ============================================

node dist/index.js
# Hello, Alice (id 1)!

# ============================================
# PART 9: WATCH MODE
# ============================================

npm run watch
# Watching for file changes.

# Edit src/index.ts in another terminal
# โ†’ dist/index.js updates automatically

# ============================================
# PART 10: TYPE-CHECK ONLY
# ============================================

npm run typecheck
# (no output โ€” no errors)

# ============================================
# PART 11: RUN DIRECTLY WITH TSX
# ============================================

npm install --save-dev tsx
npx tsx src/index.ts
# Hello, Alice (id 1)!

# ============================================
# PART 12: ADD .gitignore
# ============================================

cat > .gitignore << 'EOF'
node_modules/
dist/
*.tsbuildinfo
EOF

Quick Reference

Required Tools

ToolPurposeInstall
Node.jsRuntime for toolingnodejs.org (LTS)
npmPackage managerShips with Node
TypeScriptCompilernpm i -D typescript
VS CodeEditorcode.visualstudio.com

Install Commands

CommandPurpose
npm install -g typescriptGlobal install
npm install --save-dev typescriptLocal install
npm install --save-dev tsxFast runner
npm install --save-dev ts-nodeOlder runner

Compiler Commands

CommandPurpose
tsc --versionShow version
tsc --initCreate tsconfig.json
tscCompile per config
tsc file.tsCompile a single file
tsc --watchWatch and rebuild
tsc --noEmitType-check only
tsc --helpShow help

Running Without Compiling

ToolCommand
tsxnpx tsx src/index.ts
ts-nodenpx ts-node src/index.ts
Node nativenode --experimental-strip-types src/index.ts

Global vs Local

AspectGlobalLocal
Installnpm i -g typescriptnpm i -D typescript
Commandtscnpx tsc
VersionOne for all projectsPer project
ReproducibleโŒโœ…
RecommendedFor learningFor projects

Project Layout

PathContents
src/.ts sources
dist/Compiled .js
node_modules/Dependencies
package.jsonDeps + scripts
package-lock.jsonExact versions
tsconfig.jsonCompiler config
.gitignoreIgnored files

npm Scripts

ScriptCommand
buildtsc
watchtsc --watch
typechecktsc --noEmit
devtsx src/index.ts

tsconfig Essentials

OptionRecommended
targetES2022
moduleESNext or NodeNext
moduleResolutionBundler or NodeNext
stricttrue
esModuleInteroptrue
skipLibChecktrue
outDirdist
rootDirsrc

Best Practices

โœ… Do This:

# Install Node LTS
# Use nvm for multi-project work
nvm use 20                                          # โœ…

# Install TypeScript locally in every project
npm install --save-dev typescript                   # โœ…

# Use npx to run the local compiler
npx tsc --version                                   # โœ…

# Commit tsconfig.json and package-lock.json
git add tsconfig.json package-lock.json             # โœ…

# Keep source in src/, output in dist/
# Both in tsconfig and .gitignore                    # โœ…

# Enable strict mode
"strict": true                                      # โœ…

# Use tsx for the dev loop
npm install --save-dev tsx                          # โœ…

# Type-check in CI
npx tsc --noEmit                                    # โœ…

# Select the workspace TypeScript in VS Code
# Command Palette โ†’ TypeScript: Select Version       # โœ…

โŒ Don’t Do This:

# Don't rely on global TypeScript in real projects
tsc                                                 # โš ๏ธ  version drift

# Don't commit node_modules or dist
git add node_modules dist                           # โŒ

# Don't edit node_modules by hand
nano node_modules/typescript/...                    # โŒ

# Don't skip the lockfile
# Remove package-lock.json                          # โŒ

# Don't run tsc on every edit in dev
tsc && node dist/index.js                           # โš ๏ธ  slow โ€” use tsx

# Don't disable strict mode permanently
"strict": false                                     # โš ๏ธ  temporary at best

# Don't mix global and local configs
# Global tsc using project tsconfig                  # โš ๏ธ  use npx

# Don't install Node "Current" for stable work
# Download the LTS version                           # โœ…

Common Pitfalls

PitfallProblemSolution
tsc: command not foundNot installed or not on PATHReinstall, check PATH
Global vs local mismatchDifferent versionsUse npx tsc in projects
Editor uses bundled versionEditor disagrees with buildSelect workspace version
No tsconfig.jsonNo project settingsRun tsc --init
tsc emits next to sourceMessy projectSet outDir and rootDir
Forgetting --save-devTS in production depsAlways use --save-dev
Running .ts with nodeSyntax errorUse tsx or compile first
Missing lockfileVersion driftCommit package-lock.json
node_modules committedHuge repoAdd to .gitignore

Real-World Examples

1. Check Node

node --version

2. Check npm

npm --version

3. Install TypeScript globally

npm install -g typescript

4. Install TypeScript locally

npm install --save-dev typescript

5. Check the compiler

npx tsc --version

6. Initialize a project

npm init -y
npx tsc --init

7. Create a source file

mkdir src
echo 'console.log("hi")' > src/index.ts

8. Compile

npx tsc

9. Run the output

node dist/index.js

10. Watch mode

npx tsc --watch

11. Type-check without emitting

npx tsc --noEmit

12. Run directly with tsx

npx tsx src/index.ts

13. Run directly with ts-node

npx ts-node src/index.ts

14. Add a build script

"scripts": {
  "build": "tsc",
  "watch": "tsc --watch",
  "typecheck": "tsc --noEmit"
}

15. Ignore build artifacts

node_modules/
dist/
*.tsbuildinfo

16. Select workspace TypeScript in VS Code

Command Palette โ†’ TypeScript: Select TypeScript Version โ†’ Use Workspace Version

17. Version manager

nvm install 20
nvm use 20

18. Check which tsc you’re using

which tsc    # or `where tsc` on Windows

19. Check project TypeScript version

npx tsc --version

20. Create an empty tsconfig

npx tsc --init --rootDir src --outDir dist

Visual: The Toolchain

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Node.js                                     โ”‚
โ”‚       โ”‚                                      โ”‚
โ”‚       โ–ผ                                      โ”‚
โ”‚  npm                                         โ”‚
โ”‚       โ”‚                                      โ”‚
โ”‚       โ–ผ                                      โ”‚
โ”‚  typescript (tsc)                            โ”‚
โ”‚       โ”‚                                      โ”‚
โ”‚       โ–ผ                                      โ”‚
โ”‚  Your project                                โ”‚
โ”‚                                              โ”‚
โ”‚  Each layer depends on the one above         โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Global vs Local

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Global TypeScript                           โ”‚
โ”‚                                              โ”‚
โ”‚  /usr/local/lib/node_modules/typescript     โ”‚
โ”‚                                              โ”‚
โ”‚  Command: tsc                                โ”‚
โ”‚  One version for all projects                โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Local TypeScript                            โ”‚
โ”‚                                              โ”‚
โ”‚  ./node_modules/typescript                   โ”‚
โ”‚                                              โ”‚
โ”‚  Command: npx tsc                            โ”‚
โ”‚  Per-project version                         โ”‚
โ”‚  Pinned in package.json                      โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Inside a project:                           โ”‚
โ”‚                                              โ”‚
โ”‚  npx tsc  โ†’ uses LOCAL version               โ”‚
โ”‚  tsc      โ†’ uses GLOBAL version              โ”‚
โ”‚                                              โ”‚
โ”‚  Prefer npx in projects                      โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Compile Pipeline

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  src/index.ts                                โ”‚
โ”‚                                              โ”‚
โ”‚  interface User { ... }                      โ”‚
โ”‚  function greet(u: User): string { ... }     โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  tsc                                         โ”‚
โ”‚                                              โ”‚
โ”‚  โ€ข Type-check                                โ”‚
โ”‚  โ€ข Transform syntax                          โ”‚
โ”‚  โ€ข Erase types                               โ”‚
โ”‚  โ€ข Emit to dist/                             โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  dist/index.js                               โ”‚
โ”‚                                              โ”‚
โ”‚  function greet(u) { ... }                   โ”‚
โ”‚                                              โ”‚
โ”‚  (plain JavaScript)                          โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  node dist/index.js                          โ”‚
โ”‚                                              โ”‚
โ”‚  โ†’ Runs in the JS runtime                    โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Dev vs Build Loop

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Development loop (tsx)                      โ”‚
โ”‚                                              โ”‚
โ”‚  Edit .ts file                               โ”‚
โ”‚       โ”‚                                      โ”‚
โ”‚       โ–ผ                                      โ”‚
โ”‚  tsx strips types, runs immediately          โ”‚
โ”‚                                              โ”‚
โ”‚  Fast, no dist/ output                       โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Build loop (tsc)                            โ”‚
โ”‚                                              โ”‚
โ”‚  Edit .ts file                               โ”‚
โ”‚       โ”‚                                      โ”‚
โ”‚       โ–ผ                                      โ”‚
โ”‚  tsc full type-check + emit                  โ”‚
โ”‚                                              โ”‚
โ”‚  Slower, produces dist/ for deployment       โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  CI (tsc --noEmit)                           โ”‚
โ”‚                                              โ”‚
โ”‚  Type-check only, no output                  โ”‚
โ”‚                                              โ”‚
โ”‚  Fast, catches errors before merge           โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Project Structure

my-project/
โ”œโ”€โ”€ node_modules/          โ† installed deps (ignored)
โ”œโ”€โ”€ src/                   โ† your .ts sources
โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ””โ”€โ”€ utils.ts
โ”œโ”€โ”€ dist/                  โ† compiled .js (ignored)
โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ””โ”€โ”€ utils.js
โ”œโ”€โ”€ package.json           โ† deps + scripts
โ”œโ”€โ”€ package-lock.json      โ† exact versions
โ”œโ”€โ”€ tsconfig.json          โ† compiler config
โ”œโ”€โ”€ .gitignore             โ† ignored paths
โ””โ”€โ”€ README.md

Visual: Editor-Build Alignment

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  VS Code bundled TS                          โ”‚
โ”‚                                              โ”‚
โ”‚  Ships with VS Code                          โ”‚
โ”‚  May not match project                       โ”‚
โ”‚  โ†’ "editor says OK, tsc fails"               โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Workspace TS                                โ”‚
โ”‚                                              โ”‚
โ”‚  From node_modules/typescript                โ”‚
โ”‚  Matches what the build uses                 โ”‚
โ”‚  โ†’ editor and tsc agree                      โ”‚
โ”‚                                              โ”‚
โ”‚  Select via:                                 โ”‚
โ”‚  Command Palette โ†’ TS: Select Version        โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ConceptMeaning
Node.jsRuntime for tooling and the compiler
npmPackage manager โ€” installs TypeScript
TypeScript compilertsc โ€” checks and emits JavaScript
Local installPer-project, pinned in package.json
Global installSystem-wide, for quick scripts
tsconfig.jsonCompiler configuration
package.jsonDependencies and scripts
package-lock.jsonExact dependency versions
tsxFast runner for dev
ts-nodeOlder runner
VS Code workspace TSMatch editor and build versions

Key takeaways:

  • Node.js LTS is the foundation โ€” install it first
  • npm ships with Node โ€” no separate install
  • Install TypeScript locally in every project (--save-dev)
  • Use npx tsc inside projects to run the local compiler
  • tsconfig.json configures the compiler โ€” strict: true is the recommended baseline
  • Keep source in src/ and build output in dist/ โ€” both in tsconfig and .gitignore
  • Commit package.json, package-lock.json, and tsconfig.json; ignore node_modules/ and dist/
  • Use tsx for fast dev runs, tsc for production builds, tsc --noEmit for CI type-checks
  • Set VS Code to use the workspace TypeScript version so the editor and build agree
  • Version managers (nvm) help with multi-project work
  • Verify the setup with node --version, npm --version, npx tsc --version

Remember: The environment is a one-time investment. Install Node LTS, add TypeScript locally to each project, configure tsconfig.json, ignore the generated folders, and make the editor match the build. After that, everything is TypeScript โ€” write .ts, run with tsx for dev, compile with tsc for production. The toolchain gets out of your way, and you focus on the code.


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!