louiszn/tiny-mixin ? reverse-engineered prompt

Reverse engineered prompt

Build me a tiny TypeScript library for composing classes with mixins.

I want a simple way to take a base class, apply a few mixins in order, and get back a new class that keeps the right constructor and instance types. It should work with both normal classes and abstract classes, and it should be easy to define mixins by passing a base class into a function that returns an extended class.

Please make it lightweight, dependency free, and usable in Node.js and the browser. I also want the mixin application to be cached so calling it again with the same base and same mixins returns the same class instead of rebuilding it. Include a small example with something like an Animal base class and mixins for behaviors such as flying, swimming, and walking.

If you need to check current TypeScript patterns or docs online, go ahead. Keep the public API small and clean, and make sure the types feel really solid.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab