daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top