Skip to content

Commit ab3f16c

Browse files
authored
TypeScript 4.7.4 upgrade for Firestore (#6796)
1 parent 37dd6f6 commit ab3f16c

File tree

14 files changed

+79
-29
lines changed

14 files changed

+79
-29
lines changed

.changeset/breezy-wombats-care.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@firebase/firestore': minor
3+
'@firebase/firestore-compat': minor
4+
'firebase': minor
5+
---
6+
7+
Upgrade TypeScript to 4.7.4 (was 4.2.2)

packages/firestore-compat/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"rollup-plugin-typescript2": "0.31.2",
5959
"@rollup/plugin-node-resolve": "13.3.0",
6060
"ts-node": "10.9.1",
61-
"typescript": "4.2.2"
61+
"typescript": "4.7.4"
6262
},
6363
"license": "Apache-2.0",
6464
"typings": "dist/src/index.d.ts",

packages/firestore-compat/test/array_transforms.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ apiDescribe('Array Transforms:', (persistence: boolean) => {
189189
let errCaught = false;
190190
try {
191191
await docRef.get({ source: 'cache' });
192-
} catch (err) {
192+
} catch (e) {
193+
const err = e as firestore.FirestoreError;
193194
expect(err.code).to.equal('unavailable');
194195
errCaught = true;
195196
}

packages/firestore-compat/test/transactions.test.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ apiDescribe('Database transactions', (persistence: boolean) => {
116116
const snapshot = await this.docRef.get();
117117
expect(snapshot.exists).to.equal(true);
118118
expect(snapshot.data()).to.deep.equal(expected);
119-
} catch (err) {
119+
} catch (e) {
120+
const err = e as firestore.FirestoreError;
120121
expect.fail(
121122
'Expected the sequence (' +
122123
this.listStages(this.stages) +
@@ -133,7 +134,8 @@ apiDescribe('Database transactions', (persistence: boolean) => {
133134
await this.runTransaction();
134135
const snapshot = await this.docRef.get();
135136
expect(snapshot.exists).to.equal(false);
136-
} catch (err) {
137+
} catch (e) {
138+
const err = e as firestore.FirestoreError;
137139
expect.fail(
138140
'Expected the sequence (' +
139141
this.listStages(this.stages) +
@@ -150,8 +152,9 @@ apiDescribe('Database transactions', (persistence: boolean) => {
150152
await this.prepareDoc();
151153
await this.runTransaction();
152154
succeeded = true;
153-
} catch (err) {
154-
expect((err as firestore.FirestoreError).code).to.equal(expected);
155+
} catch (e) {
156+
const err = e as firestore.FirestoreError;
157+
expect(err.code).to.equal(expected);
155158
}
156159
if (succeeded) {
157160
expect.fail(

packages/firestore/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"@firebase/logger": "0.3.4",
8585
"@firebase/util": "1.7.3",
8686
"@firebase/webchannel-wrapper": "0.8.1",
87-
"@grpc/grpc-js": "^1.3.2",
87+
"@grpc/grpc-js": "~1.7.0",
8888
"@grpc/proto-loader": "^0.6.13",
8989
"node-fetch": "2.6.7",
9090
"tslib": "^2.1.0"
@@ -111,7 +111,7 @@
111111
"rollup-plugin-terser": "7.0.2",
112112
"rollup-plugin-typescript2": "0.31.2",
113113
"ts-node": "10.9.1",
114-
"typescript": "4.2.2"
114+
"typescript": "4.7.4"
115115
},
116116
"repository": {
117117
"directory": "packages/firestore",

packages/firestore/scripts/remove-asserts.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firestore/scripts/remove-asserts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class RemoveAsserts {
6464
) {
6565
const method = declaration.name!.text;
6666
if (method === 'debugAssert') {
67-
updatedNode = ts.createEmptyStatement();
67+
updatedNode = ts.createOmittedExpression();
6868
} else if (method === 'hardAssert') {
6969
// Remove the log message but keep the assertion
7070
updatedNode = ts.createCall(

packages/firestore/src/platform/browser_lite/fetch_connection.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export class FetchConnection extends RestConnection {
6161
headers,
6262
body: requestJson
6363
});
64-
} catch (err) {
64+
} catch (e) {
65+
const err = e as { status: number | undefined; statusText: string };
6566
throw new FirestoreError(
6667
mapCodeFromHttpStatus(err.status),
6768
'Request failed with error: ' + err.statusText

packages/firestore/src/util/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface WindowLike {
6161

6262
/** The subset of the browser's Document interface used by the SDK. */
6363
export interface DocumentLike {
64-
readonly visibilityState: VisibilityState;
64+
readonly visibilityState: DocumentVisibilityState;
6565
addEventListener(type: string, listener: EventListener): void;
6666
removeEventListener(type: string, listener: EventListener): void;
6767
}

packages/firestore/test/integration/api_internal/transaction.test.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import { expect } from 'chai';
1919

20+
import { FirestoreError } from '../../../src';
2021
import { DEFAULT_TRANSACTION_OPTIONS } from '../../../src/core/transaction_options';
2122
import { TimerId } from '../../../src/util/async_queue';
2223
import { Deferred } from '../../util/promise';
@@ -155,7 +156,8 @@ apiDescribe(
155156
await transaction.set(docRef, { count: 16 });
156157
});
157158
expect.fail('transaction should fail');
158-
} catch (err) {
159+
} catch (e) {
160+
const err = e as FirestoreError;
159161
expect(err).to.exist;
160162
expect(err.code).to.equal('aborted');
161163
}
@@ -194,7 +196,8 @@ apiDescribe(
194196
options
195197
);
196198
expect.fail('transaction should fail');
197-
} catch (err) {
199+
} catch (e) {
200+
const err = e as FirestoreError;
198201
expect(err).to.exist;
199202
expect(err.code).to.equal('aborted');
200203
}

packages/firestore/test/unit/local/indexeddb_persistence.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1310,18 +1310,18 @@ describe('IndexedDb: canActAsPrimary', () => {
13101310

13111311
after(() => SimpleDb.delete(INDEXEDDB_TEST_DATABASE_NAME));
13121312

1313-
const visible: VisibilityState = 'visible';
1314-
const hidden: VisibilityState = 'hidden';
1313+
const visible: DocumentVisibilityState = 'visible';
1314+
const hidden: DocumentVisibilityState = 'hidden';
13151315
const networkEnabled = true;
13161316
const networkDisabled = false;
13171317
const primary = true;
13181318
const secondary = false;
13191319

13201320
type ExpectedPrimaryStateTestCase = [
13211321
boolean,
1322-
VisibilityState,
1322+
DocumentVisibilityState,
13231323
boolean,
1324-
VisibilityState,
1324+
DocumentVisibilityState,
13251325
boolean
13261326
];
13271327

packages/firestore/test/unit/specs/spec_test_runner.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ export interface SpecWatchEntity {
15711571
// PORTING NOTE: Only used by web multi-tab tests.
15721572
export interface SpecClientState {
15731573
/** The visibility state of the browser tab running the client. */
1574-
visibility?: VisibilityState;
1574+
visibility?: DocumentVisibilityState;
15751575
/** Whether this tab should try to forcefully become primary. */
15761576
primary?: true;
15771577
}

packages/firestore/test/util/test_platform.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ export function testWindow(
9393
* `Document` fake that implements the `visibilitychange` API used by Firestore.
9494
*/
9595
export class FakeDocument implements DocumentLike {
96-
private _visibilityState: VisibilityState = 'hidden';
96+
private _visibilityState: DocumentVisibilityState = 'hidden';
9797
private visibilityListener: EventListener | null = null;
9898

99-
get visibilityState(): VisibilityState {
99+
get visibilityState(): DocumentVisibilityState {
100100
return this._visibilityState;
101101
}
102102

@@ -114,7 +114,7 @@ export class FakeDocument implements DocumentLike {
114114
}
115115
}
116116

117-
raiseVisibilityEvent(visibility: VisibilityState): void {
117+
raiseVisibilityEvent(visibility: DocumentVisibilityState): void {
118118
this._visibilityState = visibility;
119119
if (this.visibilityListener) {
120120
this.visibilityListener(new Event('visibilitychange'));

yarn.lock

+42-7
Original file line numberDiff line numberDiff line change
@@ -1815,13 +1815,6 @@
18151815
lodash.snakecase "^4.1.1"
18161816
p-defer "^3.0.0"
18171817

1818-
"@grpc/grpc-js@^1.3.2":
1819-
version "1.3.7"
1820-
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.3.7.tgz#58b687aff93b743aafde237fd2ee9a3259d7f2d8"
1821-
integrity sha512-CKQVuwuSPh40tgOkR7c0ZisxYRiN05PcKPW72mQL5y++qd7CwBRoaJZvU5xfXnCJDFBmS3qZGQ71Frx6Ofo2XA==
1822-
dependencies:
1823-
"@types/node" ">=12.12.47"
1824-
18251818
"@grpc/grpc-js@~1.6.0":
18261819
version "1.6.7"
18271820
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.6.7.tgz#4c4fa998ff719fe859ac19fe977fdef097bb99aa"
@@ -1830,6 +1823,14 @@
18301823
"@grpc/proto-loader" "^0.6.4"
18311824
"@types/node" ">=12.12.47"
18321825

1826+
"@grpc/grpc-js@~1.7.0":
1827+
version "1.7.3"
1828+
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.7.3.tgz#f2ea79f65e31622d7f86d4b4c9ae38f13ccab99a"
1829+
integrity sha512-H9l79u4kJ2PVSxUNA08HMYAnUBLj9v6KjYQ7SQ71hOZcEXhShE/y5iQCesP8+6/Ik/7i2O0a10bPquIcYfufog==
1830+
dependencies:
1831+
"@grpc/proto-loader" "^0.7.0"
1832+
"@types/node" ">=12.12.47"
1833+
18331834
"@grpc/proto-loader@^0.6.12", "@grpc/proto-loader@^0.6.13", "@grpc/proto-loader@^0.6.4":
18341835
version "0.6.13"
18351836
resolved "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.13.tgz#008f989b72a40c60c96cd4088522f09b05ac66bc"
@@ -1841,6 +1842,17 @@
18411842
protobufjs "^6.11.3"
18421843
yargs "^16.2.0"
18431844

1845+
"@grpc/proto-loader@^0.7.0":
1846+
version "0.7.3"
1847+
resolved "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.3.tgz#75a6f95b51b85c5078ac7394da93850c32d36bb8"
1848+
integrity sha512-5dAvoZwna2Py3Ef96Ux9jIkp3iZ62TUsV00p3wVBPNX5K178UbNi8Q7gQVqwXT1Yq9RejIGG9G2IPEo93T6RcA==
1849+
dependencies:
1850+
"@types/long" "^4.0.1"
1851+
lodash.camelcase "^4.3.0"
1852+
long "^4.0.0"
1853+
protobufjs "^7.0.0"
1854+
yargs "^16.2.0"
1855+
18441856
"@gulp-sourcemaps/identity-map@^2.0.1":
18451857
version "2.0.1"
18461858
resolved "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-2.0.1.tgz#a6e8b1abec8f790ec6be2b8c500e6e68037c0019"
@@ -11889,6 +11901,11 @@ long@^4.0.0:
1188911901
resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
1189011902
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
1189111903

11904+
long@^5.0.0:
11905+
version "5.2.1"
11906+
resolved "https://registry.npmjs.org/long/-/long-5.2.1.tgz#e27595d0083d103d2fa2c20c7699f8e0c92b897f"
11907+
integrity sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A==
11908+
1189211909
loose-envify@^1.0.0:
1189311910
version "1.4.0"
1189411911
resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
@@ -14128,6 +14145,24 @@ [email protected], protobufjs@^6.11.3:
1412814145
"@types/node" ">=13.7.0"
1412914146
long "^4.0.0"
1413014147

14148+
protobufjs@^7.0.0:
14149+
version "7.1.2"
14150+
resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz#a0cf6aeaf82f5625bffcf5a38b7cd2a7de05890c"
14151+
integrity sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==
14152+
dependencies:
14153+
"@protobufjs/aspromise" "^1.1.2"
14154+
"@protobufjs/base64" "^1.1.2"
14155+
"@protobufjs/codegen" "^2.0.4"
14156+
"@protobufjs/eventemitter" "^1.1.0"
14157+
"@protobufjs/fetch" "^1.1.0"
14158+
"@protobufjs/float" "^1.0.2"
14159+
"@protobufjs/inquire" "^1.1.0"
14160+
"@protobufjs/path" "^1.1.2"
14161+
"@protobufjs/pool" "^1.1.0"
14162+
"@protobufjs/utf8" "^1.1.0"
14163+
"@types/node" ">=13.7.0"
14164+
long "^5.0.0"
14165+
1413114166
protocols@^1.1.0, protocols@^1.4.0:
1413214167
version "1.4.8"
1413314168
resolved "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8"

0 commit comments

Comments
 (0)