From 3b2f53cf6acd51b136f6c62e0ceef841b6a0adea Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 10 Jun 2017 00:05:33 +0200 Subject: [PATCH] hapi: fix incorrect connection.table() result type (#17070) --- types/hapi/index.d.ts | 19 ++++++++++++++++--- types/hapi/test/connection/table.ts | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 9b03944e9a..efce9f3dc4 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1256,13 +1256,14 @@ export interface RoutingTableEntry { /** * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value + * For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71) */ export interface Route { /** * the route config with defaults applied. * TODO check type of RouteConfiguration here is correct */ - settings: RouteConfiguration; + settings: RouteAdditionalConfigurationOptions; /** * the HTTP method in lower case. * TODO, check if it can contain 'head' or not. @@ -1270,6 +1271,18 @@ export interface Route { method: HTTP_METHODS_PARTIAL_lowercase; /** the route path. */ path: string; + + params: string[]; + + connection: ServerConnection; + + fingerprint: string; + + plugin?: any; + + public: RoutePublicInterface; + + server: Server; } /** @@ -1618,8 +1631,8 @@ export interface ServerConnection { /** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */ inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; inject(options: string | InjectedRequestOptions, ): Promise; - /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servertablehost) */ - table(host?: string): RoutingTableEntry; + /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ + table(host?: string): Route[]; /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ lookup(id: string): RoutePublicInterface | null; /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */ diff --git a/types/hapi/test/connection/table.ts b/types/hapi/test/connection/table.ts index dee4741b07..24eaa28ddc 100644 --- a/types/hapi/test/connection/table.ts +++ b/types/hapi/test/connection/table.ts @@ -18,3 +18,5 @@ const table = connection.table(); } ] */ + +table.map(({method, path, settings: {description}}) => { });