isaacs / minimatch

a glob matcher in javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minimatch export with Node16 module/cjs consumer is unfriendly

Gerrit0 opened this issue · comments

TypeDoc uses common js modules, and passes several minimatch instances around. Prior to switching to the builtin types, I could do:

import { Minimatch } from "minimatch";
declare const mm: Minimatch;

After upgrading, due to the Object.assign call in index-cjs.ts which doesn't preserve type exports, I have to do:

import { Minimatch } from "minimatch";
declare const mm: InstanceType<typeof Minimatch>;
commented

Ah, that is kinda crappy. I'll take a look. Getting the hybrid module setup working properly is such a house of cards, I somewhat regret not just biting the bullet and ditching the default export.

(This is the part where I go to the typescript discord and ask you for help fixing it lol...)

commented

Can you try npm install github:isaacs/minimatch#isaacs/gh-194 and see if that fixes the issue? I'm having some trouble reproducing it, I thought I saw it happen, but can't seem to get coc to complain about it anymore.

That seems to work for me, I don't use the default export, so can't speak to that working as intended, but the named export works now

commented

Fixed on v7.1.3

commented

Note: default export has been removed. No way to make it work in all the different scenarios, with various combinations of tsconfig settings. Just do import { minimatch } from 'minimatch' and call it a day :)