mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
* Type declaration for agent() return type
## The case
In my project, it is essential to always clarify the variable type. In my case, writing a test suite would require to declare variables (so that they could be accessed in other scopes) and then later initialize them in a different block
## An example
```ts
describe("Health module", () => {
// In this case I must declare variables here
let app: NestApplication;
let agent: any; // I could just copy and paste that huge return type, but it will break the code style. Using `any` is also a bad practice I guess
beforeAll(() => {
/* some code */
// initialization goes here
agent = supertest.agent(app.getHttpServer());
});
/* some code */
});
```
## Proposal
Declaring the return type of the agent function would be great, however, considering that I'm new to this library there may be a type declared already.
P.S. `SuperTestAgent` is just the first thing that I could come up with, it should be named more properly
* running lint
|
||
|---|---|---|
| .. | ||
| index.d.ts | ||
| supertest-tests.ts | ||
| tsconfig.json | ||
| tslint.json | ||