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

Add type declaration #117

Closed
wants to merge 1 commit into from
Closed

Add type declaration #117

wants to merge 1 commit into from

Conversation

zanona
Copy link
Contributor

@zanona zanona commented May 4, 2022

This PR adds the ability to import the package under typescript.
My use case has been importing tailwind configuration directly inside vite.config.ts files and as such, I had to manually declare the types for @tailwindcss/forms.

Since my package was set to type: module I could not use require either.

// vite.config.ts
import autoprefixer from "autoprefixer";
import tailwindcss from "tailwindcss";
import tailwindcssForms from "@tailwindcss/forms";
import { defineConfig } from "vite";

export default defineConfig(() => ({
  css: {
    postcss: {
      plugins: [
        tailwindcss({
          content: ["./index.html", "../../{apps,libs}/**/*.{ts,tsx}"],
          plugins: [tailwindcssForms],
          //plugins: [tailwindcssForms({strategy: 'class'})],
          theme: {},
        }),
        autoprefixer(),
      ],
    },
  },
}));

The types added include support for the strategy option as well.

@vercel
Copy link

vercel bot commented May 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
tailwindcss-forms ✅ Ready (Inspect) Visit Preview May 4, 2022 at 8:55AM (UTC)

@RobinMalfait
Copy link
Member

Hey! Thank you for your PR!
Much appreciated! 🙏

I've made some changes and create a new PR (#118) based on your initial work. Made a few changes so that we don't rely on the @types/tailwindcss since we will be release our own types so within the repo.

Also updated export default plugin to export = plugin since it is a cjs file and not a esm file. Did some testing and the import plugin from '@tailwindcss/forms' should just work even with the export = plugin 👍

@zanona
Copy link
Contributor Author

zanona commented May 18, 2022

That's great. Thanks a lot for your help and taking the time to improve it, Robin. 😀

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