mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-05 09:40:02 +00:00
Merge pull request #30920 from lukaselmer/feature/improve-superagent-agent
improve superagent.agent() typing
This commit is contained in:
3
types/superagent/index.d.ts
vendored
3
types/superagent/index.d.ts
vendored
@@ -6,6 +6,7 @@
|
||||
// Shrey Jain <https://github.com/shreyjain1994>
|
||||
// Alec Zopf <https://github.com/zopf>
|
||||
// Adam Haglund <https://github.com/beeequeue>
|
||||
// Lukas Elmer <https://github.com/lukaselmer>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -45,7 +46,7 @@ declare namespace request {
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
(method: string, url: string): SuperAgentRequest;
|
||||
|
||||
agent(): SuperAgent<SuperAgentRequest>;
|
||||
agent(): this & Request;
|
||||
serialize: { [type: string]: Serializer };
|
||||
parse: { [type: string]: Parser };
|
||||
}
|
||||
|
||||
@@ -421,3 +421,16 @@ request
|
||||
.get('/echo')
|
||||
.use(echoPlugin)
|
||||
.end();
|
||||
|
||||
async function testDefaultOptions() {
|
||||
// Default options for multiple requests
|
||||
const agentWithDefaultOptions = request
|
||||
.agent()
|
||||
.use(() => null)
|
||||
.auth('digest', 'secret', { type: 'auto' });
|
||||
|
||||
await agentWithDefaultOptions.get('/with-plugin-and-auth');
|
||||
await agentWithDefaultOptions.get('/also-with-plugin-and-auth');
|
||||
}
|
||||
|
||||
testDefaultOptions();
|
||||
|
||||
Reference in New Issue
Block a user