The implementation seems pretty straightforward:
type Falsy = Zero | "" | false | null | undefined;
type Truthy<T = Numeric | object | string | symbol | true> = Exclude<T, Falsy>;
Falsy
should include NaN
, but TypeScript does not provide that at the type level.
Technically, Falsy
should also include HTMLAllCollection
due to the [[IsHTMLDDA]] internal slot. However, that type is only available for DOM code (not NodeJS) and is deprecated anyways, so I think it's okay to exclude it from this union.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too