svelte icon indicating copy to clipboard operation
svelte copied to clipboard

A better error message to replace `switch_value is not a constructor`

Open UltraCakeBakery opened this issue 3 years ago • 0 comments

Describe the problem

I've been ripping hairs out left and right for the last days while trying to figure out why I got the following error: switch_value is not a constructor.

This error apparently occurs when you pass an invalid value to the this="" attribute on <svelte:component /> inside a { #each } block.

My project is pretty large with some components having excessive amounts of binded properties. I thought these were to blame at first, but no, it was the stupid dynamic component that wasn't loaded in correctly.

Here is a recreation of the error using the REPL: https://svelte.dev/repl/904c3f254d9b45eaa96cc1b937b52130?version=3.48.0

Describe the proposed solution

Improve the error message

Alternatives considered

depending on if svelte can't catch the error and improve it, add a hint warning or something

Importance

would make my life easier

UltraCakeBakery avatar May 20 '22 14:05 UltraCakeBakery