Course contentsShow
← TypeScript
Lesson 1769 of 1,79640. The Future of TypeScriptFree lesson

Syntax That Would Be Standardized

Which parts of TypeScript syntax the proposal aims to make valid JavaScript syntax.

Syntax That Would Be Standardized

You'll learn: Exactly which TypeScript syntax features the TC39 Type Annotations Proposal would make valid JavaScript.

The Core Idea

The Type Annotations Proposal doesn't aim to bring all of TypeScript to JavaScript — that would be impossibly complex. Instead, it proposes standardizing a subset of TypeScript's syntax that browsers and JavaScript engines could safely ignore at runtime.

Think of it like comments: JavaScript engines already skip over /* ... */ and // without understanding their contents. The proposal would extend this concept to type annotations.

What Would Become Standard JavaScript

The proposal focuses on syntax that's:

  • Erasable: Can be completely removed without changing runtime behavior
  • Non-intrusive: Doesn't affect how JavaScript actually executes
  • Type-only: Purely for static analysis tools

Specifically Included

The syntax that would be standardized:

  • Type annotations on variables and parameters: let name: string, function greet(name: string)
  • Return type annotations: function add(): number
  • Interface declarations: interface User { }
  • Type alias declarations: type ID = string
  • Generic syntax: Array<number>, function identity<T>(x: T)
  • Type assertions: value as string
  • Union and intersection operators: string | number, A & B

Explicitly Excluded

Features that would not be standardized because they generate runtime code or transform behavior:

  • Enums (they compile to objects)
  • Namespaces (they generate runtime code)
  • Parameter properties (they transform constructors)
  • Decorators (have their own separate proposal)

Why This Matters

If standardized, you could write type-annotated JavaScript that runs directly in browsers and Node.js without transpilation — the engines would simply skip the type syntax. TypeScript, Flow, and other type checkers would still read and validate those annotations, but the JavaScript engine itself wouldn't need to understand them.

Key Takeaway: The proposal would standardize TypeScript's type annotation syntax (the stuff that gets erased anyway), not its runtime features, making types a built-in but ignored part of JavaScript itself.