Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Relevant Package
rule-tester
Repro Code
TrytocompileanESLintpluginprojectwiththiscodeand`skipLibCheck: false`in**tsconfig.json**:import{ RuleTester}from'@typescript-eslint/rule-tester';
Expected Result
The code should compile without errors.
Actual Result
tsc reports a build failure like this:
../../common/temp/node_modules/.pnpm/@typescript-eslint+rule-tester@6.19.0_@eslint+eslintrc@3.0.0_eslint@8.7.0_typescript@5.3.3/node_modules/@typescript-eslint/rule-tester/dist/types/DependencyConstraint.d.ts:1:35 - error TS7016: Could not find a declaration file for module 'semver'. 'C:/Git/rushstack/common/temp/node_modules/.pnpm/semver@7.5.4/node_modules/semver/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/semver` if it exists or add a new declaration (.d.ts) file containing `declare module 'semver';`1 import type { RangeOptions } from 'semver'; ~~~~~~~~Found 1 error in ../../common/temp/node_modules/.pnpm/@typescript-eslint+rule-tester@6.19.0_@eslint+eslintrc@3.0.0_eslint@8.7.0_typescript@5.3.3/node_modules/@typescript-eslint/rule-tester/dist/types/DependencyConstraint.d.ts:1The problem is caused by this code:
| importtype{RangeOptions}from'semver'; | |
| exportinterfaceSemverVersionConstraint{ | |
| readonlyrange:string; | |
| readonlyoptions?:RangeOptions|boolean; |
It imports types from"semver", but that dependency is not declared inpackage.json.
Using an old-fashionedinstallation model such as NPM or Yarn Classic, then thesemver package will likely get "hoisted" allowing the compiler to load typings from asemver folder installed to satisfy some other unrelated package. However with a modern installation model such as Yarn Plug'n'Play or PNPM, the import will fail; this is more correct behavior, because dependency versions should be explicitly specified rather than fished out of anode_modules folder with no idea what version you will get.
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin | 6.19.0 |
TypeScript | 5.3.3 |