Skip to content

Fix Error TS7016 for imported css-tree types #9131

@regseb

Description

@regseb

What minimal example or steps are needed to reproduce the bug?

  • package.json

    {
      "name": "testcase",
      "version": "1.0.0",
      "type": "module",
      "dependencies": {
        "@types/node": "25.3.5",
        "stylelint": "17.4.0",
        "typescript": "5.9.3"
      }
    }
  • index.ts

    import stylelint from "stylelint";
  1. npm install
  2. npx tsc --module nodenext --strict index.ts

What minimal configuration is needed to reproduce the bug?

Not Applicable.

How did you run Stylelint?

Not Applicable.

Which Stylelint-related dependencies are you using?

None.

What did you expect to happen?

No error.

What actually happened?

node_modules/stylelint/types/stylelint/index.d.ts:4:44 - error TS7016: Could not find a declaration file for module 'css-tree'. '/home/regseb/testcase/node_modules/css-tree/cjs/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/css-tree` if it exists or add a new declaration (.d.ts) file containing `declare module 'css-tree';`

4 import type { Lexer as CSSTreeLexer } from 'css-tree';
                                             ~~~~~~~~~~


Found 1 error in node_modules/stylelint/types/stylelint/index.d.ts:4

Do you have a proposal to fix the bug?

Add @types/css-tree in dependencies.

The bug has been present since version 17.3.0. Maybe the PR Refactor CSSTree lexer creation #9067

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: wipis being worked on by someone

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions