Skip to content

[postcss-nesting] TypeScript definition files #600

Closed
@nathan-alden-sr

Description

@nathan-alden-sr

What would you want to propose?

I am using PNPM, Vite, and SolidJS. I installed postcss-nesting like this:

pnpm add postcss-nesting

I then attempted to include the plugin in vite.config.ts:

import { defineConfig } from "vite";
import eslint from "vite-plugin-eslint";
import solid from "vite-plugin-solid";
import postcssNesting from "postcss-nesting";

export default defineConfig({
  build: {
    target: "esnext"
  },
  css: {
    postcss: {
      plugins: [postcssNesting]
    }
  },
  plugins: [
    solid(),
    eslint({
      include: ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
    })
  ],
  server: {
    port: 3000
  }
});

TypeScript reports the following error:

Could not find a declaration file for module 'postcss-nesting'. 'D:/.../node_modules/.pnpm/[email protected][email protected]/node_modules/postcss-nesting/dist/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/postcss-nesting` if it exists or add a new declaration (.d.ts) file containing `declare module 'postcss-nesting';`ts(7016)

I then created a sibling file to vite.config.ts called postcss-nesting.d.ts:

declare module "postcss-nesting";

That seems to resolve the problem, but it would be nice if this library included the necessary TypeScript definitions so developers don't have to do this. Also, I am unsure of whether my fix is actually a fix, or if I'll see things going wrong later.

FWIW, postcss-nested does have TypeScript definition files.

Suggested solution

Include TypeScript definition files with the NPM package.

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this feature?

  • I'm willing to open a PR

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions