[superagent] support generic type for request body#74968
[superagent] support generic type for request body#74968SchroederSteffen wants to merge 6 commits into
Conversation
| "private": true, | ||
| "name": "@types/superagent", | ||
| "version": "8.1.9999", | ||
| "version": "10.0.9999", |
There was a problem hiding this comment.
The current version of superagent is 10.
From what I can tell, v8 -> v10 only changed Node.js version requirements, so the types shouldn't be affected.
Do we want to align the @types/superagent version as part of this PR or do we want to stay on v8 because the change is compatible?
I tend towards the latter, hence reverting this version change again...
|
@SchroederSteffen Thank you for submitting this PR! This is a live comment that I will keep updated. 1 package in this PR
Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 74968,
"author": "SchroederSteffen",
"headCommitOid": "ba23bf2cf97921625a0ae01a8379189e2d95c594",
"mergeBaseOid": "dafc26dc3da728f912025f73d2629374a9b1aba9",
"lastPushDate": "2026-05-08T12:51:59.000Z",
"lastActivityDate": "2026-05-11T19:11:57.000Z",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"tooManyCommits": false,
"tooManyReviews": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "superagent",
"kind": "edit",
"files": [
{
"path": "types/superagent/lib/node/index.d.ts",
"kind": "definition"
},
{
"path": "types/superagent/superagent-tests.ts",
"kind": "test"
}
],
"owners": [
"NicoZelaya",
"mxl",
"shreyjain1994",
"zopf",
"beeequeue",
"lukaselmer",
"theQuazz",
"carnesen",
"ghostganz",
"LuckyWindsck",
"DavidTanner"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "lukaselmer",
"date": "2026-05-09T04:11:12.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 4409234887,
"ciResult": "pass"
} |
|
🔔 @NicoZelaya @mxl @shreyjain1994 @zopf @beeequeue @lukaselmer @theQuazz @carnesen @ghostganz @LuckyWindsck @DavidTanner — please review this PR in the next few days. Be sure to explicitly select |
| responseType(type: string): this; | ||
| retry(count?: number, callback?: CBHandler): this; | ||
| send(data?: string | object): this; | ||
| send<T extends string | object = string | object>(data?: T): this; |
There was a problem hiding this comment.
I said this here: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/74967/changes#r3221485120
But this is typically a bad idea, as it doesn't offer any more safety, no?
Please fill in this template.
pnpm test <package to test>.Select one of these and delete the others:
If changing an existing definition:
package.json.We declare DTO classes for our services to describe the request & response bodies.
When testing our services using
supertest&superagent, we want to ensure that the request bodies fit the expected type of the endpoint, e.g. as follows:I also thought about adding generics to the request methods (
.get(),.post(), etc.) to inherit these types for the.send()method, but I opted for this simpler solution for now.