Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
tylim88 committed Oct 2, 2023
1 parent eeb813d commit 4c2c20c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firelordjs",
"version": "2.6.16",
"version": "2.6.17",
"description": "🔥 High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions src/batch/updateNoFlatten.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ describe('test updateNoFlatten batch', () => {
'FirelordTest',
'updateBatchTestCaseEmpty'
)
const result = batch.updateNoFlatten(docRef, {})
expect(result).toBe(undefined)
batch.updateNoFlatten(
docRef,
// @ts-expect-error
{}
)
})
})
6 changes: 5 additions & 1 deletion src/operations/updateDocNoFlatten.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ describe('test updateDocNoFlatten', () => {
deleteDoc(docRef)
expect.assertions(1)
try {
await updateDocNoFlatten(docRef, {})
await updateDocNoFlatten(
docRef,
// @ts-expect-error
{}
)
} catch (e) {
expect(true).toBe(true)
}
Expand Down
7 changes: 5 additions & 2 deletions src/transaction/updateNoFlatten.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ describe('test updateNoFlatten transaction', () => {
await setDoc(docRef, generateRandomData())
expect.assertions(1)
await runTransaction(async transaction => {
const result = transaction.updateNoFlatten(docRef, {})
expect(result).toBe(undefined)
transaction.updateNoFlatten(
docRef,
// @ts-expect-error
{}
)
})
})
})
8 changes: 7 additions & 1 deletion src/types/exactOptional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ export type ExactOptional<
Merge extends boolean | string[], // this is for set merge operation only
NoFlatten extends boolean,
TopLevel extends boolean
> = Data extends (NoFlatten extends true ? never : Record<string, never>)
> = Data extends (
NoFlatten extends true
? TopLevel extends true
? Record<string, never>
: never
: Record<string, never>
)
? ErrorEmptyUpdate
: keyof Data extends keyof T
? {
Expand Down
10 changes: 2 additions & 8 deletions src/types/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ export type UpdateNoFlatten = UpdateCreator<Promise<void>, true>

export type TransactionUpdate = UpdateCreator<Transaction, false>

export type TransactionUpdateNoFlatten = UpdateCreator<
Transaction | undefined,
true
>
export type TransactionUpdateNoFlatten = UpdateCreator<Transaction, true>

export type WriteBatchUpdate = UpdateCreator<WriteBatch, false>

export type WriteBatchUpdateNoFlatten = UpdateCreator<
WriteBatch | undefined,
true
>
export type WriteBatchUpdateNoFlatten = UpdateCreator<WriteBatch, true>

0 comments on commit 4c2c20c

Please sign in to comment.