aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.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/Doc.ts
parentd2ec862ad60f0501a5184f9d424cc5db07b998b0 (diff)
Changed some types to be more correct for lists
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 38c220bc8..afcf71fc9 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -29,9 +29,11 @@ const SelfProxy = Symbol("SelfProxy");
export const WidthSym = Symbol("Width");
export const HeightSym = Symbol("Height");
-export function DocListCast(field: FieldResult) {
- const list = Cast(field, listSpec(Doc))
- return list ? Promise.all(list) : Promise.resolve(undefined);
+export function DocListCast(field: FieldResult): Promise<Doc[] | undefined>;
+export function DocListCast(field: FieldResult, defaultValue: Doc[]): Promise<Doc[]>;
+export function DocListCast(field: FieldResult, defaultValue?: Doc[]) {
+ const list = Cast(field, listSpec(Doc));
+ return list ? Promise.all(list) : Promise.resolve(defaultValue);
}
@Deserializable("doc").withFields(["id"])