From 27b514747188f12e0b0eeeb124576c556316923d Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 22 Apr 2019 22:57:18 -0400 Subject: Changes --- src/new_fields/Types.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/new_fields/Types.ts') diff --git a/src/new_fields/Types.ts b/src/new_fields/Types.ts index fbf002c84..246b0624e 100644 --- a/src/new_fields/Types.ts +++ b/src/new_fields/Types.ts @@ -1,4 +1,4 @@ -import { Field, Opt, FieldWaiting, FieldResult } from "./Doc"; +import { Field, Opt, FieldWaiting, FieldResult, RefField } from "./Doc"; import { List } from "./List"; export type ToType | ListSpec> = @@ -18,7 +18,7 @@ export type ToConstructor = new (...args: any[]) => T; export type ToInterface = { - [P in keyof T]: ToType; + [P in keyof T]: FieldResult>; }; // type ListSpec = { List: ToContructor> | ListSpec> }; @@ -37,11 +37,11 @@ export interface Interface { // [key: string]: ToConstructor | ListSpec; } -export function Cast | ListSpec>(field: Field | FieldWaiting | undefined, ctor: T): FieldResult>; -export function Cast | ListSpec>(field: Field | FieldWaiting | undefined, ctor: T, defaultVal: ToType): ToType; -export function Cast | ListSpec>(field: Field | FieldWaiting | undefined, ctor: T, defaultVal?: ToType): FieldResult> | undefined { +export function Cast | ListSpec>(field: FieldResult, ctor: T): FieldResult>; +export function Cast | ListSpec>(field: FieldResult, ctor: T, defaultVal: ToType): ToType; +export function Cast | ListSpec>(field: FieldResult, ctor: T, defaultVal?: ToType): FieldResult> | undefined { if (field instanceof Promise) { - return defaultVal === undefined ? field.then(f => Cast(f, ctor) as any) : defaultVal; + return defaultVal === undefined ? field.then(f => Cast(f, ctor) as any) as any : defaultVal; } if (field !== undefined && !(field instanceof Promise)) { if (typeof ctor === "string") { -- cgit v1.2.3-70-g09d2