diff options
author | bobzel <zzzman@gmail.com> | 2021-10-26 17:24:43 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-10-26 17:24:43 -0400 |
commit | 92f34533d58291036ff6123c38502cbd4e22300d (patch) | |
tree | 3ea20f1fe213b994c6465be103f783fc0212a539 /src/fields/Doc.ts | |
parent | 2155d39fbc4a9bac3945e40ee10f95f41df466d3 (diff) | |
parent | 48d5e650ddc8caa8252561bbc91961f2f4677d6e (diff) |
Merge branch 'master' into ink_v1
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 9490edc2c..42d93c60c 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -79,6 +79,7 @@ export function DocListCastAsync(field: FieldResult, defaultValue?: Doc[]) { export async function DocCastAsync(field: FieldResult): Promise<Opt<Doc>> { return Cast(field, Doc); } +export function NumListCast(field: FieldResult) { return Cast(field, listSpec("number"), []); } export function StrListCast(field: FieldResult) { return Cast(field, listSpec("string"), []); } export function DocListCast(field: FieldResult) { return Cast(field, listSpec(Doc), []).filter(d => d instanceof Doc) as Doc[]; } export function DocListCastOrNull(field: FieldResult) { return Cast(field, listSpec(Doc), null)?.filter(d => d instanceof Doc) as Doc[] | undefined; } @@ -1313,6 +1314,7 @@ export namespace Doc { if (typeof resolved === "object" && !(resolved instanceof Array)) { output = convertObject(resolved, excludeEmptyObjects, title, appendToExisting?.targetDoc); } else { + // give the proper types to the data extracted from the JSON const result = toField(resolved, excludeEmptyObjects); if (appendToExisting) { (output = appendToExisting.targetDoc)[appendToExisting.fieldKey || defaultKey] = result; |