Description
Repro
Create a TypeScript file that imports the @typescript-eslint
library like this:
index.ts
import { TSESLint } from '@typescript-eslint/experimental-utils';
Expected Result
The code compiles without errors using an older compiler (TypeScript 3.5 in our case).
Actual Result
Compilers older than TypeScript 3.7 fail to build:
error TS2307: Cannot find module '@typescript-eslint/experimental-utils'.
The reason is that the excerpt below is using a newer language feature that is not supported by older compilers:
@typescript-eslint/experimental-utils/dist/index.d.ts
export * from './AST';
export * from './CLIEngine';
. . .
Additional Info
It would be nice for projects to always use the latest TypeScript compiler version. However, in large production code bases, upgrading the compiler can involve a lot of work. For example, maybe there are custom plugins or tools that need to be updated to work with the latest compiler engine. Or the upgrades may be blocked behind the release of a customer SDK that targets a specific TypeScript version.
The TypeScript group does not guarantee that .d.ts files will be backwards compatible for a previous minor version. (The 3.7 release famously broke backwards compatibility even for source code that avoids using any new language features.)
The recommendation is for libraries to use the downlevel-dts tool to rewrite the .d.ts outputs to be backwards compatible with earlier compiler releases.
Versions
package | version |
---|---|
@typescript-eslint/experimental-utils |
3.3.0 |
TypeScript |
3.5.3 |
node |
12.17.0 |
npm |
6.14.4 |