ts-reset
ts-reset copied to clipboard
Feature request - Smarter `Boolean`
This is a great project 😍
I add a suggestion to "patch" Boolean because I have been stumped by it at multiple occasions, e.g:
const fn = (arg: 'string' | null) => {
const bar = Boolean(arg)
if (bar) {
return arg.toUpperCase()
// ^? (parameter) arg: "string" | null
}
const baz = !!arg
if (baz) {
return arg.toUpperCase()
// ^? (parameter) arg: "string"
}
return arg
}
In real code examples, I usually have a combination of variables (e.g: const hasData = Boolean(!isLoading && data && !hasError)) and I found Boolean to be quite "dumb" compared to the less elegant !!. I don't know if it's normal and I'm missing something of if it could be patch like Array#filter.