Type definition for mock-express-request (#42985)

This commit is contained in:
Fela Maslen 2020-03-13 02:00:59 +00:00 committed by GitHub
parent 282a27a0c2
commit 584eb9feba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 0 deletions

10
types/mock-express-request/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
// Type definitions for mock-express-request 0.2
// Project: https://github.com/lykmapipo/mock-express-request
// Definitions by: Fela Maslen <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Request } from 'express';
declare function MockExpressRequest(options?: object): Request;
export = MockExpressRequest;

View File

@ -0,0 +1,18 @@
import { Request } from 'express';
import MockExpressRequest from 'mock-express-request';
function doSomethingWithRequest(req: Request): void {
console.log(req.headers);
}
function testMockExpressRequest() {
doSomethingWithRequest(MockExpressRequest());
doSomethingWithRequest(
MockExpressRequest({
headers: {
'Content-Type': 'application/json',
},
}),
);
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mock-express-request-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }