diff options
| author | andrewdkim <adkim414@gmail.com> | 2019-07-19 11:21:47 -0400 |
|---|---|---|
| committer | andrewdkim <adkim414@gmail.com> | 2019-07-19 11:21:47 -0400 |
| commit | e453e7010def252b6cc10ad49d64708767c5589b (patch) | |
| tree | 4353a4be5495acd61d813066d001e2b12da7d207 /src/new_fields/Schema.ts | |
| parent | 9cad9abcf164c7d81b8debf4aa2639d83edd227b (diff) | |
| parent | 8854d3277541a67aef4187b5d3592bea5a7fcfa2 (diff) | |
merge from master
Diffstat (limited to 'src/new_fields/Schema.ts')
| -rw-r--r-- | src/new_fields/Schema.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/new_fields/Schema.ts b/src/new_fields/Schema.ts index 40ffaecd5..b1a449e08 100644 --- a/src/new_fields/Schema.ts +++ b/src/new_fields/Schema.ts @@ -2,6 +2,7 @@ import { Interface, ToInterface, Cast, ToConstructor, HasTail, Head, Tail, ListS import { Doc, Field } from "./Doc"; import { ObjectField } from "./ObjectField"; import { RefField } from "./RefField"; +import { SelfProxy } from "./FieldSymbols"; type AllToInterface<T extends Interface[]> = { 1: ToInterface<Head<T>> & AllToInterface<Tail<T>>, @@ -56,9 +57,10 @@ export function makeInterface<T extends Interface[]>(...schemas: T): InterfaceFu } }); const fn = (doc: Doc) => { - if (!(doc instanceof Doc)) { - throw new Error("Currently wrapping a schema in another schema isn't supported"); - } + doc = doc[SelfProxy]; + // if (!(doc instanceof Doc)) { + // throw new Error("Currently wrapping a schema in another schema isn't supported"); + // } const obj = Object.create(proto, { doc: { value: doc, writable: false } }); return obj; }; @@ -102,7 +104,7 @@ export function makeStrictInterface<T extends Interface>(schema: T): (doc: Doc) } export function createSchema<T extends Interface>(schema: T): T & { proto: ToConstructor<Doc> } { - schema.proto = Doc; + (schema as any).proto = Doc; return schema as any; } |
