ProgramGuru

Running TypeScript with Native Runtime Support

Running TypeScript with Native Runtime Support — why it matters

Some modern runtimes run TypeScript by stripping erasable type syntax directly. In Node.js, this is limited support: the built-in loader does not honor tsconfig.json, type-check code, or transform all TypeScript constructs. For predictable builds and older runtimes, keep a tsc + node or suitable toolchain workflow.

What you’ll learn

  • Explain running typescript with native runtime support and the problem it solves.
  • Identify the relevant compile-time checks and runtime responsibilities.
  • Run the example, predict its output, and try a realistic modification.

Understand the mechanism

The Profile annotation can be erased without changing the JavaScript logic. In Node versions with built-in type stripping enabled, such erasable syntax can execute directly, but compatibility depends on the installed Node release.

Native TypeScript execution is not the same as TypeScript type checking; run tsc --noEmit separately.

Follow the concept flow

Running TypeScript with Native Runtime Support — concept flowErasable TS syntax → Node strips types → JS executes, not typecheckedRunning TypeScript with Native Runtime Support1Erasable TS syntax2Node strips types3JS executes, nottypecheckedCompiler configuration changes checks and output, not runtime guarantees.
Follow the responsibilities from input to checked result.

Run the primary TypeScript example

Save as running-native-runtime-support.ts. The following program passed strict TypeScript compilation, and the displayed output was captured by executing its emitted JavaScript with Node.js 22.16.0.

TypeScript source

type Profile = { name: string };
const profile: Profile = { name: "Maya" };
console.log(`Hello, ${profile.name}`);

Verified output

Hello, Maya

Compile: npx tsc --strict --target es2022 --module commonjs running-native-runtime-support.ts; run: node running-native-runtime-support.js. For Node.js API examples, install @types/node first. For browser projects, use the browser-specific instructions below.

The example demonstrates the code-level behavior; the related configuration or test commands are shown separately when needed.

Trace the result

The Profile annotation can be erased without changing the JavaScript logic. In Node versions with built-in type stripping enabled, such erasable syntax can execute directly, but compatibility depends on the installed Node release.

Predict what changes if you alter one input. Then run the code to compare your reasoning with the real output.

Try the full tool or configuration workflow

Practical project lab: These are real configuration and source-file examples, not a TypeScript object that merely describes settings. Place the files at the named paths relative to one project directory.

hello.ts

type Name = { first: string };
const user: Name = { first: "Maya" };
console.log(user.first);

Commands

node --version
node hello.ts
npx tsc --noEmit hello.ts

Node must be a version with default type stripping; earlier Node 22 versions require an explicit experimental flag.

This project requires its named external tool or dependency and was supplied as setup guidance; it was not claimed as an executed test here.

Common mistake and correction

Native TypeScript execution is not the same as TypeScript type checking; run tsc --noEmit separately.

Identify whether the failure is a type-checking issue, a configuration issue, or a runtime behavior issue before choosing a fix.

Practice the concept

Inspect node --version. Test node example.ts only on a compatible Node release, then run tsc --noEmit independently.

Write down your expected result first. For configuration examples, compare compiler output and diagnostics; for test examples, make the assertion fail deliberately to verify that the tool reports it.

Check your understanding

What should you remember when configuring TypeScript compilation?
Choose one answer. You can try again.

Answer and explanation

Compiler options control static checks or emitted files; running the result is a separate step.

The Profile annotation can be erased without changing the JavaScript logic. In Node versions with built-in type stripping enabled, such erasable syntax can execute directly, but compatibility depends on the installed Node release.

Official reference

For the exact current options and platform behavior, consult the official documentation. These examples were verified using the tool versions described above.

What to remember

Some modern runtimes run TypeScript by stripping erasable type syntax directly.

Run the primary example, then complete the practice task or environment-specific lab.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: TypeScript ESLint and Prettier →