Skip to content

Instantly share code, notes, and snippets.

@rsms
rsms / optional.ts
Created July 28, 2017 16:11
Make a TypeScript interface completely optional
// Optional declares a type of keyed type T where all keys are optional.
// This allows
type Optional<T> = { [P in keyof T]? :T[P] }
interface Foo {
x :number
y :number
}
type OptionalFoo = Optional<Foo>