Skip to content

Instantly share code, notes, and snippets.

@filipenevola
Created January 27, 2022 13:27
Show Gist options
  • Save filipenevola/f7cc0032ffac2020b15d5dc1e235639b to your computer and use it in GitHub Desktop.
Save filipenevola/f7cc0032ffac2020b15d5dc1e235639b to your computer and use it in GitHub Desktop.
how to avoid errors coming from a dependent module in typedefs
Filipe Névola Jan 25th at 1:40 PM
@channel does anyone know how to avoid errors coming from a dependent module in typedefs?
I would like to ignore mongodb typedefs checks: https://github.com/DefinitelyTyped/DefinitelyTyped/commit/e978da68b45cd896df143160d910218c5ef89306/checks?check_suite_id=5038300272
This is the PR https://github.com/DefinitelyTyped/DefinitelyTyped/pull/58433
tomche 1 day ago
skipLibCheck: true maybe?
Stephan Meijer 1 day ago
Or override them in a .d.ts, extending the namespace
Stephan Meijer 1 day ago
Which is imo better, because otherwise you'll skip all libs. That might not be what you want.
Stephan Meijer 1 day ago
exclude in your tsconfig might also be of help, if excluding is what you want.
https://www.typescriptlang.org/tsconfig#exclude
Filipe Névola 1 day ago
skipLibCheck: true maybe?
at least locally this doesn't work in this case.
Filipe Névola 1 day ago
exclude in your tsconfig might also be of help, if excluding is what you want.
doesn't work either
Filipe Névola 1 day ago
I believe these solutions above doesn't work because they are for typedefs and not for the lint of the typedefs. DefinitelyTyped uses a specific lint for typedefs and it seems this lint doesn't consider these options.
Filipe Névola 1 day ago
Or override them in a .d.ts, extending the namespace
Hmm, I think I don't get it. What exactly should I do?
Stephan Meijer 1 day ago
Create a ./global.d.ts file in your project. And update tsconfig.json to include:
{
"include": ["./global.d.ts"]
}
Then in the global.d.ts (name it whatever you like), you'll extend/override the mongo namespace to include your signatures so they don't error any more.
declare module mongodb {
export interface Collection {
find: any
}
}
TypeScript will merge interfaces. So that way you can make them less strict, or add support to missing props.
Stephan Meijer 1 day ago
But looking at that PR, that might not be what you need. I see that basically all methods are erroring. Weird. :confused:
Filipe Névola 15 hours ago
Yes and this is not my project, this is Meteor types from DefinitelyTyped.
When @Per added mongodb as a dependency instead of mongodb types it starts to produce these errors but I'm not sure how to prevent DefinitelyTyped from validating the types in our dependencies :disappointed:
Filipe Névola < 1 minute ago
I'm stuck here :disappointed:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment