TS Keywords
TypeScript inherits every JavaScript keyword and adds about a dozen of its own — type-related modifiers and the type-system constructs.
JavaScript keywords TS inherits
const, let, var, function, return, if, else, switch, case, for, while, do, break, continue, class, extends, super, this, new, typeof, instanceof, in, of, void, delete, throw, try, catch, finally, async, await, yield, import, export, default, from, as, true, false, null, undefined.
TypeScript-only keywords
| Keyword | What it does |
|---|---|
type | Declare a type alias. |
interface | Declare an interface. |
enum | Declare an enum. |
namespace | Declare a namespace (legacy). |
module | Same as namespace, older spelling. |
declare | Ambient declaration (no implementation). |
abstract | Abstract class / member. |
public / protected / private | Access modifiers. |
readonly | Set-once property. |
override | Explicit method override. |
static | Static member. |
implements | Implement an interface. |
keyof | Union of an object's keys. |
typeof (type-level) | Type of a value. |
infer | Capture a type in a conditional. |
is | Type predicate return. |
asserts | Assertion function return. |
satisfies | Check without widening. |
as (in expr) | Type assertion. |
any, unknown, never, void, object | Special types. |
boolean, number, string, symbol, bigint | Primitive type names. |
Soft keywords
Some words are only reserved in specific contexts — you can still name variables type or keyof, but please don't.
Look it up at runtime
TS
// In a TypeScript source file, the compiler resolves these without import. // At runtime, only the JS subset survives — the rest are erased.
Tip: Don't fight conventions.
type, interface, readonly, abstract all have idiomatic uses. Memorise the table once and TS code reads like prose.Example
Example
// Common reserved words:
// const, let, var, function, return, if, else, switch, case,
// for, while, do, break, continue, class, extends, super, this,
// new, typeof, instanceof, in, of, void, delete, throw, try, catch,
// finally, async, await, yield, import, export, default, from, as,
// type, interface, enum, namespace, module, declare, readonly,
// public, private, protected, abstract, static, override, satisfies
console.log('Plus all JS keywords — TS is a JS superset');
Try it Yourself »
Exercise
TS-only keyword for type aliases.
User = { id: number };
Four letters.
Discussion
Loading…