DEV Community

Cover image for ts-faker - Generating fake data using TypeScript interfaces
Sirwan Afifi
Sirwan Afifi

Posted on

ts-faker - Generating fake data using TypeScript interfaces

I recently built a Next.js website that generates fake data. Regularly, I perform routine tasks like this. Rather than manually go through the process, I decided to automate it. You just need to define your schema as TypeScript interfaces, and the test data will be generated automatically. I thought it would be a good idea to share the source code with you so that you can learn something from it. I hope you enjoy it.

source: https://github.com/SirwanAfifi/ts-faker
website: https://ts-faker.vercel.app/

Discussion (1)

Collapse
raulinlee profile image
Lee Raulin

Pretty cool proof of concept, but for it to be useful for me, it would need to be able to handle interfaces composed of other interfaces. Even if I provide all the interfaces in a valid TS file, it just treats each one separately, creating data for them all, which I don't need, and treating interface types as strings, which means I'd to manually paste in data for nested interfaces, which sort of defeats the point.