Stop nesting ternaries in JavaScript
@philnash
https://www.sonarsource.com/blog/stop-nesting-ternaries-javascript/
Conversation
Notices
-
Embed this notice
ECMAScript News (ecmascript_news@mastodon.online)'s status on Thursday, 07-Dec-2023 22:38:47 JST ECMAScript News -
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Thursday, 07-Dec-2023 22:38:43 JST Sergey on FunctionalScript @ecmascript_news @philnash agree, I'm using `if () { return .. }` always. I've also tried to use `switch (true)` but TypeScript can't narrow types :-( https://github.com/functionalscript/functionalscript/pull/263/files
In conversation permalink Attachments
-
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Thursday, 07-Dec-2023 23:39:20 JST Sergey on FunctionalScript @ecmascript_news @philnash Thank you! Good to know! However, it looks like the narrowing doesn't apply to the next `case ...` after `return` 🥴 https://github.com/functionalscript/functionalscript/pull/263/commits/58db1318b5742e636df6a2e03005f1fc9719de4b
In conversation permalink Attachments
-
Embed this notice
ECMAScript News (ecmascript_news@mastodon.online)'s status on Thursday, 07-Dec-2023 23:39:21 JST ECMAScript News @functionalscript @philnash The latter has changed recently: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#switch-true-narrowing
In conversation permalink Attachments
-
Embed this notice