typescript-eslint

Is there a way to get the latest TypeScript version supported by `typescript-eslint` programmatically?


I want to update TypeScript to its latest version supported by typescript-eslint.

I tried to use pnpm info typescript-eslint, however, the output either does not include typescript or it is set to support all (*) TS versions.

// pnpm info typescript-eslint peerDependencies
{ eslint: '^8.56.0' }

// pnpm info typescript-eslint devDependencies
{
  'downlevel-dts': '*',
  jest: '29.7.0',
  prettier: '^3.0.3',
  rimraf: '*',
  typescript: '*'
}

// pnpm info typescript-eslint dependencies
{
  '@typescript-eslint/eslint-plugin': '7.1.1',
  '@typescript-eslint/parser': '7.1.1'
}

The only way I could find is to get it from the docs which is not the best way. I could not find any file in their repository which could be used for this purpose.

pnpm i "typescript@$(
  curl -s https://typescript-eslint.io/users/dependency-versions/ | \
    grep -Po 'The version range of TypeScript currently supported is.*<code>\K.*(?=</code>)' | \
    sed 's/&gt;/>/;s/&lt;/</g'
)"

Is there a better way?


Solution

  • You can find this in the root-level package.json in the typescript-eslint repository, under peerDependencies. As of posting (typescript-eslint@7), that's "typescript": ">=4.7.4 <5.4.0".

    https://github.com/typescript-eslint/typescript-eslint/blob/2960201c31b7acf35e747db0bf4b8d2064223f04/package.json#L121