Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: install @tsconfig/ember, update typescript, install ts-patch #321

Merged
merged 8 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions addon/adapters/cloud-firestore-modular.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getOwner } from '@ember/application';
import { inject as service } from '@ember/service';
import Adapter from '@ember-data/adapter';
import DS, { ModelSchema } from 'ember-data';
import ModelRegistry from 'ember-data/types/registries/model';
import DS, { type ModelSchema } from 'ember-data';
import type ModelRegistry from 'ember-data/types/registries/model';
import RSVP from 'rsvp';
import Store from '@ember-data/store';

Expand Down Expand Up @@ -272,7 +272,7 @@ export default class CloudFirestoreAdapter extends Adapter {
urlNodes.pop();

const db = getFirestore();
const docRef = doc(db, urlNodes.join('/'), id);
const docRef = doc(db, urlNodes.join('/'), id!);
const modelName = relationship.type;
const docSnapshot =
relationship.options.isRealtime && !this.isFastBoot
Expand Down
2 changes: 1 addition & 1 deletion addon/authenticators/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getOwner } from '@ember/application';

import { Auth, User, UserCredential } from 'firebase/auth';
import type { Auth, User, UserCredential } from 'firebase/auth';
import BaseAuthenticator from 'ember-simple-auth/authenticators/base';
import type FastBoot from 'ember-cli-fastboot/services/fastboot';

Expand Down
6 changes: 3 additions & 3 deletions addon/instance-initializers/firebase-settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ApplicationInstance from '@ember/application/instance';

import { FirebaseApp, FirebaseOptions } from 'firebase/app';
import { Firestore, EmulatorMockTokenOptions } from 'firebase/firestore';
import type { FirebaseApp, FirebaseError, FirebaseOptions } from 'firebase/app';
import type { Firestore, EmulatorMockTokenOptions } from 'firebase/firestore';

import { initializeApp } from 'ember-cloud-firestore-adapter/firebase/app';
import {
Expand Down Expand Up @@ -141,7 +141,7 @@ export function initialize(appInstance: ApplicationInstance): void {
try {
setupModularInstance(addonConfig);
} catch (e) {
if (e.code !== 'failed-precondition') {
if ((e as FirebaseError).code !== 'failed-precondition') {
throw new Error(
`There was a problem with initializing Firebase. Check if you've configured the addon properly. | Error: ${e}`,
);
Expand Down
6 changes: 3 additions & 3 deletions addon/serializers/cloud-firestore-modular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { isNone } from '@ember/utils';
import DS, { ModelSchema } from 'ember-data';
import DS, { type ModelSchema } from 'ember-data';
import JSONSerializer from '@ember-data/serializer/json';
import Store from '@ember-data/store';

Expand Down Expand Up @@ -134,9 +134,9 @@ export default class CloudFirestoreSerializer extends JSONSerializer {
...super.serialize(snapshot, options),
};

snapshot.eachRelationship((name: string, relationship) => {
snapshot.eachRelationship((name, relationship) => {
if (relationship.kind === 'hasMany') {
delete json[name];
delete json[name as string];
}
});

Expand Down
30 changes: 15 additions & 15 deletions addon/services/-firestore-data-manager.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { next } from '@ember/runloop';
import DS from 'ember-data';
import ModelRegistry from 'ember-data/types/registries/model';
import type ModelRegistry from 'ember-data/types/registries/model';
import Service, { inject as service } from '@ember/service';
import StoreService from '@ember-data/store';

import {
import type {
CollectionReference,
DocumentReference,
DocumentSnapshot,
Expand Down Expand Up @@ -96,7 +96,7 @@ export default class FirestoreDataManager extends Service {
await this.setupDocRealtimeUpdates(modelName, docRef);
}

return this.docListeners[listenerKey].snapshot;
return this.docListeners[listenerKey]!.snapshot;
}

public async findAllRealtime(
Expand All @@ -109,7 +109,7 @@ export default class FirestoreDataManager extends Service {
await this.setupColRealtimeUpdates(modelName, colRef);
}

return this.colListeners[listenerKey].snapshot;
return this.colListeners[listenerKey]!.snapshot;
}

public async queryRealtime(
Expand All @@ -120,7 +120,7 @@ export default class FirestoreDataManager extends Service {
let unsubscribe: Unsubscribe | undefined;

if (this.queryListeners[queryId]) {
unsubscribe = this.queryListeners[queryId].unsubscribe;
unsubscribe = this.queryListeners[queryId]!.unsubscribe;
delete this.queryListeners[queryId];
}

Expand All @@ -130,7 +130,7 @@ export default class FirestoreDataManager extends Service {
unsubscribe();
}

return this.queryListeners[queryId].snapshots;
return this.queryListeners[queryId]!.snapshots;
}

public async findHasManyRealtime(
Expand All @@ -141,7 +141,7 @@ export default class FirestoreDataManager extends Service {
let unsubscribe: Unsubscribe | undefined;

if (this.hasManyListeners[queryId]) {
unsubscribe = this.hasManyListeners[queryId].unsubscribe;
unsubscribe = this.hasManyListeners[queryId]!.unsubscribe;
delete this.hasManyListeners[queryId];
}

Expand All @@ -151,7 +151,7 @@ export default class FirestoreDataManager extends Service {
unsubscribe();
}

return this.hasManyListeners[queryId].snapshots;
return this.hasManyListeners[queryId]!.snapshots;
}

public async queryWithReferenceTo(
Expand Down Expand Up @@ -320,7 +320,7 @@ export default class FirestoreDataManager extends Service {
listenerKey: string,
): void {
if (docSnapshot.exists()) {
this.docListeners[listenerKey].snapshot = docSnapshot;
this.docListeners[listenerKey]!.snapshot = docSnapshot;
this.pushRecord(modelName, docSnapshot);
} else {
this.unloadRecord(modelName, docSnapshot.id, listenerKey);
Expand All @@ -332,7 +332,7 @@ export default class FirestoreDataManager extends Service {
listenerKey: string,
querySnapshot: QuerySnapshot,
): void {
this.colListeners[listenerKey].snapshot = querySnapshot;
this.colListeners[listenerKey]!.snapshot = querySnapshot;

querySnapshot.forEach((docSnapshot) => {
this.pushRecord(modelName, docSnapshot);
Expand Down Expand Up @@ -378,7 +378,7 @@ export default class FirestoreDataManager extends Service {
// multiple times. Race condition can happen where queryId no longer exists inside
// queryListeners so we have this check.
if (Object.prototype.hasOwnProperty.call(this.queryListeners, queryId)) {
const { unsubscribe } = this.queryListeners[queryId];
const { unsubscribe } = this.queryListeners[queryId]!;

delete this.queryListeners[queryId];
recordArray.update().then(() => unsubscribe());
Expand Down Expand Up @@ -479,22 +479,22 @@ export default class FirestoreDataManager extends Service {

private destroyListener(type: string, key: string): void {
if (type === 'doc' && this.docListeners[key]) {
this.docListeners[key].unsubscribe();
this.docListeners[key]!.unsubscribe();
delete this.docListeners[key];
}

if (type === 'col' && this.colListeners[key]) {
this.colListeners[key].unsubscribe();
this.colListeners[key]!.unsubscribe();
delete this.colListeners[key];
}

if (type === 'query' && this.queryListeners[key]) {
this.queryListeners[key].unsubscribe();
this.queryListeners[key]!.unsubscribe();
delete this.queryListeners[key];
}

if (type === 'hasMany' && this.hasManyListeners[key]) {
this.hasManyListeners[key].unsubscribe();
this.hasManyListeners[key]!.unsubscribe();
delete this.hasManyListeners[key];
}
}
Expand Down
Loading
Loading