Skip to main content
Servers Are Up
Virtual Datacenter
PricingFree Tools
Sign inBrowse catalog
Servers Are Up
Virtual Datacenter
PricingFree Tools
Sign inBrowse catalog

Loading…

Servers Are Up

Your apps, automation and data on hardware we own. Build a private stack with predictable capacity and access through your dashboard, API or SSH.

SLA with service creditsOwned hardwareUS-based

Make room for your next idea

Explore the capacity, apps and access options that fit your workload. Check current availability and your total before you buy.

Sign up freeView Pricing

Products

  • Linux VPS
  • Windows VPS
  • Cloud & SaaS Services
  • Cloud Storage (Azure)
  • Virtual Datacenter
  • AI & Agent Hosting
  • Containers
  • Instant Apps
  • Software Platforms
  • Network builder
  • Game Servers
  • Free Game Servers
  • Pricing

Resources

  • Free Network Tools
  • 2026 Pricing Benchmark
  • Live SVG Badges
  • Latency & Speed Test
  • Guides & Tutorials
  • Documentation
  • API Reference
  • MCP Server
  • CLI & SDKs
  • OpenAPI & llms.txt
  • Use Cases
  • Free Migration
  • Uptime & Reliability
  • Datacenter
  • System Status
  • Network
  • Provider Comparisons Hub
  • Compare Providers

Company

  • About Us
  • Enterprise
  • Security Architecture
  • Trust Center
  • Blog
  • FAQ
  • Compliance
  • Startup Program
  • Open-Source Sponsorship
  • Press & Media Kit
  • Referral Program
  • Help Center
  • Contact Us
© Servers Are Up
TermsPrivacySLARefund PolicyDPAAcceptable Use
Service information
Docs
  • Documentation Hub
  • Technical Knowledge Library
    Runbooks & 187 Blueprints
  • Choose a Product
    VMs, Containers & Cloud
  • First Linux Server
    SSH, Firewall & Apps
  • Windows Server 2025
    BYOL & Remote Desktop
  • Remote Access
  • Troubleshooting
  • FAQ
  • All Product Guides
    29 Step-by-Step Guides
  • Cloud & SaaS Catalog
    112 Cloud & SaaS Offerings
  • Azure Cloud Storage
    Hot/Cool/Archive & WORM
  • Resource Manager & RBAC
    Groups, Tags & Locks
  • Multi-Model Cloud DB
    JSONB, SQL & pgvector
  • Cloud Identity & ZTNA
    OIDC, SCIM & PIM
  • Key Vault & KMS
    Secrets & Envelope Keys
  • Cloud SIEM, SOAR & DLP
    Posture & Threat Response
  • API Gateway & Cloud DNS
    Edge WAF & DNS Zones
  • Serverless, Workflows & IoT
    Functions, Queues & DAGs
  • SaaS, Governance & Vault
    Budgets & Off-Host GRS
  • Linux Systems & Kernel
    SSH, UFW, sysctl & OOM
  • Self-Hosted Apps & Stacks
    Caddy, Nextcloud & Auth
  • Build Web Apps with AI
  • Next.js and React
  • TypeScript and Node.js
  • npm and Tooling
  • Data and APIs
  • Deploy and Operate
  • Tutorials
  • Infrastructure
  • Automation & Regions
  • API Overview
  • API v1 Reference
    Endpoints & 23 Scopes
  • MCP Server
    129 AI Agent Tools
  • Swagger / OpenAPI 3.1
  • API Playground
  • Versioning & Sunset
  • API Token Security
    Authentication & Tokens
  • Instances API
    Compute Resources
  • Networking API
    Networks & Ports
  • Storage API Availability
    Volumes & Backups
  • Webhooks & Events
    Event Notifications
  • Rate Limits & Best Practices
    Throttling & Retries
  • sau CLI Reference
    34 Commands (v0.2)
  • Browser Web CLI
  • SDKs
  • Infrastructure as Code
    Terraform & Ansible
  • Code Examples
  • CLI & SDK Guides
  • Security Guides
  • Security at a Glance
  • Zero Trust Architecture
  • Live Trust Center
  • Compliance
Need help?

Loading documentation...

Documentation/typescript node

Turn on strict TypeScript and fix the first errors

