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

Missing declaration file for "tailwindcss/resolveConfig" #8920

Closed
joshmossas opened this issue Jul 21, 2022 · 8 comments
Closed

Missing declaration file for "tailwindcss/resolveConfig" #8920

joshmossas opened this issue Jul 21, 2022 · 8 comments

Comments

@joshmossas
Copy link
Contributor

What version of Tailwind CSS are you using?

For example: v3.1.6

What build tool (or framework if it abstracts the build tool) are you using?

Vite, Typescript

What version of Node.js are you using?

For example: v16.15.1

What browser are you using?

Chrome

What operating system are you using?

Windows 10

Reproduction URL

https://github.com/joshmossas/tailwindcss-resolve-config-missing-types

Describe your issue

When attempting to use the resolveConfig helper in a typescript project you get a type error Could not find a declaration file for module 'tailwindcss/resolveConfig'.

@joshmossas
Copy link
Contributor Author

joshmossas commented Jul 21, 2022

For anyone that needs a quick work-around, create a .d.ts file (ex tailwind-resolve-config.d.ts) in your types/typings directory with the following

declare module 'tailwindcss/resolveConfig' {
    import type { Config } from 'tailwindcss';

    declare function resolveConfig(config: Config): Config;
    export = resolveConfig;
}

@thecrypticace
Copy link
Contributor

Hey, I merged in your PR. This will be in our insiders build until we tag a new release (likely tomorrow). Thanks again for the PR! 🎉

@robclancy
Copy link

I am using some utils, would be nice if all of them had types. Here is what I've done to add some.

declare module "tailwindcss/src/util/normalizeScreens" {
  import {
    ResolvableTo,
    Screen,
    ScreensConfig,
  } from "tailwindcss/types/config";

  type ScreenDefinition = {
    name: string;
    values: Screen;
  };

  export function normalizeScreens(
    screens: ResolvableTo<ScreensConfig>
  ): ScreenDefinition[];
}

declare module "tailwindcss/src/util/buildMediaQuery" {
  import { ScreenDefinition } from "tailwindcss/src/util/normalizeScreens";

  function buildMediaQuery(screen: ScreenDefinition): string;

  export = buildMediaQuery;
}

@thecrypticace
Copy link
Contributor

@robclancy Those utils are not part of the Tailwind CSS public API so we are not likely to add types for them.

@Sidnioulz
Copy link

If it's not part of your public API, why is it on your public documentation?

https://tailwindcss.com/docs/configuration#referencing-in-java-script

@thecrypticace
Copy link
Contributor

@Sidnioulz No they're not. My comment was about normalizeScreens and buildMediaQuery from the comment above hence why I was replying to said comment. I was not talking about resolveConfig.

@Sidnioulz
Copy link

@thecrypticace aaaand I read too fast. My sincerest apologies! 😱

@thecrypticace
Copy link
Contributor

@Sidnioulz All good!

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

No branches or pull requests

4 participants