diff --git a/types/mock-express-request/index.d.ts b/types/mock-express-request/index.d.ts new file mode 100644 index 0000000000..99d18771aa --- /dev/null +++ b/types/mock-express-request/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for mock-express-request 0.2 +// Project: https://github.com/lykmapipo/mock-express-request +// Definitions by: Fela Maslen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Request } from 'express'; + +declare function MockExpressRequest(options?: object): Request; + +export = MockExpressRequest; diff --git a/types/mock-express-request/mock-express-request-tests.ts b/types/mock-express-request/mock-express-request-tests.ts new file mode 100644 index 0000000000..cf3018f26f --- /dev/null +++ b/types/mock-express-request/mock-express-request-tests.ts @@ -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', + }, + }), + ); +} diff --git a/types/mock-express-request/tsconfig.json b/types/mock-express-request/tsconfig.json new file mode 100644 index 0000000000..1a1e4a15de --- /dev/null +++ b/types/mock-express-request/tsconfig.json @@ -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" + ] +} diff --git a/types/mock-express-request/tslint.json b/types/mock-express-request/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mock-express-request/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }