Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node_modules/glob/dist/mjs/index"' has no exported member 'IOptions'. && Minipass type error #529

Closed
YashRaniga opened this issue May 17, 2023 · 4 comments

Comments

@YashRaniga
Copy link

YashRaniga commented May 17, 2023

I am currently trying to upgrade glob from version 8.1.0 to 10.2.4 (as long as I have version 9.x.x or higher it's fine). @types/glob version is 8.1.0. When running npm run build, the following error comes:

PS > npm run build

infrastructure/copy-files.ts:15:27 - error TS2694: Namespace '"node_modules/glob/dist/mjs/index"' has no exported member 'IOptions'.

15     let globOptions: glob.IOptions = {};
                             ~~~~~~~~

node_modules/glob/node_modules/minipass/index.d.ts:148:3 - error TS2416: Property 'on' in type 'Minipass<RType, WType, Events>' is not assignable to the same property in base type 'Stream'.
  Type '<Event extends keyof Events>(ev: Event, handler: (...args: Events[Event]) => any) => this' is not assignable to type '(eventName: string | symbol, listener: (...args: any[]) => void) => this'.
    Types of parameters 'ev' and 'eventName' are incompatible.
      Type 'string | symbol' is not assignable to type 'keyof Events'.
        Type 'symbol' is not assignable to type 'keyof Events'.
          Type 'symbol' is not assignable to type 'keyof Events<RType>'.

148   on<Event extends keyof Events>(
      ~~

node_modules/glob/node_modules/minipass/index.d.ts:153:3 - error TS2416: Property 'once' in type 'Minipass<RType, WType, Events>' is not assignable to the same property in base type 'Stream'.
  Type '<Event extends keyof Events>(ev: Event, handler: (...args: Events[Event]) => any) => this' is not assignable to type '(eventName: string | symbol, listener: (...args: any[]) => void) => this'.
    Types of parameters 'ev' and 'eventName' are incompatible.
      Type 'string | symbol' is not assignable to type 'keyof Events'.
        Type 'symbol' is not assignable to type 'keyof Events'.

153   once<Event extends keyof Events>(
      ~~~~

node_modules/glob/node_modules/minipass/index.d.ts:158:3 - error TS2416: Property 'addListener' in type 'Minipass<RType, WType, Events>' is not assignable to the same property in base type 'Stream'.
  Type '<Event extends keyof Events>(ev: Event, handler: (...args: Events[Event]) => any) => this' is not assignable to type '(eventName: string | symbol, listener: (...args: any[]) => void) => this'.
    Types of parameters 'ev' and 'eventName' are incompatible.
      Type 'string | symbol' is not assignable to type 'keyof Events'.
        Type 'symbol' is not assignable to type 'keyof Events'.

158   addListener<Event extends keyof Events>(
      ~~~~~~~~~~~
        Type 'symbol' is not assignable to type 'keyof Events'.

163   emit<Event extends keyof Events>(ev: Event, ...data: Events[Event]): boolean
      ~~~~


Found 5 errors in 2 files.

Errors  Files
     1  copy-files.ts:15
     4  node_modules/glob/node_modules/minipass/index.d.ts:148

Gone through multiple stack overflow threads, none of them have worked. Saw one thread where apparently @types/glob isn't required but removing that didn't work. Running npm install minipass also didn't fix the minipass errors

@isaacs
Copy link
Owner

isaacs commented May 17, 2023

You definitely should not have the @types packages for minipass or glob.

What version of typescript are you using?

What does npm ls glob minipass typescript output?

@isaacs
Copy link
Owner

isaacs commented May 17, 2023

Oh also, what's in copy-files.ts?

@YashRaniga
Copy link
Author

YashRaniga commented May 17, 2023

Typescript version: "typescript": "^5.0.2",

Output of npm ls glob minipass typescript:

+-- @commitlint/cli@17.5.0
| `-- @commitlint/load@17.5.0
|   +-- cosmiconfig-typescript-loader@4.3.0
|   | `-- typescript@5.0.2 deduped
|   `-- typescript@5.0.2 deduped
+-- @typescript-eslint/eslint-plugin@5.56.0
| `-- tsutils@3.21.0
|   `-- typescript@5.0.2 deduped
+-- eslint-config-typescript@3.0.0
| `-- typescript@5.0.2 deduped
+-- eslint@8.36.0
| `-- file-entry-cache@6.0.1
|   `-- flat-cache@3.0.4
|     `-- rimraf@3.0.2
|       `-- glob@7.2.3
+-- gherkin-lint@4.2.2
| `-- glob@7.1.6
+-- glob@10.2.4
| +-- minipass@6.0.1
| `-- path-scurry@1.9.1
|   `-- minipass@6.0.1
+-- ibm-openapi-validator@0.97.5
| `-- @stoplight/spectral-cli@6.5.1
|   +-- @rollup/plugin-commonjs@20.0.0
|   | `-- glob@7.2.3
|   `-- @stoplight/spectral-ruleset-bundler@1.3.2
|     `-- @rollup/plugin-commonjs@22.0.2
|       `-- glob@7.2.3
+-- license-checker@25.0.1
| `-- read-installed@4.0.3
|   `-- read-package-json@2.1.2
|     `-- glob@7.2.3
+-- mocha@10.2.0
| `-- glob@7.2.0
+-- npm-upgrade@3.1.0
| +-- del@6.0.0
| | `-- rimraf@3.0.2
| |   `-- glob@7.2.3
| +-- npm-check-updates@11.1.9
| | `-- rimraf@3.0.2
| |   `-- glob@7.2.3
| +-- pacote@11.2.7
| | +-- @npmcli/run-script@1.8.6
| | | `-- node-gyp@7.1.2
| | |   +-- glob@7.2.3
| | |   `-- rimraf@3.0.2
| | |     `-- glob@7.2.3 deduped
| | +-- cacache@15.3.0
| | | +-- @npmcli/move-file@1.1.2
| | | | `-- rimraf@3.0.2
| | | |   `-- glob@7.2.3
| | | +-- glob@7.2.3
| | | +-- minipass-collect@1.0.2
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass-flush@1.0.5
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass-pipeline@1.2.4
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass@3.3.4 deduped
| | | `-- rimraf@3.0.2
| | |   `-- glob@7.2.3 deduped
| | +-- fs-minipass@2.1.0
| | | `-- minipass@3.3.4 deduped
| | +-- minipass@3.3.4
| | +-- npm-packlist@2.2.2
| | | `-- glob@7.2.3
| | +-- npm-registry-fetch@9.0.0
| | | +-- make-fetch-happen@8.0.14
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass-fetch@1.4.1
| | | | +-- minipass-sized@1.0.3
| | | | | `-- minipass@3.3.4 deduped
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass-json-stream@1.0.1
| | | | `-- minipass@3.3.4 deduped
| | | +-- minipass@3.3.4 deduped
| | | `-- minizlib@2.1.2
| | |   `-- minipass@3.3.4 deduped
| | +-- rimraf@3.0.2
| | | `-- glob@7.2.3
| `-- test-exclude@6.0.0
|   `-- glob@7.2.3
+-- rimraf@5.0.0
| `-- glob@10.2.4 deduped
+-- ts-node@10.9.1
| `-- typescript@5.0.2 deduped
`-- typescript@5.0.2

copy-files.ts is a file which contains a method which copies all files from a source directory to a destination directory

export async function copyFolder(sourceDir: string, destDir: string, exclude?: string[]) {
    let globOptions: glob.IOptions = {};
    if (exclude) {
        globOptions = { ignore: exclude };
    }

this is a snippet of code where the IOptions error occurs

@isaacs
Copy link
Owner

isaacs commented May 17, 2023

The minipass error is fixed on the latest release, npm update minipass should fix it.

   let globOptions: glob.IOptions = {};

glob.IOptions isn't a thing anymore. That was just a DefinitelyTyped-ism.

Do this:

import type { GlobOptions } from 'glob'
export async function copyFolder(sourceDir: string, destDir: string, exclude?: string[]) {
    let globOptions: GlobOptions = {};

If you know that you will/won't use withFiletypes: true, you can also use GlobOptionsWithFileTypesTrue or GlobOptionsWithFileTypesFalse explicitly, so that your return values will be more conveniently string or Path instead of string | Path.

isaacs added a commit that referenced this issue May 17, 2023
This requires the minipass with the fixed EventEmitter types, and also
the tsconfig setting that let the error slip past in the first place.

Re: #529
Re: isaacs/minipass#49
isaacs added a commit to isaacs/rimraf that referenced this issue May 17, 2023
This requires the minipass with the fixed EventEmitter types, and also
the tsconfig setting that let the error slip past in the first place.

Re: isaacs/node-glob#529
Re: isaacs/minipass#49
DanTup added a commit to Dart-Code/Dart-Code that referenced this issue Jul 19, 2023
These are causing errors on CI since the upgrade and isaacs/node-glob#529 (comment) says they shouldn't be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants