Guest User

Untitled

a guest
Mar 13th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. declare module "koa" {
  2. namespace Koa {
  3. ...
  4.  
  5. export interface Request {
  6. ...
  7. }
  8. ...
  9. }
  10. ...
  11. namespace Koa {}
  12. export = Koa;
  13. }
  14.  
  15. /// <reference path="globals/koa/index.d.ts" />
  16. /// <reference path="koa.d.ts" />
  17.  
  18. import koa = require("koa");
  19. ...
  20. app.use(ctx => {
  21. console.log(ctx.request.body); // error: Property 'body' does not exist on type 'Request'
  22. });
  23.  
  24. declare module "koa" {
  25. namespace Koa {
  26. export interface Request {
  27. body: any;
  28. }
  29. }
  30.  
  31. export default Koa;
  32. }
  33.  
  34. import {Request} from "koa";
  35.  
  36. declare module "koa" {
  37. interface Request {
  38. body: any;
  39. }
  40. }
  41.  
  42. import * as bodyparser from 'koa-bodyparser';
  43. ...
  44. app.use(bodyParser());
  45.  
  46. ctx.request.body
Add Comment
Please, Sign In to add comment