Skip to content

Enable noUncheckedIndexedAccess in StatefulCallClient and Calling-Component-Bindings#5242

Merged
JamesBurnside merged 6 commits intomainfrom
jaburnsi/noUncheckedIndexedAccess
Oct 4, 2024
Merged

Enable noUncheckedIndexedAccess in StatefulCallClient and Calling-Component-Bindings#5242
JamesBurnside merged 6 commits intomainfrom
jaburnsi/noUncheckedIndexedAccess

Conversation

@JamesBurnside
Copy link
Copy Markdown
Member

@JamesBurnside JamesBurnside commented Oct 3, 2024

What

  • In the common tsconfig, set noUncheckedIndexedAccess to true
  • In packages were we do not have instances of this fixed, explicitly set to false with the goal of slowly migrate these to true
  • Fixup in StatefulCallClient packlet and Calling-Component-Bindings packlet as examples

Why

We have had several bugs stemming from this issue (often these lead to app crashes).
As an example: What happens is const a: string = some_array[5]; will type a as string. However this is not always the case! if some_array[5] is beyond the range of the array then a is undefined. This causes exceptions, for example if a.someFn() is called, it will throw saying someFn does not exist on undefined. Really a should've been typed as string | undefined then developer handles the undefined case. This is easily gated and handled at compile time with noUncheckedIndexedAccess flag.

How Tested

CI only

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

Chat bundle size is not changed.

  • Current size: 1756532
  • Base size: 1756532
  • Diff size: 0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

Calling bundle size is not changed.

  • Current size: 11750180
  • Base size: 11750180
  • Diff size: 0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

CallWithChat bundle size is not changed.

  • Current size: 11750193
  • Base size: 11750193
  • Diff size: 0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

@azure/communication-react jest test coverage for stable.

Lines Statements Functions Branches
Base 26640 / 42876
62.13%
26640 / 42876
62.13%
729 / 1329
54.85%
2126 / 3384
62.82%
Current 26680 / 42905
62.18%
26680 / 42905
62.18%
729 / 1329
54.85%
2126 / 3393
62.65%
Diff 40 / 29
0.05%
40 / 29
0.05%
0 / 0
0%
0 / 9
-0.17%

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 3, 2024

@azure/communication-react jest test coverage for beta.

Lines Statements Functions Branches
Base 53962 / 88162
61.2%
53962 / 88162
61.2%
1085 / 2475
43.83%
3195 / 5270
60.62%
Current 53922 / 88208
61.13%
53922 / 88208
61.13%
1085 / 2475
43.83%
3190 / 5265
60.58%
Diff -40 / 46
-0.07%
-40 / 46
-0.07%
0 / 0
0%
-5 / -5
-0.04%

expect(Object.keys(context.getState().callsEnded).length).toBe(1);
expect(context.getState().callsEnded[mockCallId].callEndReason?.code).toBe(1);
expect(context.getState().callsEnded[mockCallId].endTime).toBeTruthy();
expect(context.getState().callsEnded[mockCallId]?.callEndReason?.code).toBe(1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this because the return on these callEndReasons are strings?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The ? is added because context.getState().callsEnded[mockCallId] now correctly returns Call | undefined (importantly the | undefined is now added to typescripts interpretation of the return type because the call is accessed via object[key] where key isn't guaranteed to exist)

Copy link
Copy Markdown
Member

@emlynmac emlynmac left a comment

Choose a reason for hiding this comment

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

Nice to see this change going in!

@JamesBurnside JamesBurnside enabled auto-merge (squash) October 4, 2024 20:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 4, 2024

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.

4 participants