Skip to content

Commit 450cfd2

Browse files
committed
🐛 do not import types in js
1 parent 8d3cf39 commit 450cfd2

File tree

2 files changed

+36
-48
lines changed

2 files changed

+36
-48
lines changed

src/Firebase/Auth.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const {
55
createUserWithEmailAndPassword,
66
signInWithEmailAndPassword,
77
signOut,
8-
User,
98
signInAnonymously,
109
sendEmailVerification,
1110
useDeviceLanguage,
@@ -49,7 +48,7 @@ exports.signOutImp = function (auth) {
4948

5049
/**
5150
*
52-
* @param {User} user
51+
* @param {import("firebase/auth").User} user
5352
*/
5453
exports.getUserIdTokenImp = function (user, force) {
5554
return function () {
@@ -72,7 +71,7 @@ exports.getAuthImp = function (firebase) {
7271
// TODO: correctly type ActionCodeSettings in PS
7372
/**
7473
*
75-
* @param {User} user
74+
* @param {import("firebase/auth").User} user
7675
* @param {import("firebase/auth").ActionCodeSettings | undefined | null} config
7776
* @returns {() => Promise<void>}
7877
*/
@@ -166,7 +165,7 @@ exports.useDeviceLanguageImp = function (auth) {
166165

167166
/**
168167
*
169-
* @param {(u: User | null) => () => void} callback
168+
* @param {(u: import("firebase/auth").User | null) => () => void} callback
170169
* @param {import("firebase/auth").Auth} auth
171170
* @returns {() => () => Void} Unsubscribe
172171
*/

src/Firebase/Firestore.js

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,17 @@ const {
44
query,
55
where,
66
getDocs,
7-
CollectionReference,
8-
Firestore,
9-
WhereFilterOp,
10-
QueryConstraint,
11-
Query,
12-
QuerySnapshot,
13-
QueryDocumentSnapshot,
147
getFirestore,
15-
DocumentData,
168
doc,
179
deleteDoc,
18-
DocumentReference,
1910
onSnapshot,
20-
FirestoreError,
21-
DocumentSnapshot,
2211
setDoc,
2312
addDoc,
2413
} = require("firebase/firestore");
2514

2615
/**
2716
*
28-
* @returns { Firestore }
17+
* @returns { import("firebase/firestore").Firestore }
2918
*/
3019
exports.getFirestoreImp = function () {
3120
return getFirestore();
@@ -34,8 +23,8 @@ exports.getFirestoreImp = function () {
3423
/**
3524
*
3625
* @param {String} path
37-
* @param {Firestore} firestore
38-
* @returns {() => CollectionReference}
26+
* @param {import("firebase/firestore").Firestore} firestore
27+
* @returns {() => import("firebase/firestore").CollectionReference}
3928
*/
4029
exports.collectionImp = function (path, firestore) {
4130
return function () {
@@ -46,9 +35,9 @@ exports.collectionImp = function (path, firestore) {
4635
/**
4736
*
4837
* @param {String} path
49-
* @param {WhereFilterOp} opStr
38+
* @param {import("firebase/firestore").WhereFilterOp} opStr
5039
* @param {unknown} value
51-
* @returns {() => QueryConstraint}
40+
* @returns {() => import("firebase/firestore").QueryConstraint}
5241
*/
5342
exports.whereImp = function (path, opStr, value) {
5443
return function () {
@@ -58,9 +47,9 @@ exports.whereImp = function (path, opStr, value) {
5847

5948
/**
6049
*
61-
* @param {QueryConstraint[]} queryConstraints
62-
* @param {Query} q
63-
* @returns {() => Query}
50+
* @param {import("firebase/firestore").QueryConstraint[]} queryConstraints
51+
* @param {import("firebase/firestore").Query} q
52+
* @returns {() => import("firebase/firestore").Query}
6453
*/
6554
exports.queryImp = function (queryConstraints, q) {
6655
return function () {
@@ -70,8 +59,8 @@ exports.queryImp = function (queryConstraints, q) {
7059

7160
/**
7261
*
73-
* @param {Query} q
74-
* @returns {() => Promise<QuerySnapshot>}
62+
* @param {import("firebase/firestore").Query} q
63+
* @returns {() => Promise<import("firebase/firestore").QuerySnapshot>}
7564
*/
7665
exports.getDocsImp = function (q) {
7766
return function () {
@@ -81,8 +70,8 @@ exports.getDocsImp = function (q) {
8170

8271
/**
8372
*
84-
* @param {(result: QueryDocumentSnapshot) => () => void} callback
85-
* @param {QuerySnapshot} snapshot
73+
* @param {(result: import("firebase/firestore").QueryDocumentSnapshot) => () => void} callback
74+
* @param {import("firebase/firestore").QuerySnapshot} snapshot
8675
* @returns {() => void}
8776
*/
8877
exports.foreachImp = function (callback, snapshot) {
@@ -95,8 +84,8 @@ exports.foreachImp = function (callback, snapshot) {
9584

9685
/**
9786
*
98-
* @param {QuerySnapshot} snapshot
99-
* @returns {() => QueryDocumentSnapshot[]}
87+
* @param {import("firebase/firestore").QuerySnapshot} snapshot
88+
* @returns {() => import("firebase/firestore").QueryDocumentSnapshot[]}
10089
*/
10190
exports.getSnapshotDocsImp = function (snapshot) {
10291
return function () {
@@ -106,8 +95,8 @@ exports.getSnapshotDocsImp = function (snapshot) {
10695

10796
/**
10897
*
109-
* @param {DocumentSnapshot<DocumentData>} snapshot
110-
* @returns {() => DocumentData | undefined }
98+
* @param {import("firebase/firestore").DocumentSnapshot<import("firebase/firestore").DocumentData>} snapshot
99+
* @returns {() => import("firebase/firestore").DocumentData | undefined }
111100
*/
112101
exports.getDocSnapshotDataImp = function (snapshot) {
113102
return function () {
@@ -118,8 +107,8 @@ exports.getDocSnapshotDataImp = function (snapshot) {
118107

119108
/**
120109
*
121-
* @param {QueryDocumentSnapshot} snapshot
122-
* @returns {() => DocumentData}
110+
* @param {import("firebase/firestore").QueryDocumentSnapshot} snapshot
111+
* @returns {() => import("firebase/firestore").DocumentData}
123112
*/
124113
exports.getSnapshotDataImp = function (snapshot) {
125114
return function () {
@@ -129,10 +118,10 @@ exports.getSnapshotDataImp = function (snapshot) {
129118

130119
/**
131120
*
132-
* @param {Firestore} firestore
121+
* @param {import("firebase/firestore").Firestore} firestore
133122
* @param {String} path
134123
* @param {String[]} pathSegments
135-
* @returns {() => DocumentReference}
124+
* @returns {() => import("firebase/firestore").DocumentReference}
136125
*/
137126
exports.docImp = function (firestore, path, pathSegments) {
138127
return function () {
@@ -142,7 +131,7 @@ exports.docImp = function (firestore, path, pathSegments) {
142131

143132
/**
144133
*
145-
* @param {DocumentReference} doc
134+
* @param {import("firebase/firestore").DocumentReference} doc
146135
* @returns {() => Promise<void>}
147136
*/
148137
exports.deleteImp = function (doc) {
@@ -153,10 +142,10 @@ exports.deleteImp = function (doc) {
153142

154143
/**
155144
*
156-
* @param {(snapshot: QuerySnapshot) => void} onNext
157-
* @param {(error: FirestoreError) => void} onError
145+
* @param {(snapshot: import("firebase/firestore").QuerySnapshot) => void} onNext
146+
* @param {(error: import("firebase/firestore").FirestoreError) => void} onError
158147
* @param {() => void} onCompletion
159-
* @param {Query} query
148+
* @param {import("firebase/firestore").Query} query
160149
* @returns {() => () => void}
161150
*/
162151
exports.onSnapshotImp = function (onNext, onError, onCompletion, query) {
@@ -168,9 +157,9 @@ exports.onSnapshotImp = function (onNext, onError, onCompletion, query) {
168157

169158
/**
170159
*
171-
* @param {DocumentReference<DocumentData>} doc
172-
* @param {(snapshot: DocumentSnapshot) => void} onNext
173-
* @param {(error: FirestoreError) => void} onError
160+
* @param {import("firebase/firestore").DocumentReference<import("firebase/firestore").DocumentData>} doc
161+
* @param {(snapshot: import("firebase/firestore").DocumentSnapshot) => void} onNext
162+
* @param {(error: import("firebase/firestore").FirestoreError) => void} onError
174163
* @param {() => void} onCompletion
175164
* @returns {() => () => void}
176165
*/
@@ -183,7 +172,7 @@ exports.onDocSnapshotImp = function (doc, onNext, onError, onCompletion) {
183172

184173
/**
185174
*
186-
* @param {QuerySnapshot} qs
175+
* @param {import("firebase/firestore").QuerySnapshot} qs
187176
* @returns {() => Boolean}
188177
*/
189178
exports.isQuerySnapshotEmptyImp = function (qs) {
@@ -194,8 +183,8 @@ exports.isQuerySnapshotEmptyImp = function (qs) {
194183

195184
/**
196185
*
197-
* @param {DocumentReference<DocumentData>} doc
198-
* @param {DocumentData} data
186+
* @param {import("firebase/firestore").DocumentReference<import("firebase/firestore").DocumentData>} doc
187+
* @param {import("firebase/firestore").DocumentData} data
199188
* @returns {() => Promise<void>}
200189
*/
201190
exports.setDocImp = function (doc, data) {
@@ -206,9 +195,9 @@ exports.setDocImp = function (doc, data) {
206195

207196
/**
208197
*
209-
* @param {CollectionReference<DocumentData>} collection
210-
* @param {DocumentData} data
211-
* @returns {() => Promise<DocumentReference<DocumentData>>}
198+
* @param {import("firebase/firestore").CollectionReference<import("firebase/firestore").DocumentData>} collection
199+
* @param {import("firebase/firestore").DocumentData} data
200+
* @returns {() => Promise<import("firebase/firestore").DocumentReference<import("firebase/firestore").DocumentData>>}
212201
*/
213202
exports.addDocImp = function (collection, data) {
214203
return function () {

0 commit comments

Comments
 (0)