diff --git a/packages/owl-core/src/types.ts b/packages/owl-core/src/types.ts index f71c8a849..7315d362f 100644 --- a/packages/owl-core/src/types.ts +++ b/packages/owl-core/src/types.ts @@ -39,7 +39,7 @@ function booleanType(): boolean { } as any; } -function numberType(): number { +function numberType(): T { return function validateNumber(context: ValidationContext) { if (typeof context.value !== "number") { context.addIssue({ message: "value is not a number" }); @@ -47,7 +47,7 @@ function numberType(): number { } as any; } -function stringType(): string { +function stringType(): T { return function validateString(context: ValidationContext) { if (typeof context.value !== "string" && !(context.value instanceof String)) { context.addIssue({ message: "value is not a string" }); @@ -56,6 +56,7 @@ function stringType(): string { } function arrayType(): any[]; +function arrayType(): T[]; function arrayType(elementType: T): T[]; function arrayType(elementType?: any): any { return function validateArray(context: ValidationContext) { @@ -103,6 +104,7 @@ function customValidator( function functionType(): (...parameters: any[]) => any; function functionType(parameters: P): (...parameters: P) => void; +function functionType(): (...parameters: P) => R; function functionType(parameters: P, result: R): (...parameters: P) => R; function functionType(parameters = [], result = undefined): (...parameters: any[]) => any { return function validateFunction(context: ValidationContext) { @@ -207,6 +209,7 @@ function objectType(): Record; function objectType( keys: Keys ): ResolveOptionalEntries>; +function objectType(): ResolveOptionalEntries; function objectType(shape: Shape): ResolveOptionalEntries; function objectType(schema = {}): Record { return function validateLooseObject(context: ValidationContext) { @@ -292,6 +295,7 @@ function union(types: T): T[number] { } function reactiveValueType(): ReactiveValue; +function reactiveValueType(): ReactiveValue; function reactiveValueType(type: T): ReactiveValue; function reactiveValueType(type?: any): ReactiveValue { return function validateReactiveValue(context: ValidationContext) {