diff --git a/langs/ts/ts.go b/langs/ts/ts.go index c29ee96..ecc1ee9 100644 --- a/langs/ts/ts.go +++ b/langs/ts/ts.go @@ -134,11 +134,58 @@ func getModelOption(namespace string, key string, required bool, options firemod const ( file = `// DO NOT EDIT - Code generated by firemodel {{firemodelVersion}}. - import { firestore } from 'firebase'; type Omit = Pick>; +export interface Query + extends firestore.Query { + where( + fieldPath: string | firestore.FieldPath, + opStr: firestore.WhereFilterOp, + value: any, + ): Query; + orderBy( + fieldPath: string | firestore.FieldPath, + directionStr?: firestore.OrderByDirection, + ): Query; + limit(limit: number): Query; + startAt(snapshot: DocumentSnapshot): Query; + startAt(...fieldValues: any[]): Query; + startAfter(snapshot: DocumentSnapshot): Query; + startAfter(...fieldValues: any[]): Query; + endBefore(snapshot: DocumentSnapshot): Query; + endBefore(...fieldValues: any[]): Query; + endAt(snapshot: DocumentSnapshot): Query; + endAt(...fieldValues: any[]): Query; + get(options?: firestore.GetOptions): Promise>; + onSnapshot(observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: Error) => void; + complete?: () => void; + }): () => void; + onSnapshot( + options: firestore.SnapshotListenOptions, + observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: Error) => void; + complete?: () => void; + }, + ): () => void; + onSnapshot( + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void, + onCompletion?: () => void, + ): () => void; + onSnapshot( + options: firestore.SnapshotListenOptions, + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void, + onCompletion?: () => void, + ): () => void; +} + + export interface DocumentSnapshot extends firestore.DocumentSnapshot { data(options?: firestore.SnapshotOptions): DataType | undefined; @@ -198,6 +245,9 @@ export interface DocumentReference onCompletion?: () => void, ): () => void; } + + + export interface CollectionReference extends Query, Omit { @@ -207,52 +257,6 @@ export interface Collection { [id: string]: DocumentSnapshotExpanded; } -export interface Query - extends firestore.Query { - where( - fieldPath: string | firestore.FieldPath, - opStr: firestore.WhereFilterOp, - value: any, - ): Query; - orderBy( - fieldPath: string | firestore.FieldPath, - directionStr?: firestore.OrderByDirection, - ): Query; - limit(limit: number): Query; - startAt(snapshot: DocumentSnapshot): Query; - startAt(...fieldValues: any[]): Query; - startAfter(snapshot: DocumentSnapshot): Query; - startAfter(...fieldValues: any[]): Query; - endBefore(snapshot: DocumentSnapshot): Query; - endBefore(...fieldValues: any[]): Query; - endAt(snapshot: DocumentSnapshot): Query; - endAt(...fieldValues: any[]): Query; - get(options?: firestore.GetOptions): Promise>; - onSnapshot(observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: Error) => void; - complete?: () => void; - }): () => void; - onSnapshot( - options: firestore.SnapshotListenOptions, - observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: Error) => void; - complete?: () => void; - }, - ): () => void; - onSnapshot( - onNext: (snapshot: QuerySnapshot) => void, - onError?: (error: Error) => void, - onCompletion?: () => void, - ): () => void; - onSnapshot( - options: firestore.SnapshotListenOptions, - onNext: (snapshot: QuerySnapshot) => void, - onError?: (error: Error) => void, - onCompletion?: () => void, - ): () => void; -} // tslint:disable-next-line:no-namespace export namespace {{.Options | getSchemaOption "ts" "namespace" "firemodel"}} { diff --git a/testfixtures/firemodel/TestFiremodelFromSchema/ts/firemodel.d.ts b/testfixtures/firemodel/TestFiremodelFromSchema/ts/firemodel.d.ts index ac9f0b7..bef7c0f 100644 --- a/testfixtures/firemodel/TestFiremodelFromSchema/ts/firemodel.d.ts +++ b/testfixtures/firemodel/TestFiremodelFromSchema/ts/firemodel.d.ts @@ -1,9 +1,56 @@ // DO NOT EDIT - Code generated by firemodel (dev). - import { firestore } from 'firebase'; type Omit = Pick>; +export interface Query + extends firestore.Query { + where( + fieldPath: string | firestore.FieldPath, + opStr: firestore.WhereFilterOp, + value: any, + ): Query; + orderBy( + fieldPath: string | firestore.FieldPath, + directionStr?: firestore.OrderByDirection, + ): Query; + limit(limit: number): Query; + startAt(snapshot: DocumentSnapshot): Query; + startAt(...fieldValues: any[]): Query; + startAfter(snapshot: DocumentSnapshot): Query; + startAfter(...fieldValues: any[]): Query; + endBefore(snapshot: DocumentSnapshot): Query; + endBefore(...fieldValues: any[]): Query; + endAt(snapshot: DocumentSnapshot): Query; + endAt(...fieldValues: any[]): Query; + get(options?: firestore.GetOptions): Promise>; + onSnapshot(observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: Error) => void; + complete?: () => void; + }): () => void; + onSnapshot( + options: firestore.SnapshotListenOptions, + observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: Error) => void; + complete?: () => void; + }, + ): () => void; + onSnapshot( + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void, + onCompletion?: () => void, + ): () => void; + onSnapshot( + options: firestore.SnapshotListenOptions, + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void, + onCompletion?: () => void, + ): () => void; +} + + export interface DocumentSnapshot extends firestore.DocumentSnapshot { data(options?: firestore.SnapshotOptions): DataType | undefined; @@ -63,6 +110,9 @@ export interface DocumentReference onCompletion?: () => void, ): () => void; } + + + export interface CollectionReference extends Query, Omit { @@ -72,52 +122,6 @@ export interface Collection { [id: string]: DocumentSnapshotExpanded; } -export interface Query - extends firestore.Query { - where( - fieldPath: string | firestore.FieldPath, - opStr: firestore.WhereFilterOp, - value: any, - ): Query; - orderBy( - fieldPath: string | firestore.FieldPath, - directionStr?: firestore.OrderByDirection, - ): Query; - limit(limit: number): Query; - startAt(snapshot: DocumentSnapshot): Query; - startAt(...fieldValues: any[]): Query; - startAfter(snapshot: DocumentSnapshot): Query; - startAfter(...fieldValues: any[]): Query; - endBefore(snapshot: DocumentSnapshot): Query; - endBefore(...fieldValues: any[]): Query; - endAt(snapshot: DocumentSnapshot): Query; - endAt(...fieldValues: any[]): Query; - get(options?: firestore.GetOptions): Promise>; - onSnapshot(observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: Error) => void; - complete?: () => void; - }): () => void; - onSnapshot( - options: firestore.SnapshotListenOptions, - observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: Error) => void; - complete?: () => void; - }, - ): () => void; - onSnapshot( - onNext: (snapshot: QuerySnapshot) => void, - onError?: (error: Error) => void, - onCompletion?: () => void, - ): () => void; - onSnapshot( - options: firestore.SnapshotListenOptions, - onNext: (snapshot: QuerySnapshot) => void, - onError?: (error: Error) => void, - onCompletion?: () => void, - ): () => void; -} // tslint:disable-next-line:no-namespace export namespace example {