Skip to content

Update typing for new TS versions #6365

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 1 commit into from
Jun 17, 2022
Merged

Update typing for new TS versions #6365

merged 1 commit into from
Jun 17, 2022

Conversation

dwyfrequency
Copy link
Contributor

@dwyfrequency dwyfrequency commented Jun 16, 2022

Update codebase to conform to later typescript versions. TS version > 4.4 gave TS errors for the lack of return type and not using arrow functions as a callback. TS version 4.4 requires updating catch variables as unknown. See additional information below.

"""
In JavaScript, any type of value can be thrown with throw and caught in a catch clause. Because of this, TypeScript historically typed catch clause variables as any, and would not allow any other type annotation:

Once TypeScript added the unknown type, it became clear that unknown was a better choice than any in catch clause variables for users who want the highest degree of correctness and type-safety, since it narrows better and forces us to test against arbitrary values. Eventually TypeScript 4.0 allowed users to specify an explicit type annotation of unknown (or any) on each catch clause variable so that we could opt into stricter types on a case-by-case basis; however, for some, manually specifying : unknown on every catch clause was a chore.
"""
per https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2022

⚠️ No Changeset found

Latest commit: ccb3af5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

Size Report 1

Affected Products

  • @firebase/analytics

    TypeBase (578dc58)Merge (3799c84)Diff
    browser19.0 kB19.1 kB+178 B (+0.9%)
    esm523.6 kB23.8 kB+178 B (+0.8%)
    main24.7 kB24.9 kB+178 B (+0.7%)
    module19.0 kB19.1 kB+178 B (+0.9%)
  • @firebase/messaging

    TypeBase (578dc58)Merge (3799c84)Diff
    browser21.3 kB21.3 kB+53 B (+0.2%)
    esm526.6 kB26.7 kB+53 B (+0.2%)
    main27.3 kB27.4 kB+53 B (+0.2%)
    module21.3 kB21.3 kB+53 B (+0.2%)
  • @firebase/messaging-sw

    TypeBase (578dc58)Merge (3799c84)Diff
    main30.0 kB30.1 kB+53 B (+0.2%)
    module23.3 kB23.3 kB+53 B (+0.2%)
  • bundle

    TypeBase (578dc58)Merge (3799c84)Diff
    analytics (logEvent)41.6 kB41.8 kB+138 B (+0.3%)
    messaging (send + receive)45.1 kB45.1 kB+49 B (+0.1%)
  • firebase

    TypeBase (578dc58)Merge (3799c84)Diff
    firebase-analytics-compat.js25.6 kB25.8 kB+136 B (+0.5%)
    firebase-analytics.js111 kB112 kB+241 B (+0.2%)
    firebase-compat.js794 kB794 kB+214 B (+0.0%)
    firebase-messaging-compat.js38.1 kB38.2 kB+78 B (+0.2%)
    firebase-messaging-sw.js107 kB107 kB+71 B (+0.1%)
    firebase-messaging.js106 kB106 kB+71 B (+0.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/tAc5Ln0m9v.html

@google-oss-bot
Copy link
Contributor

Size Analysis Report 1

Affected Products

  • @firebase/analytics

    • getAnalytics

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.80 kB9.94 kB+138 B (+1.4%)
      size-with-ext-deps35.9 kB36.0 kB+138 B (+0.4%)
    • initializeAnalytics

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.69 kB9.83 kB+138 B (+1.4%)
      size-with-ext-deps35.7 kB35.8 kB+138 B (+0.4%)
    • isSupported

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.58 kB9.72 kB+138 B (+1.4%)
      size-with-ext-deps35.2 kB35.4 kB+138 B (+0.4%)
    • logEvent

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.44 kB9.58 kB+138 B (+1.5%)
      size-with-ext-deps35.1 kB35.2 kB+138 B (+0.4%)
    • setAnalyticsCollectionEnabled

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.61 kB9.75 kB+138 B (+1.4%)
      size-with-ext-deps35.3 kB35.4 kB+138 B (+0.4%)
    • setCurrentScreen

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.69 kB9.83 kB+138 B (+1.4%)
      size-with-ext-deps35.3 kB35.5 kB+138 B (+0.4%)
    • setUserId

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.67 kB9.81 kB+138 B (+1.4%)
      size-with-ext-deps35.3 kB35.5 kB+138 B (+0.4%)
    • setUserProperties

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.75 kB9.89 kB+138 B (+1.4%)
      size-with-ext-deps35.4 kB35.5 kB+138 B (+0.4%)
    • settings

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size9.57 kB9.71 kB+138 B (+1.4%)
      size-with-ext-deps35.2 kB35.4 kB+138 B (+0.4%)
  • @firebase/messaging

    • deleteToken

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size12.7 kB12.7 kB+49 B (+0.4%)
      size-with-ext-deps38.2 kB38.3 kB+49 B (+0.1%)
    • getMessaging

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size13.1 kB13.2 kB+49 B (+0.4%)
      size-with-ext-deps38.8 kB38.8 kB+49 B (+0.1%)
    • getToken

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size12.6 kB12.6 kB+49 B (+0.4%)
      size-with-ext-deps38.1 kB38.1 kB+49 B (+0.1%)
    • isSupported

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size12.9 kB13.0 kB+49 B (+0.4%)
      size-with-ext-deps38.4 kB38.5 kB+49 B (+0.1%)
    • onMessage

      Size

      TypeBase (578dc58)Merge (3799c84)Diff
      size12.7 kB12.7 kB+49 B (+0.4%)
      size-with-ext-deps38.2 kB38.3 kB+49 B (+0.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/s2XNiCKQC2.html

@dwyfrequency dwyfrequency marked this pull request as ready for review June 16, 2022 19:19
@dwyfrequency dwyfrequency merged commit d87d3a8 into master Jun 17, 2022
@dwyfrequency dwyfrequency deleted the tsUpdates branch June 17, 2022 14:45
@firebase firebase locked and limited conversation to collaborators Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants