-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
ESM Import Failing - v6.0.0 #189
Comments
What version of typescript are you using? This works for me:
import minimatch from 'minimatch'
export class Test {
untrackedFilePatterns: string[] = ['a', 'b', 'c']
protected isFileUntracked(
pathRelativeToContainer: string
): string | undefined {
return this.untrackedFilePatterns.find(pattern =>
minimatch(pathRelativeToContainer, pattern)
)
}
} |
Oh, you said you're using 4.9.4. Then I wonder what's going on there...? |
Aha, I was able to reproduce it. This is weird. |
In the short term, you can |
That worked 👍 |
It's really weird, like, I see this in the d.ts: export declare const minimatch: {
// v-- THIS IS A CALL SIGNATURE, WAT!?
(p: string, pattern: string, options?: MinimatchOptions): boolean;
sep: string;
GLOBSTAR: typeof GLOBSTAR;
filter: (pattern: string, options?: MinimatchOptions) => (p: string) => boolean;
defaults: (def: MinimatchOptions) => typeof minimatch;
braceExpand: (pattern: string, options?: MinimatchOptions) => string[];
makeRe: (pattern: string, options?: MinimatchOptions) => false | MMRegExp;
match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
Minimatch: typeof Minimatch;
};
// v-- IT IS THE DEFAULT EXPORT! THE THING WITH THE CALL SIGNATURE!
export default minimatch; but then:
|
Possibly a typescript bug, I know it took them a significant effort to support ESM in the first place. |
Aha, if you use |
That disables ESM and uses commonjs https://www.typescriptlang.org/tsconfig#node16nodenext-nightly-builds |
Ok, this gets even stranger. After experimenting with it a bit and trying to work out a minimal test case, now I can't reproduce the error, even starting from the exact same setup where I was reproducing it before. This definitely feels like a strangely non-deterministic TS bug. I'm going to update the readme and call it fixed 😂 |
Works for me, I prefer names imports anyway haha |
Same issue as isaacs/minimatch#189
This is the TS issue: microsoft/TypeScript#50466 "Proper" (ugly) fix incoming. |
Just to follow up here, I tried using |
@redonkulus What version of minimatch? Should be fixed on latest. |
I tried this morning on the latest version from npm. |
@redonkulus Ah, indeed. Updated Fixed on a4fa1f8, published 6.1.6 |
- solution was suggested in isaacs/minimatch#189
|
minimatch - 6.0.0
typescript - 4.9.4
node - 16.17.0
Error:
Usage:
tsconfig
The text was updated successfully, but these errors were encountered: