Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): fix TypeScript types #58

Closed
wants to merge 1 commit into from
Closed

fix(types): fix TypeScript types #58

wants to merge 1 commit into from

Conversation

remcohaszing
Copy link
Contributor

This only includes the TypeScript type fixes from #57.


CommonJS

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

Before

// ✗ TypeError
require('clsx')('')

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

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

After

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

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

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

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

Before

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

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

After

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

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

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

Before

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

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

After

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

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

@lukeed
Copy link
Owner

lukeed commented Jul 15, 2023

Superseded by #57. Thank you

@lukeed lukeed closed this Jul 15, 2023
@remcohaszing remcohaszing deleted the fix-types branch July 16, 2023 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants