|
17 | 17 | * under the License. |
18 | 18 | */ |
19 | 19 |
|
20 | | -import { ValidationError, Type, schema, ObjectType, isConfigSchema } from '@kbn/config-schema'; |
| 20 | +import { |
| 21 | + ValidationError, |
| 22 | + Type, |
| 23 | + schema, |
| 24 | + ObjectType, |
| 25 | + TypeOf, |
| 26 | + isConfigSchema, |
| 27 | +} from '@kbn/config-schema'; |
21 | 28 | import { Stream } from 'stream'; |
22 | 29 | import { RouteValidationError } from './validator_error'; |
23 | 30 |
|
@@ -85,7 +92,7 @@ type RouteValidationResultType<T extends RouteValidationSpec<any> | undefined> = |
85 | 92 | T extends RouteValidationFunction<any> |
86 | 93 | ? ReturnType<T>['value'] |
87 | 94 | : T extends Type<any> |
88 | | - ? ReturnType<T['validate']> |
| 95 | + ? TypeOf<T> |
89 | 96 | : undefined |
90 | 97 | >; |
91 | 98 |
|
@@ -170,23 +177,23 @@ export class RouteValidator<P = {}, Q = {}, B = {}> { |
170 | 177 | * @internal |
171 | 178 | */ |
172 | 179 | public getParams(data: unknown, namespace?: string): Readonly<P> { |
173 | | - return this.validate(this.config.params, this.options.unsafe?.params, data, namespace); |
| 180 | + return this.validate(this.config.params, this.options.unsafe?.params, data, namespace) as P; |
174 | 181 | } |
175 | 182 |
|
176 | 183 | /** |
177 | 184 | * Get validated query params |
178 | 185 | * @internal |
179 | 186 | */ |
180 | 187 | public getQuery(data: unknown, namespace?: string): Readonly<Q> { |
181 | | - return this.validate(this.config.query, this.options.unsafe?.query, data, namespace); |
| 188 | + return this.validate(this.config.query, this.options.unsafe?.query, data, namespace) as Q; |
182 | 189 | } |
183 | 190 |
|
184 | 191 | /** |
185 | 192 | * Get validated body |
186 | 193 | * @internal |
187 | 194 | */ |
188 | 195 | public getBody(data: unknown, namespace?: string): Readonly<B> { |
189 | | - return this.validate(this.config.body, this.options.unsafe?.body, data, namespace); |
| 196 | + return this.validate(this.config.body, this.options.unsafe?.body, data, namespace) as B; |
190 | 197 | } |
191 | 198 |
|
192 | 199 | /** |
|
0 commit comments