Skip to content

fix: add typings to v1 and v1beta in firestore.d.ts #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 2, 2021
Merged

Conversation

thebrianchen
Copy link

@thebrianchen thebrianchen commented Mar 1, 2021

Add external typings for v1 and v1beta1 in firestore.d.ts files by copying over the generated .d.ts files into types/.

Fixes #1422.

@thebrianchen thebrianchen self-assigned this Mar 1, 2021
@thebrianchen thebrianchen requested review from a team as code owners March 1, 2021 22:24
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 1, 2021
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Mar 1, 2021
@codecov
Copy link

codecov bot commented Mar 1, 2021

Codecov Report

Merging #1433 (ee28ed6) into master (071c27b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1433   +/-   ##
=======================================
  Coverage   98.20%   98.20%           
=======================================
  Files          32       32           
  Lines       19502    19502           
  Branches     1363     1363           
=======================================
  Hits        19152    19152           
  Misses        346      346           
  Partials        4        4           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 071c27b...9b70dc2. Read the comment docs.

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Approach LGTM. Some improvement suggestions.

I also wonder whether this should be a fix or even a feat since this is something that we want to create a release for,

@@ -1964,13 +1980,16 @@ declare namespace FirebaseFirestore {
* Firestore v1beta1 RPCs.
* @deprecated Use v1 instead.
*/
export const v1beta1: any;
export const v1beta1: typeof import('./v1beta1/firestore_client');
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just do a regular import:

import v1beta1 from '...';
import {FirestoreClient, FirestoreAdminClient} from '...'

Copy link
Contributor

Choose a reason for hiding this comment

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

Approach LGTM. Some improvement suggestions.

I also wonder whether this should be a fix or even a feat since this is something that we want to create a release for,

'fix' should cause a patch release.

Copy link
Author

Choose a reason for hiding this comment

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

I don't think top level imports in .d.ts files are allowed (see stackoverflow). I played around with it, but it always ended in sadness.

Copy link
Author

Choose a reason for hiding this comment

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

Update: Following our conversation, changed to use import directly inline, rather than use typeof.

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

There are now two copyright headers.

Copy link
Author

Choose a reason for hiding this comment

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

removed.

@thebrianchen thebrianchen changed the title chore: add typings to v1 and v1beta in firestore.d.ts fix: add typings to v1 and v1beta in firestore.d.ts Mar 2, 2021
@@ -1964,13 +1962,16 @@ declare namespace FirebaseFirestore {
* Firestore v1beta1 RPCs.
* @deprecated Use v1 instead.
*/
export const v1beta1: any;
export const v1beta1: import('./v1beta1/firestore_client').FirestoreClient;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit torn about using the default export here, which is really an anti-pattern and not used in the export below. I think no matter how we export this, we have a chance of breaking users, but the clean way would be to export this as { FirestoreClient: import(...).FirestoreClient }. That both works is technical debt that I would like to not carry forward.

Copy link
Author

Choose a reason for hiding this comment

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

done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add type definitions for v1 and v1beta1 clients
3 participants