aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Types.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-06 19:59:04 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-06 19:59:04 -0400
commitad74425473aa76e718ea3b35d38b5f3b7ca358e1 (patch)
tree6f49221c4dc271690d8172c17947231fc8d57915 /src/new_fields/Types.ts
parentd2ec862ad60f0501a5184f9d424cc5db07b998b0 (diff)
Changed some types to be more correct for lists
Diffstat (limited to 'src/new_fields/Types.ts')
-rw-r--r--src/new_fields/Types.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/new_fields/Types.ts b/src/new_fields/Types.ts
index c07d38786..4b4c58eb8 100644
--- a/src/new_fields/Types.ts
+++ b/src/new_fields/Types.ts
@@ -1,5 +1,6 @@
import { Field, Opt, FieldResult, Doc } from "./Doc";
import { List } from "./List";
+import { RefField } from "./RefField";
export type ToType<T extends ToConstructor<Field> | ListSpec<Field>> =
T extends "string" ? string :
@@ -71,7 +72,7 @@ export function BoolCast(field: FieldResult, defaultVal: boolean | null = null)
return Cast(field, "boolean", defaultVal);
}
-type WithoutList<T extends Field> = T extends List<infer R> ? R[] : T;
+type WithoutList<T extends Field> = T extends List<infer R> ? (R extends RefField ? (R | Promise<R>)[] : R[]) : T;
export function FieldValue<T extends Field, U extends WithoutList<T>>(field: FieldResult<T>, defaultValue: U): WithoutList<T>;
export function FieldValue<T extends Field>(field: FieldResult<T>): Opt<T>;