From de1ec36c49e65efe323bd072cc47b78a496dfb29 Mon Sep 17 00:00:00 2001 From: Cahya Pribadi <534150+ozylog@users.noreply.github.com> Date: Fri, 22 Jun 2018 16:54:26 +1200 Subject: [PATCH 1/2] Update index.d.ts based on hapi.js request object on actual module that params and payload are possible to be null when there is no value applied on it. ``` params: null, paramsArray: null, path: '/v1/Schemas', payload: null, ``` --- types/hapi/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index d8edc40685..26edb16926 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -424,7 +424,7 @@ export interface Request extends Podium { /** * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). */ - readonly params: Util.Dictionary; + readonly params: Util.Dictionary | null; /** * An array containing all the path params values in the order they appeared in the path. @@ -440,7 +440,7 @@ export interface Request extends Podium { * The request payload based on the route payload.output and payload.parse settings. * TODO check this typing and add references / links. */ - readonly payload: stream.Readable | Buffer | string | object; + readonly payload: stream.Readable | Buffer | string | object | null; /** * Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. From 28c5b788e76f967670782d88c83451f33d033739 Mon Sep 17 00:00:00 2001 From: Cahya Pribadi <534150+ozylog@users.noreply.github.com> Date: Mon, 25 Jun 2018 09:15:39 +1200 Subject: [PATCH 2/2] Update parameters.ts --- types/hapi/test/request/parameters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/test/request/parameters.ts b/types/hapi/test/request/parameters.ts index 3f19a02d45..33177d53b4 100644 --- a/types/hapi/test/request/parameters.ts +++ b/types/hapi/test/request/parameters.ts @@ -20,7 +20,7 @@ const serverRoute1: ServerRoute = { // Example 2 // http://localhost:8000/person/rafael/fijalkowski const getPerson: Lifecycle.Method = (request, h) => { - const nameParts = request.params.name.split('/'); + const nameParts = request.params ? request.params.name.split('/') : []; return { first: nameParts[0], last: nameParts[1] }; }; const serverRoute2: ServerRoute = {