Is your feature request related to a problem? Please describe.
Many people have been surprised when {#each} doesn't work with iterables, and there have been a number of issues about adding support for this - which we don't want to do, for reasons outlined elsewhere.
Describe the solution you'd like
A dev mode only check that makes sure the argument to the {#each} block is an object with a length property. If not, throw a descriptive runtime error about needing an array-like.
If the object in question has a Symbol.iterator property, we could also add a note to the error about [...foo]/Array.from(foo). We'd want to be careful to not accidentally cause a different error in js engines that don't have Symbol.iterator.
This would probably be implemented by writing a new validate_each_argument (name tbd) function in the same vein as validate_store or validate_each_keys and only emit code to call it in dev mode.
Describe alternatives you've considered
Do nothing. It's sort of worked so far.
How important is this feature to you?
The main reason it'd be important to me personally is that it might reduce the number of questions or issues about {#each} and iterables, which would be nice.
Additional context
Not really.
Is your feature request related to a problem? Please describe.
Many people have been surprised when
{#each}doesn't work with iterables, and there have been a number of issues about adding support for this - which we don't want to do, for reasons outlined elsewhere.Describe the solution you'd like
A dev mode only check that makes sure the argument to the
{#each}block is an object with alengthproperty. If not, throw a descriptive runtime error about needing an array-like.If the object in question has a
Symbol.iteratorproperty, we could also add a note to the error about[...foo]/Array.from(foo). We'd want to be careful to not accidentally cause a different error in js engines that don't haveSymbol.iterator.This would probably be implemented by writing a new
validate_each_argument(name tbd) function in the same vein asvalidate_storeorvalidate_each_keysand only emit code to call it in dev mode.Describe alternatives you've considered
Do nothing. It's sort of worked so far.
How important is this feature to you?
The main reason it'd be important to me personally is that it might reduce the number of questions or issues about
{#each}and iterables, which would be nice.Additional context
Not really.