Heh, I just had an epiphany. See, I'd have argued that this can be also quite annoying to deal with. It does work well with hierarchies/templates, but what if I don't need a rectangular hitbox. What if it's a single big spike and I need it triangle-shaped? My first thought was I'd need to create specific collision polygons for every differently shaped object... but there's a feature that I tend to overlook a bit. Meshes! Meshes solve that quite elegantly. And one obvious benefit is that I can also make an enemy only partially spiky simply by adjusting that sprite, which I would have to solve this way anyway even with javascript.
Only downside I see with this approach is the lack of a simple catch-all. I don't think spawing in the spiky sprites via events is ideal and hierarchies can be a little bit annoying to deal with (although it's gotten better over time), and some objects (let's say a static sprite) would be so simple to solve by just saying "you're spiky now" as opposed to creating hierarchy, template, placing replicas, having to remember to update the replicas across all layouts when I make changes,... And the mesh could also be somewhat annoying to set up in some cases at least, for example with a round sprite it's quite easy to just press "guess collision polygon" and be done with it, but adjusting the mesh nicely to that...
Tilemaps are also a bit tricky in that regard I think. I can't really just create the spiky sprites if I have differently shaped spikes, at least not without some extra work to make a specific template for the specific tiles. Or I make an extra tilemap that is only spikes, but that then again would require me to do an extra "or on collision with tilemap" which kinda defeats the purpose.
But I suppose this is still the ideal solution.