Skip to content

Remove makeConstructorPrivate #3309

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

Merged
merged 5 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .changeset/small-ghosts-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add "firebase": patch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

---

Removed internal wrapper around our public API that was meant to prevent incorrect SDK usage for JavaScript users, but caused our SDK to stop working in IE11.
4 changes: 4 additions & 0 deletions packages/firestore/src/api/field_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export class NumericIncrementFieldValueImpl extends SerializableFieldValue {
/** The public FieldValue class of the lite API. */
export abstract class FieldValue extends SerializableFieldValue
implements firestore.FieldValue {
protected constructor() {
super();
}

static delete(): firestore.FieldValue {
validateNoArgs('FieldValue.delete', arguments);
return new FieldValueDelegate(
Expand Down
62 changes: 12 additions & 50 deletions packages/firestore/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,75 +21,37 @@ import { _FirebaseNamespace } from '@firebase/app-types/private';
import { Component, ComponentType, Provider } from '@firebase/component';
import {
CACHE_SIZE_UNLIMITED,
Firestore,
CollectionReference,
DocumentReference,
DocumentSnapshot,
QueryDocumentSnapshot,
Firestore,
Query,
QueryDocumentSnapshot,
QuerySnapshot,
CollectionReference,
Transaction,
WriteBatch
} from './api/database';
import { Blob } from './api/blob';
import { FieldPath } from './api/field_path';
import { GeoPoint } from './api/geo_point';
import { Timestamp } from './api/timestamp';
import { makeConstructorPrivate } from './util/api';
import { FieldValue } from './api/field_value';

// Public instance that disallows construction at runtime. Note that this still
// allows instanceof checks.
export const PublicFirestore = makeConstructorPrivate(
const firestoreNamespace = {
Firestore,
'Use firebase.firestore() instead.'
);
export const PublicTransaction = makeConstructorPrivate(
GeoPoint,
Timestamp,
Blob,
Transaction,
'Use firebase.firestore().runTransaction() instead.'
);
export const PublicWriteBatch = makeConstructorPrivate(
WriteBatch,
'Use firebase.firestore().batch() instead.'
);
export const PublicDocumentReference = makeConstructorPrivate(
DocumentReference,
'Use firebase.firestore().doc() instead.'
);
export const PublicDocumentSnapshot = makeConstructorPrivate(DocumentSnapshot);
export const PublicQueryDocumentSnapshot = makeConstructorPrivate(
QueryDocumentSnapshot
);
export const PublicQuery = makeConstructorPrivate(Query);
export const PublicQuerySnapshot = makeConstructorPrivate(QuerySnapshot);
export const PublicCollectionReference = makeConstructorPrivate(
DocumentSnapshot,
Query,
QueryDocumentSnapshot,
QuerySnapshot,
CollectionReference,
'Use firebase.firestore().collection() instead.'
);
export const PublicFieldValue = makeConstructorPrivate(
FieldValue,
'Use FieldValue.<field>() instead.'
);
export const PublicBlob = makeConstructorPrivate(
Blob,
'Use Blob.fromUint8Array() or Blob.fromBase64String() instead.'
);

const firestoreNamespace = {
Firestore: PublicFirestore,
GeoPoint,
Timestamp,
Blob: PublicBlob,
Transaction: PublicTransaction,
WriteBatch: PublicWriteBatch,
DocumentReference: PublicDocumentReference,
DocumentSnapshot: PublicDocumentSnapshot,
Query: PublicQuery,
QueryDocumentSnapshot: PublicQueryDocumentSnapshot,
QuerySnapshot: PublicQuerySnapshot,
CollectionReference: PublicCollectionReference,
FieldPath,
FieldValue: PublicFieldValue,
FieldValue,
setLogLevel: Firestore.setLogLevel,
CACHE_SIZE_UNLIMITED
};
Expand Down
57 changes: 0 additions & 57 deletions packages/firestore/src/util/api.ts

This file was deleted.

This file was deleted.

72 changes: 0 additions & 72 deletions packages/firestore/test/unit/util/api.test.ts

This file was deleted.