pahen / madge

Create graphs from your CommonJS, AMD or ES6 module dependencies
MIT License
9.09k stars 317 forks source link

Madge is not detecting the right version of Typescript and incorrect warning #416

Open AddictArts opened 7 months ago

AddictArts commented 7 months ago

My root package.json

`"typescript": "5.2.2",

No other file has "typescript" in it. My global npm

`"typescript": "5.2.2",

I checked the node_modules/typescript/package.json

I also used qnm

qnm typescipt

qnm typescript
typescript 5.4.5 ↰ 1 week ago
├── 5.2.2 ⇡ 7 months ago
└─┬ config-file-ts
  └── 4.9.5 ⇡ 1 year ago

5.2.2 is installed. I ripgrep for 5.4.5 and nothing. I can't determine how madge thinks I have 5.4.5.

I still get

⠋ Finding files=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.2.0

YOUR TYPESCRIPT VERSION: 5.4.5

Please only submit bug reports when using the officially supported version.

=============
Processed 45 files (674ms) (2 warnings)
tetedacier commented 7 months ago

If you run npm ls typescript @typescript-eslint/typescript-estree you should be able to find the dependencies tree related to your problem.

Lately, I run into a similar issues and forces those packages version package.json overrides mechanism:

{
    ...
    "overrides": {
        ...
        "@typescript-eslint/eslint-plugin": "7.7.0",
        "@typescript-eslint/utils": "7.7.0",
        "@typescript-eslint/parser": "7.7.0",
        ...
        "typescript": "5.4.5",
        ...
    },
    ...
}

The issue you mentioned disappeared and my project was still operational 😎

AddictArts commented 7 months ago

@tetedacier thanks, I cannot use overrides, but I tested and it didn't eliminate the warning from madge.

❯ npm ls typescript @typescript-eslint/typescript-estree
something@0.9.0 D:\something
+-- @something/electron@0.9.0 -> .\apps\electron
| `-- electron-builder@24.9.1
|   `-- read-config-file@6.3.2
|     `-- config-file-ts@0.2.4
|       `-- typescript@4.9.5
+-- @typescript-eslint/eslint-plugin@7.7.0
| +-- @typescript-eslint/type-utils@7.7.0
| | `-- @typescript-eslint/typescript-estree@7.7.0 deduped
| +-- @typescript-eslint/utils@7.7.0
| | `-- @typescript-eslint/typescript-estree@7.7.0 deduped
| `-- ts-api-utils@1.3.0
|   `-- typescript@5.1.6 deduped
+-- @typescript-eslint/parser@7.7.0
| `-- @typescript-eslint/typescript-estree@7.7.0
`-- typescript@5.1.6

I downgraded to 5.1.6. It is not identifying typescript version correctly.

Ejdamm commented 6 months ago

I ran npm ls typescript @typescript-eslint/typescript-estree and it looks like the wrong version comes from precinct which is a dependency of madge itself

├─┬ madge@7.0.0
│ ├─┬ dependency-tree@10.0.9
│ │ ├─┬ filing-cabinet@4.2.0
│ │ │ └── typescript@5.0.4 deduped
│ │ └── typescript@5.0.4 deduped
│ ├─┬ precinct@11.0.5
│ │ └─┬ detective-typescript@11.2.0
│ │   ├── @typescript-eslint/typescript-estree@5.62.0
│ │   └── typescript@5.4.5
│ └── typescript@5.0.4 deduped

After overriding in package.json as tetedacier suggested the warning disappeared

"overrides": {
    ...
    "typescript": "5.0.4"
}
├─┬ madge@7.0.0
│ ├─┬ dependency-tree@10.0.9
│ │ ├─┬ filing-cabinet@4.2.0
│ │ │ └── typescript@5.0.4 deduped
│ │ └── typescript@5.0.4 deduped
│ ├─┬ precinct@11.0.5
│ │ └─┬ detective-typescript@11.2.0
│ │   ├── @typescript-eslint/typescript-estree@5.62.0
│ │   └── typescript@5.0.4 deduped
│ └── typescript@5.0.4 deduped