Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
44 changes: 23 additions & 21 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
},
"optionalDependencies": {
"@google-cloud/firestore": "^7.11.0",
"@google-cloud/storage": "^7.14.0"
"@google-cloud/storage": "^7.19.0"
},
"devDependencies": {
"@firebase/api-documenter": "^0.5.0",
Expand Down Expand Up @@ -271,7 +271,7 @@
"sinon": "^18.0.0",
"sinon-chai": "^3.0.0",
"ts-node": "^10.2.0",
"typescript": "5.5.4",
"typescript": "^5.7.3",
"yargs": "^17.0.1"
}
}
4 changes: 2 additions & 2 deletions src/utils/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class AsyncHttpCall extends AsyncRequestCall {
try {
this.httpConfigImpl = httpConfigImpl;
this.options = this.httpConfigImpl.buildRequestOptions();
this.entity = this.httpConfigImpl.buildEntity(this.options.headers!);
this.entity = this.httpConfigImpl.buildEntity(this.options.headers as http.OutgoingHttpHeaders);

Choose a reason for hiding this comment

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

medium

While using as http.OutgoingHttpHeaders works, it's a type assertion that tells the compiler to trust you, which can hide potential bugs if the type assumptions are wrong. A safer and clearer approach is to use a type guard. This ensures this.options.headers is always an object, making the code more robust against future changes and satisfying the compiler without forcing a type.

      if (!this.options.headers) {
        this.options.headers = {};
      }
      this.entity = this.httpConfigImpl.buildEntity(this.options.headers);

this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
Expand Down Expand Up @@ -828,7 +828,7 @@ class AsyncHttp2Call extends AsyncRequestCall {
try {
this.http2ConfigImpl = http2ConfigImpl;
this.options = this.http2ConfigImpl.buildRequestOptions();
this.entity = this.http2ConfigImpl.buildEntity(this.options.headers!);
this.entity = this.http2ConfigImpl.buildEntity(this.options.headers as http.OutgoingHttpHeaders);

Choose a reason for hiding this comment

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

medium

Similar to the previous comment, using a type assertion with as can suppress potential type errors. A safer and clearer approach is to use a type guard. This ensures this.options.headers is always an object, making the code more robust against future changes and satisfying the compiler without forcing a type.

      if (!this.options.headers) {
        this.options.headers = {};
      }
      this.entity = this.http2ConfigImpl.buildEntity(this.options.headers);

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this one should be as http2.OutgoingHttpHeaders but I also don't remember if both map to the same interface.

this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
Expand Down
Loading