Skip to content

Instantly share code, notes, and snippets.

@david-crespo
Last active May 14, 2023 21:03
Show Gist options
  • Save david-crespo/059e8d4946491c0b04eebc160fc35d0b to your computer and use it in GitHub Desktop.
Save david-crespo/059e8d4946491c0b04eebc160fc35d0b to your computer and use it in GitHub Desktop.
TypeScript release highlights thru 5.0

TypeScript release highlights

These aren't meant to be comprehensive. They're just the features that most interest me. CFA = control-flow analysis.

1.4: union types and better inference on generics using the union type

1.6: JSX, intersection types, generic type aliases

1.8: type params referring to other type params, string literal types

2.0: strict null checking, tagged unions, never

2.1: keyof + lookup types, mapped types, object rest/spread, config extend

2.3: generic param defaults

2.4: better generics inference

2.6: strict function types

2.7: fixed length tuples, better object literal inference

2.8: conditional types, infer, add/remove readonly + ? in mapped types

  • “distributive property of conditional types can be used to filter union types”
  • combination of conditional types and mapped types demoed (FunctionPropertyNames is basically PickByValue)
  • “It is possible to have multiple infer locations for the same type variable”
  • Exclude, Extract, Omit discussed

2.9: number keys in mapped types, generics in tagged templates (e.g., props in styled-components)

3.0: parameter lists are tuples, rest/spread with tuples, generics in rest params, unknown

3.1: mapped types on tuples and arrays

3.2: improved rest/spread with generic objects

3.3: improved unions of callable types

3.4: generic param propagation (compose example), readonly, as const

3.5: Omit, improved unions w/ discriminant properties, generic propagation in constructors

3.6: improved array spread, nicer error messages around promises

3.7: optional chaining, nullish coalescing, recursive type alias improvements

3.8: type-only import/export, export * as, top-level await

3.9: type params that extend any don't act as any, improved discriminant intersections

4.0: variadic tuples, ... can go anywhere in a tuple, tuple element labels

4.1: template literal types, key remapping in mapped types (e.g., key filtering with never), recursive conditional types

4.2: more flexible ... in tuple types, mark destructured vars as unused with _

4.3: template string type improvements, better narrowing for generics

4.4: CFA on aliased discriminants, template string pattern index signatures

4.5: Awaited, type modifiers on import names, template string types as discriminants

4.6: CFA for destructured discriminated unions and dependent params

4.7: CFA for bracketed element access, extends constraint for infer, instantiation expressions, variance annotations for type params

4.8: better inference for binding patterns and infer with template strings, perf

4.9: satisfies

5.0: const type params, decorators, perf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment