Skip to content

Commit

Permalink
Change order of ts types (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
omzouai-visor authored and mickeyreiss committed Sep 28, 2018
1 parent 865244f commit 64254b7
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 94 deletions.
98 changes: 51 additions & 47 deletions langs/ts/ts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export interface Query<DataType = firestore.DocumentData>
extends firestore.Query {
where(
fieldPath: string | firestore.FieldPath,
opStr: firestore.WhereFilterOp,
value: any,
): Query<DataType>;
orderBy(
fieldPath: string | firestore.FieldPath,
directionStr?: firestore.OrderByDirection,
): Query<DataType>;
limit(limit: number): Query<DataType>;
startAt(snapshot: DocumentSnapshot): Query<DataType>;
startAt(...fieldValues: any[]): Query<DataType>;
startAfter(snapshot: DocumentSnapshot): Query<DataType>;
startAfter(...fieldValues: any[]): Query<DataType>;
endBefore(snapshot: DocumentSnapshot): Query<DataType>;
endBefore(...fieldValues: any[]): Query<DataType>;
endAt(snapshot: DocumentSnapshot): Query<DataType>;
endAt(...fieldValues: any[]): Query<DataType>;
get(options?: firestore.GetOptions): Promise<QuerySnapshot<DataType>>;
onSnapshot(observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
}): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
},
): () => void;
onSnapshot(
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
}
export interface DocumentSnapshot<DataType = firestore.DocumentData>
extends firestore.DocumentSnapshot {
data(options?: firestore.SnapshotOptions): DataType | undefined;
Expand Down Expand Up @@ -198,6 +245,9 @@ export interface DocumentReference<DataType = firestore.DocumentData>
onCompletion?: () => void,
): () => void;
}
export interface CollectionReference<DataType = firestore.DocumentData>
extends Query<DataType>,
Omit<firestore.CollectionReference, keyof Query> {
Expand All @@ -207,52 +257,6 @@ export interface Collection<DataType = firestore.DocumentData> {
[id: string]: DocumentSnapshotExpanded<DataType>;
}
export interface Query<DataType = firestore.DocumentData>
extends firestore.Query {
where(
fieldPath: string | firestore.FieldPath,
opStr: firestore.WhereFilterOp,
value: any,
): Query<DataType>;
orderBy(
fieldPath: string | firestore.FieldPath,
directionStr?: firestore.OrderByDirection,
): Query<DataType>;
limit(limit: number): Query<DataType>;
startAt(snapshot: DocumentSnapshot): Query<DataType>;
startAt(...fieldValues: any[]): Query<DataType>;
startAfter(snapshot: DocumentSnapshot): Query<DataType>;
startAfter(...fieldValues: any[]): Query<DataType>;
endBefore(snapshot: DocumentSnapshot): Query<DataType>;
endBefore(...fieldValues: any[]): Query<DataType>;
endAt(snapshot: DocumentSnapshot): Query<DataType>;
endAt(...fieldValues: any[]): Query<DataType>;
get(options?: firestore.GetOptions): Promise<QuerySnapshot<DataType>>;
onSnapshot(observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
}): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
},
): () => void;
onSnapshot(
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
}
// tslint:disable-next-line:no-namespace
export namespace {{.Options | getSchemaOption "ts" "namespace" "firemodel"}} {
Expand Down
98 changes: 51 additions & 47 deletions testfixtures/firemodel/TestFiremodelFromSchema/ts/firemodel.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
// DO NOT EDIT - Code generated by firemodel (dev).

import { firestore } from 'firebase';

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

export interface Query<DataType = firestore.DocumentData>
extends firestore.Query {
where(
fieldPath: string | firestore.FieldPath,
opStr: firestore.WhereFilterOp,
value: any,
): Query<DataType>;
orderBy(
fieldPath: string | firestore.FieldPath,
directionStr?: firestore.OrderByDirection,
): Query<DataType>;
limit(limit: number): Query<DataType>;
startAt(snapshot: DocumentSnapshot): Query<DataType>;
startAt(...fieldValues: any[]): Query<DataType>;
startAfter(snapshot: DocumentSnapshot): Query<DataType>;
startAfter(...fieldValues: any[]): Query<DataType>;
endBefore(snapshot: DocumentSnapshot): Query<DataType>;
endBefore(...fieldValues: any[]): Query<DataType>;
endAt(snapshot: DocumentSnapshot): Query<DataType>;
endAt(...fieldValues: any[]): Query<DataType>;
get(options?: firestore.GetOptions): Promise<QuerySnapshot<DataType>>;
onSnapshot(observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
}): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
},
): () => void;
onSnapshot(
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
}


export interface DocumentSnapshot<DataType = firestore.DocumentData>
extends firestore.DocumentSnapshot {
data(options?: firestore.SnapshotOptions): DataType | undefined;
Expand Down Expand Up @@ -63,6 +110,9 @@ export interface DocumentReference<DataType = firestore.DocumentData>
onCompletion?: () => void,
): () => void;
}



export interface CollectionReference<DataType = firestore.DocumentData>
extends Query<DataType>,
Omit<firestore.CollectionReference, keyof Query> {
Expand All @@ -72,52 +122,6 @@ export interface Collection<DataType = firestore.DocumentData> {
[id: string]: DocumentSnapshotExpanded<DataType>;
}

export interface Query<DataType = firestore.DocumentData>
extends firestore.Query {
where(
fieldPath: string | firestore.FieldPath,
opStr: firestore.WhereFilterOp,
value: any,
): Query<DataType>;
orderBy(
fieldPath: string | firestore.FieldPath,
directionStr?: firestore.OrderByDirection,
): Query<DataType>;
limit(limit: number): Query<DataType>;
startAt(snapshot: DocumentSnapshot): Query<DataType>;
startAt(...fieldValues: any[]): Query<DataType>;
startAfter(snapshot: DocumentSnapshot): Query<DataType>;
startAfter(...fieldValues: any[]): Query<DataType>;
endBefore(snapshot: DocumentSnapshot): Query<DataType>;
endBefore(...fieldValues: any[]): Query<DataType>;
endAt(snapshot: DocumentSnapshot): Query<DataType>;
endAt(...fieldValues: any[]): Query<DataType>;
get(options?: firestore.GetOptions): Promise<QuerySnapshot<DataType>>;
onSnapshot(observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
}): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
observer: {
next?: (snapshot: QuerySnapshot<DataType>) => void;
error?: (error: Error) => void;
complete?: () => void;
},
): () => void;
onSnapshot(
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
onSnapshot(
options: firestore.SnapshotListenOptions,
onNext: (snapshot: QuerySnapshot<DataType>) => void,
onError?: (error: Error) => void,
onCompletion?: () => void,
): () => void;
}

// tslint:disable-next-line:no-namespace
export namespace example {
Expand Down

0 comments on commit 64254b7

Please sign in to comment.