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

refactor: remove typecasts and non-null assertions #1596

Merged
merged 10 commits into from
Apr 9, 2021

Conversation

mantariksh
Copy link
Contributor

Problem

Type casting and non-null assertions limit the type safety provided by the compiler.

Closes #42
Closes #317

Solution

Remove all non-null assertions as well as type casts which were highlighted under #42. In addition, introduce a linting rule which forbids non-null assertions.

Typing of SPCP JWT payload

This change was slightly trickier than the rest. The problem was that both Singpass and Corppass JWTs were typed with the same JwtPayloadtype, resulting in difficulty telling when the userInfo property was present, since it is only present for Corppass JWTs.

The solution was to separate the logic for extracting Singpass vs Corppass JWTs. This was easy to accomplish, which suggests that this should have been the implementation from the start.

Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

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

lgtm with some nits.

src/app/modules/spcp/spcp.service.ts Outdated Show resolved Hide resolved
src/app/modules/spcp/spcp.service.ts Outdated Show resolved Hide resolved
src/types/email_mode_data.ts Show resolved Hide resolved
@mantariksh mantariksh merged commit 437e16e into develop Apr 9, 2021
@karrui karrui mentioned this pull request Apr 13, 2021
@mantariksh mantariksh deleted the ref/remove-casts branch April 13, 2021 06:35
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.

Remove usage of non-null assertion operator Remove forced typecastings from converted Typescript files
2 participants