You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a typo where I used curly brackets instead of square brackets to spread to Set variables, but TypeScript didn't catch the error at build time. Instead, the code failed at runtime.
🔎 Search Terms
set, object, spread
🕗 Version & Regression Information
This is the behavior in every version I tried back to TS 3.x
constfirst=newSet(['one'])constsecond=newSet(['two'])constall={ ...first, ...second};console.log(all)// prints `{}`all.add('wat')// TS is happy but JS throws a runtime error
🙁 Actual behavior
TS thinks the Set methods like .add() and .clear() are available and doesn't show a build error for the last line.
🙂 Expected behavior
TS should show an error at build time to reflect actual JS usage at runtime: no Set method are available for the last line.
The text was updated successfully, but these errors were encountered:
Bug Report
I had a typo where I used curly brackets instead of square brackets to spread to Set variables, but TypeScript didn't catch the error at build time. Instead, the code failed at runtime.
🔎 Search Terms
set, object, spread
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
TS thinks the Set methods like
.add()
and.clear()
are available and doesn't show a build error for the last line.🙂 Expected behavior
TS should show an error at build time to reflect actual JS usage at runtime: no Set method are available for the last line.
The text was updated successfully, but these errors were encountered: