Last active
January 20, 2023 04:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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