Skip to content

Commit

Permalink
chore: Update Typescript to 4.x (#1541)
Browse files Browse the repository at this point in the history
This is the second PR of a series of changes to update @google-cloud/firestore dependency to 5.x. This is a follow-up to #1540

- Upgraded Typescript from ~3.7.3 to ~4.4.3
- Fixed TS2790: The operand of a 'delete' operator must be optional errors

Note: Manually tested for backwards compatibility on TS 3.7.x to 4.5.x. We will add TS compatibility tests to CIs in the future.
  • Loading branch information
lahirumaramba committed Jan 14, 2022
1 parent db137e9 commit d8a3afa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"sinon": "^9.0.0",
"sinon-chai": "^3.0.0",
"ts-node": "^10.2.0",
"typescript": "^3.7.3",
"typescript": "^4.4.3",
"yargs": "^17.0.1"
}
}
12 changes: 6 additions & 6 deletions test/integration/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ describe('admin.auth', () => {
const actualTenantObj = actualTenant.toJSON();
if (authEmulatorHost) {
// Not supported in Auth Emulator
delete (actualTenantObj as {testPhoneNumbers: Record<string, string>}).testPhoneNumbers;
delete (actualTenantObj as {testPhoneNumbers?: Record<string, string>}).testPhoneNumbers;
delete expectedCreatedTenant.testPhoneNumbers;
}
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
Expand Down Expand Up @@ -1617,7 +1617,7 @@ describe('admin.auth', () => {
const actualTenantObj = actualTenant.toJSON();
if (authEmulatorHost) {
// Not supported in Auth Emulator
delete (actualTenantObj as {testPhoneNumbers: Record<string, string>}).testPhoneNumbers;
delete (actualTenantObj as {testPhoneNumbers?: Record<string, string>}).testPhoneNumbers;
delete expectedCreatedTenant.testPhoneNumbers;
}
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
Expand Down Expand Up @@ -1649,15 +1649,15 @@ describe('admin.auth', () => {
.then((actualTenant) => {
const actualTenantObj = actualTenant.toJSON();
// Not supported in Auth Emulator
delete (actualTenantObj as {testPhoneNumbers: Record<string, string>}).testPhoneNumbers;
delete (actualTenantObj as {testPhoneNumbers?: Record<string, string>}).testPhoneNumbers;
delete expectedUpdatedTenant.testPhoneNumbers;
expect(actualTenantObj).to.deep.equal(expectedUpdatedTenant);
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions2);
})
.then((actualTenant) => {
const actualTenantObj = actualTenant.toJSON();
// Not supported in Auth Emulator
delete (actualTenantObj as {testPhoneNumbers: Record<string, string>}).testPhoneNumbers;
delete (actualTenantObj as {testPhoneNumbers?: Record<string, string>}).testPhoneNumbers;
delete expectedUpdatedTenant2.testPhoneNumbers;
expect(actualTenantObj).to.deep.equal(expectedUpdatedTenant2);
});
Expand Down Expand Up @@ -2150,8 +2150,8 @@ describe('admin.auth', () => {
// Not supported in ID token,
delete decodedIdToken.nonce;
// exp and iat may vary depending on network connection latency.
delete decodedIdToken.exp;
delete decodedIdToken.iat;
delete (decodedIdToken as any).exp;
delete (decodedIdToken as any).iat;
expect(decodedIdToken).to.deep.equal(payloadClaims);
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/unit/auth/tenant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ describe('Tenant', () => {
it('should return the expected server request without multi-factor and phone config', () => {
const tenantOptionsClientRequest = deepCopy(clientRequestWithoutMfa);
const tenantOptionsServerRequest = deepCopy(serverRequestWithoutMfa);
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;
expect(Tenant.buildServerRequest(tenantOptionsClientRequest, !createRequest))
.to.deep.equal(tenantOptionsServerRequest);
});

it('should return the expected server request with multi-factor and phone config', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest);
const tenantOptionsServerRequest = deepCopy(serverRequest);
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;
expect(Tenant.buildServerRequest(tenantOptionsClientRequest, !createRequest))
.to.deep.equal(tenantOptionsServerRequest);
});
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Tenant', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest);
const tenantOptionsServerRequest = deepCopy(serverRequest);
tenantOptionsClientRequest.testPhoneNumbers = null;
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;
tenantOptionsServerRequest.testPhoneNumbers = {};

expect(Tenant.buildServerRequest(tenantOptionsClientRequest, !createRequest))
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('Tenant', () => {
it('should return the expected server request without multi-factor and phone config', () => {
const tenantOptionsClientRequest: CreateTenantRequest = deepCopy(clientRequestWithoutMfa);
const tenantOptionsServerRequest: TenantServerResponse = deepCopy(serverRequestWithoutMfa);
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;

expect(Tenant.buildServerRequest(tenantOptionsClientRequest, createRequest))
.to.deep.equal(tenantOptionsServerRequest);
Expand All @@ -190,7 +190,7 @@ describe('Tenant', () => {
it('should return the expected server request with multi-factor and phone config', () => {
const tenantOptionsClientRequest: CreateTenantRequest = deepCopy(clientRequest);
const tenantOptionsServerRequest: TenantServerResponse = deepCopy(serverRequest);
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;

expect(Tenant.buildServerRequest(tenantOptionsClientRequest, createRequest))
.to.deep.equal(tenantOptionsServerRequest);
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('Tenant', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest);
const tenantOptionsServerRequest = deepCopy(serverRequest);
tenantOptionsClientRequest.testPhoneNumbers = null;
delete tenantOptionsServerRequest.name;
delete (tenantOptionsServerRequest as any).name;
tenantOptionsServerRequest.testPhoneNumbers = {};

expect(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/security-rules/security-rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ describe('SecurityRules', () => {

it('should resolve with RulesetMetadataList when the response contains no page token', () => {
const response = deepCopy(LIST_RULESETS_RESPONSE);
delete response.nextPageToken;
delete (response as any).nextPageToken;
const stub = sinon
.stub(SecurityRulesApiClient.prototype, 'listRulesets')
.resolves(response);
Expand Down

0 comments on commit d8a3afa

Please sign in to comment.