From d2fb3085fe17a9c66eab893b2a3d000a5bdec054 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Tue, 30 Apr 2019 20:17:21 -0400 Subject: Fixed list typings --- src/client/views/DocumentDecorations.tsx | 3 ++- src/new_fields/List.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 084220f76..8ee6a5b64 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -252,8 +252,9 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> } } } - if (SelectionManager.SelectedDocuments()[0].props.addDocument !== undefined) + if (SelectionManager.SelectedDocuments()[0].props.addDocument !== undefined) { SelectionManager.SelectedDocuments()[0].props.addDocument!(iconDoc!); + } return iconDoc; } @action diff --git a/src/new_fields/List.ts b/src/new_fields/List.ts index ec1bf44a9..817ae943b 100644 --- a/src/new_fields/List.ts +++ b/src/new_fields/List.ts @@ -1,5 +1,5 @@ import { Deserializable, autoObject } from "../client/util/SerializationHelper"; -import { Field, Update, Self } from "./Doc"; +import { Field, Update, Self, FieldResult } from "./Doc"; import { setter, getter, deleteProperty } from "./util"; import { serializable, alias, list } from "serializr"; import { observable, observe, IArrayChange, IArraySplice, IObservableArray, Lambda, reaction } from "mobx"; @@ -194,17 +194,17 @@ type ListUpdate = ListSpliceUpdate | ListIndexUpdate; class ListImpl extends ObjectField { constructor(fields: T[] = []) { super(); - this.___fields = fields; const list = new Proxy(this, { set: setter, get: listGetter, deleteProperty: deleteProperty, defineProperty: () => { throw new Error("Currently properties can't be defined on documents using Object.defineProperty"); }, }); + (list as any).push(...fields); return list; } - [key: number]: T | null | undefined; + [key: number]: FieldResult; @serializable(alias("fields", list(autoObject()))) private get __fields() { @@ -217,7 +217,7 @@ class ListImpl extends ObjectField { // @serializable(alias("fields", list(autoObject()))) @observable - private ___fields: (T | null | undefined)[]; + private ___fields: (T extends RefField ? ProxyField : T)[] = []; private [Update] = (diff: any) => { // console.log(diff); -- cgit v1.2.3-70-g09d2