Skip to content

Instantly share code, notes, and snippets.

@joerter
Last active January 20, 2023 04:33
Show Gist options
  • Save joerter/890d1e728112a9c52f47aa629d9f77d1 to your computer and use it in GitHub Desktop.
Save joerter/890d1e728112a9c52f47aa629d9f77d1 to your computer and use it in GitHub Desktop.
A simple function that creates an object of the specified type and sets all properties to undefined. Useful for creating stubs in Typescript tests
export function stub<T>(partial?: Partial<T>): T {
return partial != null ? (partial as T) : ({} as T);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment