mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Merge pull request #24341 from ozum/master
[hapi] Fix: Make server.app non-optional
This commit is contained in:
commit
80c15edab7
4
types/hapi/index.d.ts
vendored
4
types/hapi/index.d.ts
vendored
@ -2586,7 +2586,7 @@ export interface ServerInjectOptions extends Shot.RequestOptions {
|
||||
/**
|
||||
* sets the initial value of request.app, defaults to {}.
|
||||
*/
|
||||
app?: ApplicationState;
|
||||
app: ApplicationState;
|
||||
/**
|
||||
* sets the initial value of request.plugins, defaults to {}.
|
||||
*/
|
||||
@ -3257,7 +3257,7 @@ export class Server extends Podium {
|
||||
* Initialized with an empty object.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp)
|
||||
*/
|
||||
app?: ApplicationState;
|
||||
app: ApplicationState;
|
||||
|
||||
/**
|
||||
* Server Auth: properties and methods
|
||||
|
||||
@ -6,20 +6,20 @@ const options: ServerOptions = {
|
||||
};
|
||||
|
||||
declare module "hapi" {
|
||||
// Demonstrate augmenting the application state.
|
||||
interface ApplicationState {
|
||||
key?: string;
|
||||
}
|
||||
// Demonstrate augmenting the application state.
|
||||
interface ApplicationState {
|
||||
key?: string;
|
||||
}
|
||||
}
|
||||
|
||||
const server = new Server(options);
|
||||
server.app!.key = 'value2';
|
||||
server.app.key = 'value2';
|
||||
|
||||
const serverRoute: ServerRoute = {
|
||||
path: '/',
|
||||
method: 'GET',
|
||||
handler(request, h) {
|
||||
return 'key: ' + request.server.app!.key;
|
||||
return 'key: ' + request.server.app.key;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ const options: ServerOptions = {
|
||||
};
|
||||
|
||||
const server = new Server(options);
|
||||
server.app!.key = 'value2';
|
||||
server.app.key = 'value2';
|
||||
|
||||
server.route({
|
||||
path: '/',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user