Skip to content

Use strictNullChecks in matrix-react-sdk #21967

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

Closed
novocaine opened this issue Apr 28, 2022 · 3 comments · Fixed by matrix-org/matrix-react-sdk#11194
Closed

Use strictNullChecks in matrix-react-sdk #21967

novocaine opened this issue Apr 28, 2022 · 3 comments · Fixed by matrix-org/matrix-react-sdk#11194
Assignees
Labels

Comments

@novocaine
Copy link
Contributor

novocaine commented Apr 28, 2022

Your use case

https://www.typescriptlang.org/tsconfig#strictNullChecks

This will reduce the number of runtime errors caused by unexpected null and undefined values by disallowing them as a value unless explicitly permitted.

Related: matrix-org/matrix-js-sdk#2112

### Tasks
- [ ] https://github.com/vector-im/element-web/issues/24659
- [x] https://github.com/vector-im/element-web/issues/24658
- [ ] https://github.com/vector-im/element-web/issues/24657
- [ ] https://github.com/vector-im/element-web/issues/24656
- [x] https://github.com/vector-im/element-web/issues/24655
- [ ] https://github.com/vector-im/element-web/issues/24654
- [x] https://github.com/vector-im/element-web/issues/24653
- [x] https://github.com/vector-im/element-web/issues/24652
- [ ] https://github.com/vector-im/element-web/issues/24651
- [ ] https://github.com/vector-im/element-web/issues/24650
- [x] https://github.com/vector-im/element-web/issues/24649
- [ ] https://github.com/vector-im/element-web/issues/24756
- [ ] https://github.com/vector-im/element-web/issues/24755
- [ ] https://github.com/vector-im/element-web/issues/24754
- [ ] https://github.com/vector-im/element-web/issues/24753
- [ ] https://github.com/vector-im/element-web/issues/24822
- [ ] https://github.com/vector-im/element-web/issues/24836
- [ ] https://github.com/vector-im/element-web/issues/24935
- [ ] https://github.com/vector-im/element-web/issues/24936
- [ ] https://github.com/vector-im/element-web/issues/24938
- [ ] https://github.com/vector-im/element-web/issues/24937
- [ ] https://github.com/vector-im/element-web/issues/24940
- [ ] https://github.com/vector-im/element-web/issues/24939
- [ ] https://github.com/vector-im/element-web/issues/24941
- [ ] https://github.com/vector-im/element-web/issues/25217
- [ ] https://github.com/vector-im/element-web/issues/24944
- [ ] https://github.com/vector-im/element-web/issues/24945
- [ ] https://github.com/vector-im/element-web/issues/24946
- [ ] https://github.com/vector-im/element-web/issues/24948
- [ ] https://github.com/vector-im/element-web/issues/25017
- [ ] https://github.com/vector-im/element-web/issues/25086
- [ ] https://github.com/vector-im/element-web/issues/24943
- [ ] https://github.com/vector-im/element-web/issues/25087
- [ ] https://github.com/vector-im/element-web/issues/25088
- [ ] https://github.com/vector-im/element-web/issues/25370
- [ ] https://github.com/vector-im/element-web/issues/24752
- [ ] https://github.com/vector-im/element-web/issues/24947
- [ ] https://github.com/vector-im/element-web/issues/24942
- [ ] https://github.com/vector-im/element-web/issues/24838
- [ ] https://github.com/vector-im/element-web/issues/25344
- [x] Apply `strictNullChecks` to `src/components/structures/InteractiveAuth.tsx`
- [x] Apply `strictNullChecks` to `src/Lifecycle.ts`
- [x] Apply `strictNullChecks` to `src/components/structures/RoomView.tsx`
- [x] Apply `strictNullChecks` to `src/components/structures/ScrollPanel.tsx`
- [x] Apply `strictNullChecks` to `src/components/structures/TimelinePanel.tsx`
- [x] Apply `strictNullChecks` to `src/IdentityAuthClient.tsx` & `src/AddThreepid.ts`
- [x] Apply `strictNullChecks` to `src/components/views/rooms/R*.tsx`
- [x] Apply `strictNullChecks` to `src/createRoom.ts`
- [x] Apply `strictNullChecks` to `src/components/views/rooms/[NPST]*.tsx`
- [x] Apply `strictNullChecks` to `src/components/views/dialogs/*`
- [x] Apply `strictNullChecks` to `src/components/structures/MatrixChat.tsx`
- [x] Apply `strictNullChecks` to `src/audio/*`
- [x] Apply `strictNullChecks` to `src/customisations/Media.ts`
- [ ] https://github.com/vector-im/element-web/issues/25345

Have you considered any alternatives?

No response

Additional context

No response

@MadLittleMods
Copy link
Contributor

MadLittleMods commented May 6, 2022

We currently have 5738 errors when enabling strictNullChecks on matrix-react-sdk.

It would be nice to start using this for all of our new code and only apply strictNullChecks to the changes in the PR (from the git diff). We can run Typescript against the files that changed and filter the errors/warnings to only the line numbers that changed.

Looks like there are some options for ESLint which we could base off of:

For staged files:


Alternatively, we could add an extra assertion that the the number of strictNullChecks can't go up from the number on develop which means you have to fix any new code introduced.

@novocaine
Copy link
Contributor Author

Thanks @MadLittleMods, that seems like a great approach.

If you're interested in helping working through that backlog .. we could use as many hands as we can get to chip away at it

@t3chguy
Copy link
Member

t3chguy commented Feb 24, 2023

Things remaining:

Found 18 errors in 9 files.

Errors  Files
     1  ../matrix-js-sdk/src/client.ts:7235
     1  src/components/structures/InteractiveAuth.tsx:113
     4  src/components/structures/RoomView.tsx:1102
     1  src/components/structures/TimelinePanel.tsx:650
     1  src/components/views/dialogs/BaseDialog.tsx:97
     1  src/components/views/dialogs/ScrollableBaseModal.tsx:46
     3  src/components/views/spaces/SpaceTreeLevel.tsx:107
     2  src/Lifecycle.ts:675
     4  src/Searching.ts:488

@t3chguy t3chguy pinned this issue May 10, 2023
@t3chguy t3chguy unpinned this issue May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants