-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[@types/mongodb] Redefine OptionalId to make it accept generic types #46412
Conversation
- Before this commit, OptionalId was defined with a conditional type that could never resolve when given a generic. - We lose the type-safety on the _id property in Collection.insert{,One,Many} methods with these changes, but we also fix a regression introduced when OptionalId was redefined. - Remove the test-cases which were validating the _id property in insert{,One,Many} methods. - Add some test-cases with an unconstrained and a constrained generic TSchema type.
@g-pascal Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through. This is a live comment which I will keep updated. 1 package in this PRCode ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. InactiveThis PR has been inactive for 31 days — it is considered abandoned! Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 46412,
"author": "g-pascal",
"owners": [
"CaselIT",
"alanmarcell",
"dante-101",
"mcortesi",
"EnricoPicci",
"AJCStriker",
"julien-c",
"daprahamian",
"denys-bushulyak",
"BastienAr",
"sindbach",
"geraldinelemeur",
"various89",
"angela-1",
"hector7",
"floric",
"erikc5000",
"Manc",
"jloveridge",
"ranguna",
"HosseinAgha",
"albertossilva",
"peterblazejewicz",
"LinusU",
"taxilian",
"xamgore",
"avaly",
"HitkoDev",
"Celend",
"jtassin"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "d7fb443",
"headCommitOid": "d7fb4431209a5913dac3f45a2b977c8c0ad5f027",
"mergeIsRequested": false,
"stalenessInDays": 31,
"lastPushDate": "2020-07-28T16:59:01.000Z",
"lastCommentDate": "2020-08-14T21:32:12.000Z",
"maintainerBlessed": true,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46412/files",
"hasMergeConflict": true,
"authorIsOwner": false,
"isFirstContribution": true,
"popularityLevel": "Popular",
"newPackages": [],
"packages": [
"mongodb"
],
"files": [
{
"path": "types/mongodb/index.d.ts",
"kind": "definition",
"package": "mongodb"
},
{
"path": "types/mongodb/test/collection/insertX.ts",
"kind": "test",
"package": "mongodb"
}
],
"hasDismissedReview": false,
"ciResult": "pass",
"reviewersWithStaleReviews": [],
"approvalFlags": 0,
"isChangesRequested": false
} |
🔔 @CaselIT @alanmarcell @Dante-101 @mcortesi @EnricoPicci @AJCStriker @julien-c @daprahamian @Denys-Bushulyak @bastienar @sindbach @geraldinelemeur @various89 @angela-1 @hector7 @floric @erikc5000 @Manc @jloveridge @Ranguna @HosseinAgha @albertossilva @peterblazejewicz @LinusU @taxilian @xamgore @avaly @HitkoDev @Celend @jtassin — please review this PR in the next few days. Be sure to explicitly select |
Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files. mongodb (unpkg)was missing the following properties:
The most common way to resolve this error is to use 'export =' syntax.
as well as these 11 other properties...BulkWriteError, Admin, Collection, GridStore, Chunk, CoreServer, CoreConnection, Map, Symbol, BSONRegExp, instrument |
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
This probably cannot go anywhere without input from owners: @CaselIT @alanmarcell @Dante-101 @mcortesi @EnricoPicci @AJCStriker @julien-c @daprahamian @Denys-Bushulyak @bastienar @sindbach @geraldinelemeur @various89 @angela-1 @hector7 @floric @erikc5000 @Manc @jloveridge @Ranguna @HosseinAgha @albertossilva @peterblazejewicz @LinusU @taxilian @xamgore @avaly @HitkoDev @jtassin |
@g-pascal Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day! |
@g-pascal To keep things tidy, we have to close PRs that aren't mergeable and don't have activity in the last month. No worries, though — please open a new PR if you'd like to continue with this change. Thank you! |
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).#46375
This PR fixes the
insert{,One,Many}
methods for genericTSchema
types, with the drawback of breaking type checking on the_id
property in theOptionalId
type.OptionalId
was defined with a conditional type that could never resolve when given a generic, because both branches of the conditional used theExtractIdType<TSchema>
, to which no genericTSchema
type could be assigned. This is due to the fact that Typescript does not resolve the constaints of the type variables in conditional types (better explained in Why I use function generic parameters as the other type's generic has compile error? microsoft/TypeScript#29225)._id
property inCollection.insert{,One,Many}
methods with these changes_id
property ininsert{,One,Many}
methods have been removed.TSchema
type.