plantain-00 / type-coverage

A CLI tool to check type coverage for typescript code
MIT License
1.26k stars 44 forks source link

Crash `minimatch_1.default` is not a function #122

Open wooorm opened 1 year ago

wooorm commented 1 year ago

Version(if relevant): 2.25.1

Environment(if relevant): Node (checked on 18, 19, and 20)

Code(if relevant):

./node_modules/.bin/type-coverage

Expected:

Works fine :)

Actual:

$ ./node_modules/.bin/type-coverage
(0 , minimatch_1.default) is not a function

type-coverage just started failing today: https://github.com/wooorm/import-meta-resolve/pull/16/files. This PR does nothing with types, but the action is pulling in latest deps, which crashes.

So, seems something is up with minimatch:

$ npm ls minimatch
import-meta-resolve@3.0.0 /Users/tilde/Projects/oss/import-meta-resolve
├─┬ c8@7.13.0
│ ├─┬ rimraf@3.0.2
│ │ └─┬ glob@7.2.3
│ │   └── minimatch@3.1.2 deduped
│ └─┬ test-exclude@6.0.0
│   └── minimatch@3.1.2
├─┬ remark-cli@11.0.0
│ └─┬ unified-args@10.0.0
│   └─┬ unified-engine@10.1.0
│     ├─┬ glob@8.1.0
│     │ └── minimatch@5.1.6
│     └─┬ load-plugin@5.1.0
│       └─┬ @npmcli/config@6.1.6
│         └─┬ @npmcli/map-workspaces@3.0.4
│           ├─┬ glob@10.2.2
│           │ └── minimatch@9.0.0 deduped
│           └── minimatch@9.0.0
├─┬ type-coverage@2.25.1
│ └─┬ type-coverage-core@2.25.1
│   └── minimatch@3.1.2 deduped
└─┬ xo@0.54.2
  ├─┬ @eslint/eslintrc@1.4.1
  │ └── minimatch@3.1.2 deduped
  ├─┬ eslint-plugin-import@2.27.5
  │ └── minimatch@3.1.2 deduped
  ├─┬ eslint-plugin-n@15.7.0
  │ └── minimatch@3.1.2 deduped
  └─┬ eslint@8.39.0
    ├─┬ @eslint/eslintrc@2.0.2
    │ └── minimatch@3.1.2 deduped
    ├─┬ @humanwhocodes/config-array@0.11.8
    │ └── minimatch@3.1.2 deduped
    └── minimatch@3.1.2 deduped

I guess type-coverage is importing minimatch 9 somehow? It looks like minimatch 9 (3 weeks ago) removed the default export: https://github.com/isaacs/minimatch/blob/main/changelog.md.

plantain-00 commented 1 year ago

v2.25.2 should supports minimatch@9 now.

ribeaud commented 1 year ago

Mmmmh... Does not solve the problem on my side. But I am now unsure whether the problem is purely related to type-coverage:

> npm ls minimatch
biomedit-portal-frontend@5.3.1-dev.7 /Users/christianr/Documents/workspace/portal/frontend
├─┬ @next/eslint-plugin-next@13.3.4
│ └─┬ glob@7.1.7
│   └── minimatch@3.1.2 deduped
├─┬ @openapitools/openapi-generator-cli@2.6.0
│ └─┬ glob@7.1.6
│   └── minimatch@3.1.2 deduped
├─┬ depcheck@1.4.3
│ ├── minimatch@3.1.2
│ └─┬ multimatch@5.0.0
│   └── minimatch@3.1.2 deduped
├─┬ dpdm@3.13.0
│ └─┬ glob@9.3.5
│   └── minimatch@8.0.4
├─┬ eslint-plugin-react@7.32.2
│ └── minimatch@3.1.2 deduped
├─┬ eslint@8.40.0
│ ├─┬ @eslint/eslintrc@2.0.3
│ │ └── minimatch@3.1.2 deduped
│ ├─┬ @humanwhocodes/config-array@0.11.8
│ │ └── minimatch@3.1.2 deduped
│ └── minimatch@3.1.2 deduped
├─┬ jest@29.5.0
│ └─┬ @jest/core@29.5.0
│   └─┬ @jest/transform@29.5.0
│     └─┬ babel-plugin-istanbul@6.1.1
│       └─┬ test-exclude@6.0.0
│         └── minimatch@3.1.2 deduped
├─┬ npm-run-all@4.1.5
│ └── minimatch@3.1.2 deduped
├─┬ rimraf@5.0.0
│ └─┬ glob@10.2.2
│   └── minimatch@9.0.0
└─┬ type-coverage@2.25.2
  └─┬ type-coverage-core@2.25.2
    └── minimatch@3.1.2 deduped

I came across this issue and hoped to find some help here. The problematic MR on our side is here.

I found out that if I remove --ignore-files from the invocation, the command is successful. If we have a look at my dependencies tree, we see that minimatch@9.0.0 will be installed for glob. Could that be the problem?

plantain-00 commented 1 year ago

@ribeaud v2.25.3 should fix this

ribeaud commented 1 year ago

I indeed did. Thank you! 💪

wooorm commented 1 year ago

think this can be closed?

simoneguzzi commented 1 month ago

Hi All! 👋

After upgrading to v2.29.6, I experience a similar issue, but with normalize-path:

❯ node_modules/.bin/type-coverage -p tsconfig.json --strict
(0 , normalize_path_1.default) is not a function

Could this change be related?

wooorm commented 1 month ago

I had forgotten about this issue but I just had many builds fail as well. https://github.com/wooorm/wooorm.github.io/actions/runs/11341385777, https://github.com/unifiedjs/github-tools/actions/runs/11341624394, https://github.com/unifiedjs/npm-tools/actions/runs/11341980179.

So, while I think this was fixed, perhaps it was re-introduced somehow?

plantain-00 commented 1 month ago

Hi All! 👋

After upgrading to v2.29.6, I experience a similar issue, but with normalize-path:

❯ node_modules/.bin/type-coverage -p tsconfig.json --strict
(0 , normalize_path_1.default) is not a function

Could this change be related?

Seems so, I will revert it in v2.29.7

plantain-00 commented 1 month ago

It should be OK now.

simoneguzzi commented 1 month ago

It should be OK now.

Can confirm. Thanks for the timely fix ❤️

wooorm commented 1 month ago

Same, I can confirm things work. Thanks!