3 ms·
The second example could be replaced with something more common like: f() ['foo', 'bar'].forEach(...) Which is probably a type error, except if `f()`
by runarberg 5y ago
The second example could be replaced with something more common like:
f()
['foo', 'bar'].forEach(...)
Which is probably a type error, except if `f()` returns something like:
function f() {
return {
bar: ['Not the array', 'you were expecting'],
}
}
Then you would actually iterate over the returned `bar` array, not the expected `['foo', 'bar']` array.
Another fairly likely example of a desired semicolon not inserted is when the following line starts with a template string literal:
f()
`This is tagged with whatever f() returns`
This will most likely be a type error, except if `f()` returns a function, that function will then be called on the template string to do whatever. However I have a hard time imagining when you would want to start a statement with a template string literal without doing something smelly like:
`some ${interpolated} string`.includes(someVar)
? sideEffectA()
: sideEffectB()