Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: DependencyConstraint.d.ts fails to compile due to phantom dependency on "semver" #8259

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't working
@octogonz

Description

@octogonz

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:1

The 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

packageversion
@typescript-eslint/eslint-plugin6.19.0
TypeScript5.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp