lukeed/clsxPublic

A tiny (239B) utility for constructing `className` strings conditionally.

fix(types): fix TypeScript types #58

Closedremcohaszingclosed 1 commit intomasterfromrefs/pull/58/head
  1. RE

    This only includes the TypeScript type fixes from #57.

    ---

    CommonJS

    ```jsonc tsconfig.json { "compilerOptions": { "checkJs": true } } ```

    Before ```js // ✗ TypeError require('clsx')('')

    // ✔️ Ok require('clsx').clsx('')

    // ✗ Runtime error require('clsx').default('') ```

    After ```js // ✔️ Ok require('clsx')('')

    // ✔️ Ok require('clsx').clsx('')

    // ✔️ Runtime and type error require('clsx').default('') ```

    ---

    ```jsonc // tsconfig.json { "compilerOptions": { "module": "node16" } } ```

    Before ```js import clsx from 'clsx' // ✗ TypeError clsx('') // ✗ TypeError clsx.clsx('') // ✗ Runtime error clsx.default('')

    // ✗ TypeError import { clsx } from 'clsx' ```

    After ```js import clsx from 'clsx' // ✔️ Ok clsx('') // ✔️ Ok clsx.clsx('') // ✔️ Runtime error and type error clsx.default('')

    // ✗ TypeError import { clsx } from 'clsx' ```

    ---

    ```jsonc // tsconfig.json { "compilerOptions": { "esModuleInterop": true } } ```

    Before ```js import clsx from 'clsx' // ✔️ Ok clsx('') // ✗ TypeError clsx.clsx('') // ✔️ Type error and runtime error clsx.default('')

    // ✔️ Ok import { clsx } from 'clsx' ```

    After ```js import clsx from 'clsx' // ✔️ Ok clsx('') // ✔️ Ok clsx.clsx('') // ✔️ Type error and runtime error clsx.default('')

    // ✔️ Ok import { clsx } from 'clsx' ```

  2. LU

    Superseded by #57. Thank you

  3. lukeedclosed3 years ago on GitHub

  4. remcohaszinghead-ref-deleted3 years ago on GitHub