94 cards across 6 sections
v7.0
.d.ts
v6.0
strict
any
tsconfig
--checkers
--builders
--watch
strict: true
module: esnext
target: es5
baseUrl
v7.1
string
number
boolean
null
undefined
symbol
bigint
string[]
type Name = ...
interface
'left' | 'right'
A | B
A & B
type
class
enum
(a: number, b: number) => number
function identity<T>(x: T): T
<T extends HasLength>
<T = string>
concat
this
readonly
ReadonlyArray<T>
?
age?: number
[key: string]: number
Window
declare module
const cfg = {...} satisfies Config
{ [K in keyof T]: T[K] }
Partial
Readonly
Pick
T extends U ? X : Y
T
U
infer R
ReturnType<T>
on${Capitalize<Event>}
Required
Omit
Record
Awaited
keyof T
typeof value
A
B
typeof
instanceof
in
kind: 'circle' | 'square'
switch
default
never
x is Foo
Foo
asserts x is Foo
!
public
private
protected
abstract class
abstract
extends
implements
count = 0
static
static {}
strictNullChecks
noImplicitAny
moduleResolution: nodenext
classic
types
package.json
declare module 'name'
references
tsconfig.json
isolatedModules
type Shape = | { kind: 'circle'; r: number } | { kind: 'square'; side: number };
satisfies
const routes = { home: '/', docs: '/docs',} satisfies Record<string, string>;
unknown
function parse(json: unknown): User { if (!isUser(json)) throw new Error('bad'); return json;}
type Result = Awaited<ReturnType<typeof fetchUser>>;
type State = | { status: 'loading' } | { status: 'error'; message: string } | { status: 'ready'; data: User };
const ROLES = ['admin', 'editor', 'viewer'] as const;type Role = typeof ROLES[number];
function isUser(x: unknown): x is User { return typeof x === 'object' && x !== null;}
type PublicUser = Omit<User, 'password' | 'email'>;
type Event = 'click' | 'hover';type Handler = `on${Capitalize<Event>}`;// 'onClick' | 'onHover'
function useToggle<T>(initial: T) { return [initial, () => {}] as const;}
const CONFIG = { retries: 3, timeout: 5000 } as const;
default: { const check: never = value; throw new Error(`unhandled: ${check}`);}
function logged<F extends (...a: any[]) => any>(fn: F): F { return fn;}
const labels: Record<Role, string> = { admin: 'Admin', editor: 'Editor', viewer: 'Viewer',};
// tsconfig.json{ "references": [{ "path": "../core" }] }
if (typeof x === 'string')
x
[K in keyof T]
Partial<T>
Readonly<T>
kind
case
target
module
moduleResolution: classic
value!
if
let color = 'red'
'red'
'red' | 'blue'
as const
as User
as
[...arr]
toSorted
toSpliced
Promise<T | undefined>
@ts-expect-error
nodenext
bundler
es2022
a?.b?.c?.d
import
export
namespace