From e189cf6b5e09901f6c068fc78960e37fa129ec77 Mon Sep 17 00:00:00 2001 From: "Rafael S. Fijalkowski" Date: Fri, 8 Dec 2017 19:10:47 -0300 Subject: [PATCH] Replacing any with object. Following the idea of @ctaggart (#4) Review of TS types using 'object' and 'any' mainly. --- .../definitions/plugin/plugin-registered.d.ts | 2 +- .../v17/definitions/request/request-auth.d.ts | 4 +-- .../hapi/v17/definitions/request/request.d.ts | 36 +++++++++---------- .../definitions/response/response-object.d.ts | 4 +-- .../response/response-toolkit.d.ts | 6 ++-- .../route/route-options-access.d.ts | 2 +- .../route/route-options-payload.d.ts | 2 +- .../route/route-options-response.d.ts | 6 ++-- .../route/route-options-validate.d.ts | 14 ++++---- .../v17/definitions/route/route-options.d.ts | 11 +++--- .../server/server-auth-scheme.d.ts | 4 +-- .../v17/definitions/server/server-auth.d.ts | 2 +- .../v17/definitions/server/server-ext.d.ts | 2 +- .../v17/definitions/server/server-inject.d.ts | 8 ++--- .../v17/definitions/server/server-method.d.ts | 5 +-- .../definitions/server/server-options.d.ts | 2 +- .../v17/definitions/server/server-realm.d.ts | 10 +++--- .../definitions/server/server-register.d.ts | 2 +- .../v17/definitions/server/server-route.d.ts | 4 +-- .../server/server-state-options.d.ts | 4 +-- .../v17/definitions/server/server-state.d.ts | 4 +-- types/hapi/v17/definitions/server/server.d.ts | 16 ++++----- 22 files changed, 75 insertions(+), 75 deletions(-) diff --git a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts index 9ee3987a10..e83eb81a63 100644 --- a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts @@ -28,6 +28,6 @@ export interface PluginRegistered { /** * options used to register the plugin. */ - options: any; // OptionsPassedToPlugin; + options: object; } diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/v17/definitions/request/request-auth.d.ts index 2382697da0..a11dd07467 100644 --- a/types/hapi/v17/definitions/request/request-auth.d.ts +++ b/types/hapi/v17/definitions/request/request-auth.d.ts @@ -11,9 +11,9 @@ */ export interface RequestAuth { /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: any; + artifacts: object; /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; + credentials: object; /** the authentication error is failed and mode set to 'try'. */ error: Error; /** true if the request has been successfully authenticated, otherwise false. */ diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 8d004553da..2a92b8a142 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -11,21 +11,14 @@ import {RequestInfo} from "./request-info"; import * as Podium from "podium"; import {RequestEvents} from "hapi"; -/** - * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. - * TODO I think it's not very elegant solution - */ -export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; -export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; - /** * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestorig) */ export interface RequestOrig { - params: any; - query: any; - payload: any; + params: object; + query: object; + payload: object; } /** @@ -39,7 +32,7 @@ export interface Request extends Podium { * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp) */ - app: any; + app: object; /** * Authentication information: @@ -92,7 +85,7 @@ export interface Request extends Podium { * An array containing the logged request events. * Note that this array will be empty if route log.collect is set to false. */ - readonly logs: any[]; + readonly logs: object[]; /** * The request method in lower case (e.g. 'get', 'post'). @@ -128,7 +121,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 | any; + readonly payload: stream.Readable | Buffer | string | object; /** * 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. @@ -138,7 +131,7 @@ export interface Request extends Podium { /** * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - readonly pre: Object; + readonly pre: Util.Dictionary; /** * Access: read / write (see limitations below). @@ -149,12 +142,12 @@ export interface Request extends Podium { /** * Same as pre but represented as the response object created by the pre method. */ - readonly preResponses: Object; + readonly preResponses: Util.Dictionary; /** * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). */ - readonly query: any; + readonly query: object; /** * An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. @@ -187,7 +180,7 @@ export interface Request extends Podium { /** * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - readonly state: Util.Dictionary; + readonly state: Map; /** * The parsed request URI. @@ -199,9 +192,11 @@ export interface Request extends Podium { * @param source - the value to set as the source of the reply interface, optional. * @param options - options for the method, optional. * @return ResponseObject - * [See docs](https://hapijs.com/api/17.0.1#request.generateResponse()) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) */ - generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): ResponseObject; + generateResponse(source: object, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; + generateResponse(source: string, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; + generateResponse(source: null, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; /** * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: @@ -211,7 +206,8 @@ export interface Request extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data) */ - log(tags: string | string[], data?: string | Object | (() => string | Object)): void; + log(tags: string, data?: string | object | (() => string | object)): void; + log(tags: string[], data?: string | object | (() => string | object)): void; /** * Validates a request against the route's authentication access configuration, where: diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index c2ffd457fa..71415c0b33 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -35,7 +35,7 @@ export interface ResponseObject extends Podium { * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseapp) */ - app: any; + app: object; /** * Access: read only and the public podium interface. @@ -44,7 +44,7 @@ export interface ResponseObject extends Podium { * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). * [See docs](https://hapijs.com/api/17.0.1#-responseevents) */ - readonly events: any; // TODO need to be implemented. I didn't understand yet. + readonly events: object; // TODO need to be implemented. I didn't understand yet. /** * Default value: {}. diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index ae737bf085..0ab64f10b0 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -52,7 +52,7 @@ export interface ResponseToolkit { * The [request] object. This is a duplication of the request lifecycle method argument used by * [toolkit decorations](https://github.com/hapijs/hapi/blob/master/API.md#server.decorate()) to access the current request. */ - request: any; // TODO needs review + request: object; // TODO needs review /** * Used by the [authentication] method to pass back valid credentials where: @@ -61,7 +61,7 @@ export interface ResponseToolkit { * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. * @return Return value: an internal authentication object. */ - authenticated(data: {credentials: any, artifacts?: any}): any; + authenticated(data: {credentials: object, artifacts?: object}): object; /** * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if @@ -125,7 +125,7 @@ export interface ResponseToolkit { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunauthenticatederror-data) */ unauthenticated(error: Error): void; - unauthenticated(error: Error, data: {credentials: any, artifacts?: any}): void; + unauthenticated(error: Error, data: {credentials: object, artifacts?: object}): void; /** * Clears a response cookie using the same arguments as diff --git a/types/hapi/v17/definitions/route/route-options-access.d.ts b/types/hapi/v17/definitions/route/route-options-access.d.ts index 8bc175b10a..57cd13e405 100644 --- a/types/hapi/v17/definitions/route/route-options-access.d.ts +++ b/types/hapi/v17/definitions/route/route-options-access.d.ts @@ -46,7 +46,7 @@ export interface RouteOptionsAccess { * An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccess) */ - access?: any | any[]; + access?: object | object[]; /** * Default value: false (no scope requirements). diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index c07bf45fd4..c48d09aa0c 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -12,7 +12,7 @@ export type PayloadOutput = 'data' | 'stream' | 'file'; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ -export type PayloadCompressionDecoderSettings = any; +export type PayloadCompressionDecoderSettings = object; /** * Determines how the request payload is processed. diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index cbf389e862..16c2249e29 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -9,6 +9,8 @@ export enum EmptyStatusCode { HTTP_204 = 204, } +export type RouteOptionsResponseSchema = boolean | ValidationOptions | ((value: object, options: object) => Function); + /** * Processing rules for the outgoing response. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) @@ -69,7 +71,7 @@ export interface RouteOptionsResponse { * * * if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseschema) */ - schema?: boolean | ValidationOptions | ((value: any, options: any) => Function); // TODO it must be better + schema?: RouteOptionsResponseSchema; /** * Default value: none. @@ -77,6 +79,6 @@ export interface RouteOptionsResponse { * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) */ - status?: Util.Dictionary; // TODO it must be better + status?: Map; } diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/v17/definitions/route/route-options-validate.d.ts index 6fba5dfc67..7fa61d5bef 100644 --- a/types/hapi/v17/definitions/route/route-options-validate.d.ts +++ b/types/hapi/v17/definitions/route/route-options-validate.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle} from "hapi"; +import {Lifecycle, RouteOptionsResponseSchema} from "hapi"; import {ValidationOptions} from "joi"; /** @@ -13,7 +13,7 @@ export interface RouteOptionsValidate { * An optional object with error fields copied into every validation error response. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateerrorfields) */ - errorFields?: any; + errorFields?: object; /** * Default value: 'error' (return a Bad Request (400) error response). @@ -34,7 +34,7 @@ export interface RouteOptionsValidate { * Note that all header field names must be in lowercase to match the headers normalized by node. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateheaders) */ - headers?: boolean | ValidationOptions | ((value: any, option: any) => Function); + headers?: RouteOptionsResponseSchema; /** * Default value: none. @@ -45,7 +45,7 @@ export interface RouteOptionsValidate { * If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - options?: ValidationOptions | Object; // TODO need review + options?: ValidationOptions | object; /** * Default value: true (no validation). @@ -59,7 +59,7 @@ export interface RouteOptionsValidate { * Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - params?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + params?: RouteOptionsResponseSchema; /** * Default value: true (no validation). @@ -73,7 +73,7 @@ export interface RouteOptionsValidate { * Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatepayload) */ - payload?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + payload?: RouteOptionsResponseSchema; /** * Default value: true (no validation). @@ -87,6 +87,6 @@ export interface RouteOptionsValidate { * Note that changes to the query parameters will not be reflected in request.url. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatequery) */ - query?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + query?: RouteOptionsResponseSchema; } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index 5f8523b322..daf0005ddd 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -15,7 +15,7 @@ import {Lifecycle} from "hapi"; * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) */ -export type RouteCompressionEncoderSettings = any; +export type RouteCompressionEncoderSettings = object; /** * Each route can be customized to change the default behavior of the request lifecycle. @@ -27,7 +27,7 @@ export interface RouteOptions { * Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) */ - app?: any; + app?: object; /** * Route authentication configuration. Value can be: @@ -43,7 +43,7 @@ export interface RouteOptions { * An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsbind) */ - bind?: any; + bind?: object; /** * Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. @@ -93,8 +93,9 @@ export interface RouteOptions { * Default value: none. * Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ - ext?: any; //TODO need to review and rewrite this definition // I saw again and I keep not understanding. + ext?: object; /** * Default value: { relativeTo: '.' }. @@ -114,7 +115,7 @@ export interface RouteOptions { * Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionshandler) */ - handler?: Lifecycle.Method | Object; //TODO need to review + handler?: Lifecycle.Method | object; /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts index 52a7b732a3..55aa77eba1 100644 --- a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -7,7 +7,7 @@ import {Lifecycle} from "hapi"; * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) */ -export type ServerAuthSchemeOptions = any; +export type ServerAuthSchemeOptions = object; /** * the method implementing the scheme with signature function(server, options) where: @@ -28,7 +28,7 @@ export interface ServerAuthSchemeObject { /** * optional object which is exposed via the [server.auth.api](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.api) object. */ - api?: any; + api?: object; /** * A lifecycle method function called for each incoming request configured with the authentication scheme. The diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 785cee3a9d..d49b12439d 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -77,7 +77,7 @@ export interface ServerAuth { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) */ strategy(name: string, scheme: string): void; - strategy(name: string, scheme: string, options: any): void; + strategy(name: string, scheme: string, options: object): void; /** * Tests a request against an authentication strategy where: diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts index 40d0969f09..ce73328b6c 100644 --- a/types/hapi/v17/definitions/server/server-ext.d.ts +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -91,7 +91,7 @@ export interface RequestExtPointFunction extends Lifecycle.Method { export interface ServerExtOptions { before: string | string[]; after: string | string[]; - bind: any; + bind: object; sandbox?: 'server' | 'plugin'; } diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts index cb04ba3aab..21ba1a8afa 100644 --- a/types/hapi/v17/definitions/server/server-inject.d.ts +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -23,9 +23,9 @@ import * as Shot from "shot"; * For context [Shot module](https://github.com/hapijs/shot) */ export interface ServerInjectOptions extends Shot.RequestOptions { - credentials?: any; - artifacts?: any; - app?: any; + credentials?: object; + artifacts?: object; + app?: object; plugins?: PluginsStates; allowInternals?: boolean; } @@ -45,6 +45,6 @@ export interface ServerInjectOptions extends Shot.RequestOptions { * For context [Shot module](https://github.com/hapijs/shot) */ export interface ServerInjectResponse extends Shot.ResponseObject { - result: any; + result: object | undefined; request: Request; } diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/v17/definitions/server/server-method.d.ts index 9806ffc5cb..e24f36cf74 100644 --- a/types/hapi/v17/definitions/server/server-method.d.ts +++ b/types/hapi/v17/definitions/server/server-method.d.ts @@ -8,7 +8,8 @@ import * as catbox from "catbox"; * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ export interface ServerMethod { - (args: any[], flags: {ttl?: number}): any; +// (args: any[], flags: {ttl?: number}): any; + (...args: any[]): any; // TODO it needs review. Look the doc: the first param is a ...args and the second is "flags". Typescript supports ...args only in the last param } /** @@ -29,7 +30,7 @@ export interface ServerMethodCache extends catbox.PolicyOptions { * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ export interface ServerMethodOptions { - bind: any; + bind: object; cache: ServerMethodCache; generateKey: Function; } diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 4273a01988..dd96c8ea3a 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -26,7 +26,7 @@ export interface ServerOptions { * Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp) */ - app?: any; + app?: object; /** * Default value: true. diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/v17/definitions/server/server-realm.d.ts index 289ea48018..ba60524ebd 100644 --- a/types/hapi/v17/definitions/server/server-realm.d.ts +++ b/types/hapi/v17/definitions/server/server-realm.d.ts @@ -1,8 +1,8 @@ import {PluginsStates} from "../plugin/plugin"; /** - The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. - For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). + * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. + * For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). */ export interface ServerRealm { /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ @@ -16,11 +16,11 @@ export interface ServerRealm { } }; /** the realm of the parent server object, or null for the root server. */ - parent: any | null; + parent: object | null; /** the active plugin name (empty string if at the server root). */ plugin: string; /** the plugin options object passed at registration. */ - pluginOptions: any; // OptionsPassedToPlugin; + pluginOptions: object; /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ plugins: PluginsStates; /** settings overrides */ @@ -28,6 +28,6 @@ export interface ServerRealm { files: { relativeTo: string; }; - bind: any; + bind: object; }; } diff --git a/types/hapi/v17/definitions/server/server-register.d.ts b/types/hapi/v17/definitions/server/server-register.d.ts index 14746bc85a..a16db4547b 100644 --- a/types/hapi/v17/definitions/server/server-register.d.ts +++ b/types/hapi/v17/definitions/server/server-register.d.ts @@ -28,5 +28,5 @@ export interface ServerRegisterOptions { */ export interface ServerRegisterPluginObject extends ServerRegisterOptions { plugin: Plugin; - options?: any; + options?: object; } diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index 70e0bf1d34..efcc910f57 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -37,11 +37,11 @@ export interface ServerRoute { /** * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - options?: Object | ((server: Server) => Function); + options?: object | ((server: Server) => Function); /** * route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. */ - rules?: any; + rules?: object; } diff --git a/types/hapi/v17/definitions/server/server-state-options.d.ts b/types/hapi/v17/definitions/server/server-state-options.d.ts index 289507b849..e650309d95 100644 --- a/types/hapi/v17/definitions/server/server-state-options.d.ts +++ b/types/hapi/v17/definitions/server/server-state-options.d.ts @@ -43,13 +43,13 @@ export interface ServerStateCookieOptions { * * password - password used for HMAC key generation (must be at least 32 characters long). */ sign?: { - integrity?: any; // TODO make iron definitions and getting typing from iron + integrity?: object; // TODO make iron definitions and getting typing from iron. Needs review! password: string; }; /** password used for 'iron' encoding (must be at least 32 characters long). */ password?: string; /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: any; // TODO make iron definitions and getting typing from iron + iron?: object; // TODO make iron definitions and getting typing from iron. Needs review! /** if true, errors are ignored and treated as missing cookies. */ ignoreErrors?: boolean; /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index 1331d32e4a..32107b8f07 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -23,7 +23,7 @@ export interface ServerState { * The server cookies manager. * Access: read only and statehood public interface. */ - readonly states: any; + readonly states: object; /** * The server cookies manager settings. The settings are based on the values configured in [server.options.state](https://github.com/hapijs/hapi/blob/master/API.md#server.options.state). @@ -34,7 +34,7 @@ export interface ServerState { * An object containing the configuration of each cookie added via [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()) where each key is the * cookie name and value is the configuration object. */ - readonly cookies: any; // TODO what the difference between this one and the settings above? This one should be an array? + readonly cookies: object; /** * An array containing the names of all configued cookies. diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 8f0e792a06..44ab2a5280 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -65,7 +65,7 @@ export class Server extends Podium { * Initialized with an empty object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) */ - app?: any; + app?: object; /** * Server Auth: properties and methods @@ -104,7 +104,7 @@ export class Server extends Podium { */ event(events: ServerEventsApplication): void; event(events: ServerEventsApplication[]): void; - + /** * Access: podium public interface. * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. @@ -177,7 +177,7 @@ export class Server extends Podium { * the server.plugins[name] object directly or via the server.expose() method. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins) */ - plugins: any; + plugins: object; /** * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When @@ -233,7 +233,7 @@ export class Server extends Podium { * When setting a context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) */ - bind(context: any): void; + bind(context: object): void; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) @@ -348,7 +348,7 @@ export class Server extends Podium { * objects. Instead favor server.expose(key, value), which only copies a reference to value. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) */ - expose(obj: Object): void; + expose(obj: object): void; /** * Registers an extension function in one of the request lifecycle extension points where: @@ -441,7 +441,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlogtags-data-timestamp) */ - log(tags: string | string[], data?: string | Object | (() => Function), timestamp?: number): void; + log(tags: string | string[], data?: string | object | (() => Function), timestamp?: number): void; /** * Looks up a route configuration where: @@ -556,8 +556,8 @@ export class Server extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function): void; - rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: any}): void; // TODO needs implementation + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function): void; + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: object}): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false).