Skip to content

[react-notifaction-system] Ref instances are nullable#58972

Merged
typescript-bot merged 1 commit intoDefinitelyTyped:masterfrom
eps1lon:fix/ref-bivariance/react-notifaction-system
Mar 16, 2022
Merged

[react-notifaction-system] Ref instances are nullable#58972
typescript-bot merged 1 commit intoDefinitelyTyped:masterfrom
eps1lon:fix/ref-bivariance/react-notifaction-system

Conversation

@eps1lon
Copy link
Copy Markdown
Collaborator

@eps1lon eps1lon commented Feb 24, 2022

Currently instances in ref callbacks are allowed to be nullable due to our bivariance hack. However, during runtime these instances can be null: https://codesandbox.io/s/refs-are-nullable-m44vxx

We'll likely remove the bivariance hack to catch these issues in the future. In the meantime, existing packages and tests should guard against nullable instances regardless.

The issue was first reported in #58464

ActionWrapper?: WrapperStyle | undefined;
}

export interface Attributes extends React.ClassAttributes<System> {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Props can't determine the ref type for class components. Needed to move code around so that NotificationSystem correctly extends a React.Component.

@eps1lon eps1lon marked this pull request as ready for review February 24, 2022 18:42
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Feb 24, 2022

@eps1lon Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners, DT maintainers or others

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 58972,
  "author": "eps1lon",
  "headCommitOid": "b5b0ab63875a1e3e946cd648f3814b3ada1a070e",
  "mergeBaseOid": "322b09e7e97422bbeb564159b9ffaafdd1c1827f",
  "lastPushDate": "2022-02-24T18:18:19.000Z",
  "lastActivityDate": "2022-03-16T19:50:45.000Z",
  "mergeOfferDate": "2022-03-16T19:48:34.000Z",
  "mergeRequestDate": "2022-03-16T19:50:45.000Z",
  "mergeRequestUser": "eps1lon",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "react-notification-system",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-notification-system/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-notification-system/react-notification-system-tests.tsx",
          "kind": "test"
        }
      ],
      "owners": [
        "GiedriusGrabauskas",
        "DeividasBakanas",
        "LKay",
        "sztobar"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "peterblazejewicz",
      "date": "2022-03-16T19:47:55.000Z",
      "isMaintainer": true
    }
  ],
  "mainBotCommentID": 1050151178,
  "ciResult": "pass"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @GiedriusGrabauskas @DeividasBakanas @LKay @sztobar — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot
Copy link
Copy Markdown
Contributor

Re-ping @GiedriusGrabauskas, @DeividasBakanas, @LKay, @sztobar:

This PR has been out for over a week, yet I haven't seen any reviews.

Could someone please give it some attention? Thanks!

@typescript-bot typescript-bot added the Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. label Mar 7, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

It has been more than two weeks and this PR still has no reviews.

I'll bump it to the DT maintainer queue. Thank you for your patience, @eps1lon.

(Ping @GiedriusGrabauskas, @DeividasBakanas, @LKay, @sztobar.)

@peterblazejewicz
Copy link
Copy Markdown
Member

this one is potentially breaking if accepted, due to changes symbols with 'export' keyword. Any feedback from the owners?

@eps1lon
Copy link
Copy Markdown
Collaborator Author

eps1lon commented Mar 16, 2022

this one is potentially breaking if accepted, due to changes symbols with 'export' keyword.

What is the breaking change here? Or rather what is the "bad" breaking change here. As far as I can tell this is only breaking for incorrect usage. But maybe I'm missing something?

@eps1lon
Copy link
Copy Markdown
Collaborator Author

eps1lon commented Mar 16, 2022

To be clear: I don't know how this namespace + declare var even works. As soon as I try to change export interface System to export class System it tells me "duplicate identifier NotificationSystem". This is just super confusing.

So it seems to me this is a very old typing pattern that isn't used anymore. So I'd really like to get rid of it and take the breaking change since it's been blocking work for over 20 days now.

@peterblazejewicz
Copy link
Copy Markdown
Member

The 'bad' change is someone using explicit types, just like in the code you've changed:

private notificationSystem: NotificationSystem.System = null;

just raising this as a concern, there is no major/minor change and there is no feedback from owners.
For me that's OK, if people complain, we will kindly ask to freeze version, otherwise move forward.

@peterblazejewicz
Copy link
Copy Markdown
Member

The native module export class, this DT could have been written differently, so I agree.

Copy link
Copy Markdown
Member

@peterblazejewicz peterblazejewicz left a comment

Choose a reason for hiding this comment

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

LGTM!

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner and removed Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. labels Mar 16, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@eps1lon: Everything looks good here. I am ready to merge this PR (at b5b0ab6) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@GiedriusGrabauskas, @DeividasBakanas, @LKay, @sztobar: you can do this too.)

@eps1lon
Copy link
Copy Markdown
Collaborator Author

eps1lon commented Mar 16, 2022

Ready to merge

@typescript-bot typescript-bot merged commit 277df65 into DefinitelyTyped:master Mar 16, 2022
@eps1lon eps1lon deleted the fix/ref-bivariance/react-notifaction-system branch March 16, 2022 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants