-
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
[mongodb] UpdateQuery is not readonly #44105
[mongodb] UpdateQuery is not readonly #44105
Conversation
@avaly Thank you for submitting this PR! 🔔 @CaselIT @alanmarcell @Dante-101 @mcortesi @EnricoPicci @AJCStriker @julien-c @daprahamian @Denys-Bushulyak @bastienar @sindbach @geraldinelemeur @various89 @angela-1 @lirbank @hector7 @floric @erikc5000 @Manc @jloveridge @Ranguna @HosseinAgha @albertossilva @peterblazejewicz @LinusU @taxilian @xamgore - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped! |
Hmmm, this is an interesting one, the values that are being accepted by the functions are really the readonly variant, since the function accepting the values won't modify them. If we remove readonly from types that are being accepted, it means that you can no longer pass readonly types into those functions (you can pass both normal and readonly things to a readonly accepting function, but you cannot pass readonly things to a normal accepting function). I'm not really sure what the best approach here is, since the example that you added in the test is something that someone might want to do... |
Maybe I'm missing this obvious thing, but is this something that's defined somewhere (the fact that the functions are accepting only readonly parameters)? |
89d7f93
to
a202695
Compare
I think that what he meant was that a function that accept a readonly variant, accepts also the not readonly one: function foo(arg: readonly number[]) {}
foo([1,2])
foo([2,3] as const) If you remove the |
I understood that part @CaselIT, but I am confused because all the functions that use updateOne(
filter: FilterQuery<TSchema>,
update: UpdateQuery<TSchema> | Partial<TSchema>,
callback: MongoCallback<UpdateWriteOpResult>,
): void; |
👋 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. |
One problem would be that the following would no longer work:
on the other hand, it fixes the problem that you stated so there is clearly pros to both approaches I would say that I'm leaning towards making this change 👍, but it would be nice to see if any other maintainers wants to chime in |
Is this ready to merge? |
@avaly 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! |
a202695
to
77ac4d3
Compare
Is anyone able to determine how likely this is to cause breaks for people using these types today? I’m a little concerned about issues like the scenario @LinusU identified. It seems to me that it isn’t strictly necessary to propagate |
@andrewbranch Thanks for the feedback! I guess we can live with that workaround. I'll close this PR. |
@avaly Thank you for submitting this PR! Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. 🔔 @CaselIT @alanmarcell @Dante-101 @mcortesi @EnricoPicci @AJCStriker @julien-c @daprahamian @Denys-Bushulyak @bastienar @sindbach @geraldinelemeur @various89 @angela-1 @lirbank @hector7 @floric @erikc5000 @Manc @jloveridge @Ranguna @HosseinAgha @albertossilva @peterblazejewicz @LinusU @taxilian @xamgore - please review this PR in the next few days. Be sure to explicitly select Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"pr_number": 44105,
"author": "avaly",
"owners": [
"CaselIT",
"alanmarcell",
"dante-101",
"mcortesi",
"EnricoPicci",
"AJCStriker",
"julien-c",
"daprahamian",
"denys-bushulyak",
"BastienAr",
"sindbach",
"geraldinelemeur",
"various89",
"angela-1",
"lirbank",
"hector7",
"floric",
"erikc5000",
"Manc",
"jloveridge",
"ranguna",
"HosseinAgha",
"albertossilva",
"peterblazejewicz",
"LinusU",
"taxilian",
"xamgore",
"avaly"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "77ac4d3",
"headCommitOid": "77ac4d3554fe492d2ac23bf993d218ad4cd58873",
"mergeIsRequested": false,
"stalenessInDays": 0,
"lastCommitDate": "2020-04-27T09:11:38.000Z",
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44105/files",
"hasMergeConflict": false,
"authorIsOwner": true,
"isFirstContribution": false,
"popularityLevel": "Popular",
"anyPackageIsNew": false,
"packages": [
"mongodb"
],
"files": [
{
"filePath": "types/mongodb/index.d.ts",
"kind": "definition",
"package": "mongodb"
},
{
"filePath": "types/mongodb/test/collection/updateX.ts",
"kind": "test",
"package": "mongodb"
}
],
"otherApprovalCount": 0,
"ownerApprovalCount": 0,
"maintainerApprovalCount": 0,
"hasDismissedReview": false,
"travisResult": "pass",
"reviewersWithStaleReviews": [],
"approvalFlags": 0,
"isChangesRequested": false
} |
@avaly Thank you for submitting this PR! Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. 🔔 @CaselIT @alanmarcell @Dante-101 @mcortesi @EnricoPicci @AJCStriker @julien-c @daprahamian @Denys-Bushulyak @bastienar @sindbach @geraldinelemeur @various89 @angela-1 @lirbank @hector7 @floric @erikc5000 @Manc @jloveridge @Ranguna @HosseinAgha @albertossilva @peterblazejewicz @LinusU @taxilian @xamgore - please review this PR in the next few days. Be sure to explicitly select Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"pr_number": 44105,
"author": "avaly",
"owners": [
"CaselIT",
"alanmarcell",
"dante-101",
"mcortesi",
"EnricoPicci",
"AJCStriker",
"julien-c",
"daprahamian",
"denys-bushulyak",
"BastienAr",
"sindbach",
"geraldinelemeur",
"various89",
"angela-1",
"lirbank",
"hector7",
"floric",
"erikc5000",
"Manc",
"jloveridge",
"ranguna",
"HosseinAgha",
"albertossilva",
"peterblazejewicz",
"LinusU",
"taxilian",
"xamgore",
"avaly"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "77ac4d3",
"headCommitOid": "77ac4d3554fe492d2ac23bf993d218ad4cd58873",
"mergeIsRequested": false,
"stalenessInDays": 0,
"lastCommitDate": "2020-04-27T09:11:38.000Z",
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44105/files",
"hasMergeConflict": false,
"authorIsOwner": true,
"isFirstContribution": false,
"popularityLevel": "Popular",
"anyPackageIsNew": false,
"packages": [
"mongodb"
],
"files": [
{
"filePath": "types/mongodb/index.d.ts",
"kind": "definition",
"package": "mongodb"
},
{
"filePath": "types/mongodb/test/collection/updateX.ts",
"kind": "test",
"package": "mongodb"
}
],
"otherApprovalCount": 0,
"ownerApprovalCount": 0,
"maintainerApprovalCount": 0,
"hasDismissedReview": false,
"travisResult": "pass",
"reviewersWithStaleReviews": [],
"approvalFlags": 0,
"isChangesRequested": false
} |
Is there an elegant workaround to the |
Please fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
There's no reason why an update object can't be mutated before being used. In complex applications building such an object can be influenced by many conditions and factors.