lukeed / clsx

A tiny (239B) utility for constructing `className` strings conditionally.
MIT License
8.08k stars 141 forks source link

fix: allow `bigint` in typings #96

Closed ViliamKopecky closed 4 months ago

ViliamKopecky commented 4 months ago

ReactNode from @types/react now includes bigint (and its 0n zero which is falsy) and that is incompatible with clsx in these scenarios:

declare const x: ReactNode

const className = clsx(x && 'some-class')
// Argument of type 'false | "" | 0 | 0n | "some-class" | null | undefined' is not assignable to parameter of type 'ClassValue'.
//  Type '0n' is not assignable to type 'ClassValue'.
lukeed commented 4 months ago

Thanks! I’ll merge and publish tomorrow. Traveling for work right now & haven’t had a chance to open laptop

lukeed commented 4 months ago

Included in 2.1.1