dtslint: estree has no exported member


TL;DR: Install @types/estree:

npm i -D @types/estree

This article goes over how to fix the dtslint error: estree has no exported member.

Problem

If you run dtslint:

npx dtslint .

And get the error:

Error: Errors in [email protected] for external dependencies:
node_modules/@types/eslint/index.d.ts(450,42): error TS2724: '"./node_modules/@types/estree/index"' has no exported member named 'ChainExpression'. Did you mean 'ThisExpression'?
node_modules/@types/eslint/index.d.ts(473,43): error TS2694: Namespace '"./node_modules/@types/estree/index"' has no exported member 'ImportExpression'.

    at ./node_modules/dtslint/bin/index.js:207:19
    at Generator.next (<anonymous>)
    at fulfilled (./node_modules/dtslint/bin/index.js:6:58)

This means there’s a conflicting @types/estree version in your node_modules:

npm ls @types/estree
├─┬ @rollup/[email protected]
│ ├─┬ @rollup/[email protected]
│ │ └── @types/[email protected]
│ └─┬ [email protected]
│   └── @types/[email protected] deduped
└─┬ [email protected]
  ├─┬ @types/[email protected]
  │ ├─┬ @types/[email protected]
  │ │ └── @types/[email protected] deduped
  │ └── @types/[email protected] deduped
  └── @types/[email protected]

Solution

The fix is to install @types/estree:

npm install --save-dev @types/estree

This ensures the deduped versions are using the latest version:

npm ls @types/estree
├─┬ @rollup/[email protected]
│ ├─┬ @rollup/[email protected]
│ │ └── @types/[email protected]
│ └─┬ [email protected]
│   └── @types/[email protected] deduped
├── @types/[email protected]
└─┬ [email protected]
  ├─┬ @types/[email protected]
  │ ├─┬ @types/[email protected]
  │ │ └── @types/[email protected] deduped
  │ └── @types/[email protected] deduped
  └── @types/[email protected] deduped

You should be able to run dtslint without issues now:

npx dtslint .


Please support this site and join our Discord!