Start a TypeScript project with the strict settings the compiler now proposes, read the first ten errors they raise, and fix each one the right way.

Beginner
30 min
Updated 2026-10-13

Deploy Ready-to-Run Infrastructure in Seconds

Linux VMs from $6/mo · Pooled Virtual Datacenters from $12/mo · Use code WELCOME20 for 20% off your first order.

Browse ServersView Pricing

Commands checked on 2026-10-13 with TypeScript 5.9, Node.js 24, npm 11.

What you will have at the end

A small TypeScript project whose compiler settings refuse the mistakes that cause most production bugs: a value that may be missing, a list read past its end, an error of unknown shape. You will have seen each refusal once, fixed it, and run the result with Node.js without a build step.

Before you start

  • Node.js 24 and npm 11. Check with node -v and npm -v.
  • An empty folder.

Steps

1. Create the project

npm init -y
npm install -D typescript@5.9 @types/node@24
npx tsc --init

tsc --init writes tsconfig.json and prints Created a new tsconfig.json.

2. Read what the compiler proposes

Open tsconfig.json. Without its comments it holds:

{
  "compilerOptions": {
    "module": "nodenext",
    "target": "esnext",
    "types": [],
    "sourceMap": true,
    "declaration": true,
    "declarationMap": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "strict": true,
    "jsx": "react-jsx",
    "verbatimModuleSyntax": true,
    "isolatedModules": true,
    "noUncheckedSideEffectImports": true,
    "moduleDetection": "force",
    "skipLibCheck": true
  }
}

Three of these lines do most of the work in this guide:

  • strict turns on a family of checks, the most useful being that null and undefined are not silently part of every type.
  • noUncheckedIndexedAccess makes list[0] a value that may be missing, because it may be.
  • exactOptionalPropertyTypes makes an optional property mean "may be left out", not "may be set to undefined".

3. Write code the way it is usually written

Create src/user.ts:

type User = { id: number; name: string; email?: string }

const users: User[] = [{ id: 1, name: 'Ada', email: 'ada@example.com' }, { id: 2, name: 'Linus' }]

export function findUser(id) {
  return users.find((user) => user.id === id)
}

export function emailDomain(id: number): string {
  const user = findUser(id)
  return user.email.split('@')[1]
}

export function firstName(names: string[]): string {
  return names[0].toUpperCase()
}

export function parsePort(value: string): number {
  try {
    return Number.parseInt(value, 10)
  } catch (error) {
    throw new Error(error.message)
  }
}

4. Ask the compiler

npx tsc --noEmit

It prints ten errors. TS1287 appears four times, once for every export, and TS2322 repeats the cause of the two TS18048 lines. The six that tell the story:

src/user.ts(5,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
src/user.ts(5,26): error TS7006: Parameter 'id' implicitly has an 'any' type.
src/user.ts(11,10): error TS18048: 'user' is possibly 'undefined'.
src/user.ts(11,10): error TS18048: 'user.email' is possibly 'undefined'.
src/user.ts(15,10): error TS2532: Object is possibly 'undefined'.
src/user.ts(22,21): error TS18046: 'error' is of type 'unknown'.

5. Say what kind of module this is

TS1287 appears once for every export. The project's package.json does not say whether its files are ES modules, so Node.js treats them as CommonJS, where export does not exist. Say it:

npm pkg set type=module

6. Fix each kind of error by saying what is true

Replace src/user.ts with:

type User = { id: number; name: string; email?: string }

const users: User[] = [{ id: 1, name: 'Ada', email: 'ada@example.com' }, { id: 2, name: 'Linus' }]

export function findUser(id: number): User | undefined {
  return users.find((user) => user.id === id)
}

export function emailDomain(id: number): string | undefined {
  const user = findUser(id)
  return user?.email?.split('@')[1]
}

export function firstName(names: string[]): string {
  const first = names[0]
  if (first === undefined) throw new Error('names is empty')
  return first.toUpperCase()
}

export function parsePort(value: string): number {
  const port = Number.parseInt(value, 10)
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
    throw new Error(`not a port: ${value}`)
  }
  return port
}

export function describe(error: unknown): string {
  return error instanceof Error ? error.message : String(error)
}

What changed, error by error:

  • TS7006, a parameter with no type. id is a number, so it says so. The return type is written too: a user may not be found.
  • TS18048, a value that may be missing. There may be no such user, and a user may have no email. ?. stops at the first missing value, and the function now admits that it may return nothing.
  • TS2532, a list read past its end. An empty list has no first name. The code checks and says what went wrong.
  • TS18046, an error of unknown shape. Anything can be thrown, not only an Error. describe checks before it reads .message.
  • The original parsePort hid a bug no setting catches: Number.parseInt('eighty', 10) does not throw, it returns NaN. The new one checks the result.

7. Run it without a build step

Node.js 24 runs TypeScript files directly by removing the types. Create src/main.ts:

import { describe, emailDomain, firstName, parsePort } from './user.ts'

console.log(emailDomain(1), emailDomain(2), emailDomain(3))
console.log(firstName(['ada', 'linus']))
console.log(parsePort('8080'))
try {
  parsePort('eighty')
} catch (error) {
  console.log(describe(error))
}

The import names the file as it is on disk, ./user.ts. The compiler refuses that until you tell it nothing will be emitted:

src/main.ts(1,61): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

Add two lines to compilerOptions in tsconfig.json:

"noEmit": true,
"allowImportingTsExtensions": true,

Check that it works

npm pkg set scripts.typecheck="tsc --noEmit"
npm run typecheck
node src/main.ts

typecheck prints no error. The program prints:

example.com undefined undefined
ADA
8080
not a port: eighty

What can go wrong

  • TS2591: Cannot find name 'process'. The proposed "types": [] loads no global types, Node's included. When your code uses process, Buffer or other Node globals, change the line to "types": ["node"].
  • TS2375 on an object with nickname: undefined. That is exactOptionalPropertyTypes at work. Leave the property out, or declare it as nickname?: string | undefined when "present but empty" is a real state.
  • TS5052: Option 'exactOptionalPropertyTypes' cannot be specified without specifying option 'strictNullChecks'. Someone tried to switch strict off while keeping the rest. The options build on each other; keep strict on.
  • The urge to write any or !. any switches the checks off for everything the value touches, and ! tells the compiler a value exists without making it so. Both turn a compile error into a production error. Narrow with a check instead.

Good practice

  • Turn the strict settings on in the first commit. On an existing project, turn on one option at a time and fix what it reports.
  • Write the return type of every exported function. It is the promise other files rely on, and the compiler then checks the function against it.
  • Treat every value from outside the program (a request, a file, an environment variable) as unknown until you have checked its shape.
  • Run tsc --noEmit in your checks even when a bundler builds the project: many build tools remove types without checking them.

Where to go next

  • Start a Next.js app with TypeScript, linting and a first test
  • Use the lockfile so every machine installs the same tree

Frequently Asked Questions

What does the Turn on strict TypeScript and fix the first errors documentation guide cover?
Start a TypeScript project with the strict settings the compiler now proposes, read the first ten errors they raise, and fix each one the right way. It is rated beginner difficulty (30 min) and applies to Servers Are Up infrastructure and workflows.
Can I manage or automate these steps through the Servers Are Up dashboard, REST API v1, or MCP server?
Yes. Every Servers Are Up server includes browser-based SSH, WebRDP, and VNC console access in the dashboard, plus programmatic control via the REST API v1 (/api/v1) and hosted Model Context Protocol server (/api/mcp/v1) using a scoped Personal Access Token.

Need hands-on help with Turn on strict TypeScript and fix the first errors?

Every Servers Are Up virtual machine and container includes an integrated HTML5 browser-based SSH, RDP, and VNC console in your dashboard, default-off inbound firewall rules with per-IP allow-lists, and full programmatic control via REST API v1 and Model Context Protocol (MCP). Explore our Virtual Datacenter Plans or reach out to Servers Are Up Support.

Was this article helpful?

On this page

What you will have at the endBefore you startSteps1. Create the project2. Read what the compiler proposes3. Write code the way it is usually written4. Ask the compiler5. Say what kind of module this is6. Fix each kind of error by saying what is true7. Run it without a build stepCheck that it worksWhat can go wrongGood practiceWhere to go next
Need Live Commands?

Open Aria in Wide Engineering Mode for distro-specific commands, compose tweaks, and isolated environment troubleshooting.

Knowledge Library