aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-04-22 22:57:18 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-04-22 22:57:18 -0400
commit27b514747188f12e0b0eeeb124576c556316923d (patch)
treeae3f9d5b2d54bb26a56a51638402fab1c6dc2d5b /src/new_fields/Doc.ts
parent5a9e437bbd175b36a161e1d96c8ae873dfe6d105 (diff)
Changes
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 60abccce6..5ae095e68 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -33,8 +33,8 @@ export class ObjectField {
export type Field = number | string | boolean | ObjectField | RefField;
export type Opt<T> = T | undefined;
-export type FieldWaiting<T extends Field = Field> = Promise<T | undefined>;
-export type FieldResult<T extends Field = Field> = Opt<T> | FieldWaiting<T>;
+export type FieldWaiting<T extends RefField = RefField> = T extends undefined ? never : Promise<T | undefined>;
+export type FieldResult<T extends Field = Field> = Opt<T> | FieldWaiting<Extract<T, RefField>>;
export const Self = Symbol("Self");
@@ -58,7 +58,8 @@ export class Doc extends RefField {
@serializable(alias("fields", map(autoObject())))
@observable
- private __fields: { [key: string]: Field | FieldWaiting | undefined } = {};
+ //{ [key: string]: Field | FieldWaiting | undefined }
+ private __fields: any = {};
private [Update] = (diff: any) => {
DocServer.UpdateField(this[Id], diff);
@@ -86,7 +87,7 @@ export namespace Doc {
return Cast(Get(doc, key, ignoreProto), ctor) as T | null | undefined;
}
export async function SetOnPrototype(doc: Doc, key: string, value: Field) {
- const proto = await Cast(doc.prototype, Doc);
+ const proto = await Cast(doc.proto, Doc);
if (proto) {
proto[key] = value;
}
@@ -97,7 +98,7 @@ export namespace Doc {
}
const delegate = new Doc();
//TODO Does this need to be doc[Self]?
- delegate.prototype = doc;
+ delegate.proto = doc;
return delegate;
}
export const Prototype = Symbol("Prototype");