Skip to content

Commit 51bd8c9

Browse files
committed
Fix types for view context
1 parent 7e192eb commit 51bd8c9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/server/plugins/engine/plugin.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { hasFormComponents, slugSchema } from '@defra/forms-model'
66
import Boom from '@hapi/boom'
77
import {
88
type Plugin,
9+
type PluginProperties,
910
type ResponseObject,
1011
type ResponseToolkit,
1112
type RouteOptions,
@@ -95,9 +96,7 @@ export interface PluginOptions {
9596
baseLayoutPath: string
9697
paths: string[]
9798
}
98-
viewContext: (
99-
request: FormRequest | FormRequestPayload | null
100-
) => Promise<Record<string, unknown>>
99+
viewContext: PluginProperties['forms-engine-plugin']['viewContext']
101100
}
102101

103102
export const plugin = {

src/typings/hapi/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { type ServerYar, type Yar } from '@hapi/yar'
55
import { type Logger } from 'pino'
66

77
import { type FormModel } from '~/src/server/plugins/engine/models/index.js'
8-
import { type context } from '~/src/server/plugins/engine/nunjucks.js'
98
import {
109
type FormRequest,
1110
type FormRequestPayload
@@ -22,7 +21,9 @@ declare module '@hapi/hapi' {
2221
'forms-engine-plugin': {
2322
baseLayoutPath: string
2423
cacheService: CacheService
25-
viewContext: context
24+
viewContext?: (
25+
request: FormRequest | FormRequestPayload | null
26+
) => Record<string, unknown> | Promise<Record<string, unknown>>
2627
}
2728
}
2829

0 commit comments

Comments
 (0)