Skip to content
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

IrcBridge.memberListSyncers: Object -> Map #1610

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

jaller94
Copy link
Contributor

  • TypeScript pretends that for the Object {[foo: string], Bar} every key will return you an Bar, even though undefined is a possibility. The usage of Map shows us that we may need to validate if a MemberListSyncer was returned.
  • Protects against the unlikely foot gun that someone configures a __proto__ domain.

@jaller94 jaller94 requested a review from a team as a code owner September 21, 2022 16:06
@jaller94
Copy link
Contributor Author

Remaining issues:


src/bridge/IrcBridge.ts:1479:17 - error TS2532: Object is possibly 'undefined'.

1479                 this.memberListSyncers.get(room.getServer().domain).addToLeavePool(
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/bridge/MatrixHandler.ts:802:27 - error TS2532: Object is possibly 'undefined'.

802                     await this.ircBridge.getMemberListSyncer(ircRoom.server).checkBotPartRoom(
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/irc/ClientPool.ts:140:37 - error TS2532: Object is possibly 'undefined'.

140                 chansToJoin = await this.ircBridge.getMemberListSyncer(server).getChannelsToJoin();
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/provisioning/Provisioner.ts:1066:16 - error TS2532: Object is possibly 'undefined'.

1066         return this.ircBridge.getMemberListSyncer(server).addToLeavePool(
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 4 errors in 4 files.

Errors  Files
     1  src/bridge/IrcBridge.ts:1479
     1  src/bridge/MatrixHandler.ts:802
     1  src/irc/ClientPool.ts:140
     1  src/provisioning/Provisioner.ts:1066

@jaller94 jaller94 marked this pull request as draft September 21, 2022 16:07
@@ -0,0 +1 @@
IrcBridge.memberListSyncers: Object -> Map.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be much more descriptive :). Needs to identify the change from the end user perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants