JS backend: generate component functions for data classes.

This appears to fix multi-declaration interaction with data classes when JS back-end is used, I’ve added a test as well.