JNavith / tailwindcss-theme-variants

Media-query- or JavaScript-based theme variants with fallback for Tailwind CSS
https://tailwindcss-theme-variants.web.app/
MIT License
188 stars 5 forks source link

Cannot find module './types' or its corresponding type declarations. #23

Open ackvf opened 6 months ago

ackvf commented 6 months ago

Hi, when I tried to use the following utility, I converted my tailwind.config.js to .ts to get better intellisense

import tailwindConfig from 'tailwind-config'
import resolveConfig from 'tailwindcss/resolveConfig'

const twFullConfig = resolveConfig(tailwindConfig)

// twFullConfig.theme.colors.dark[100] // 🗸

But then I started receiving strange errors and it's rather confusing

This doesn't work

// tailwind.config.ts
import { themeVariants } from 'tailwindcss-theme-variants'
import { type Config } from 'tailwindcss'

// The inferred type of 'twConfig' cannot be named without a reference to 'tailwindcss-theme-variants/node_modules/tailwindcss/types/config'. This is likely not portable. A type annotation is necessary.ts(2742)
const config = { /* ... */ } as const satisfies Config

export default config

This works

const config: Config = { /* ... */ }

Which finally led me to this error

$ tsc tailwind.config.ts
../../node_modules/tailwindcss-theme-variants/index.d.ts:1:40 - error TS2307: Cannot find module './types' or its corresponding type declarations.

1: import type { ThisPluginOptions } from "./types";

And when I look in the module, there is really no such folder.

image