Skip to content

feat: Enable TS strict#244

Merged
DominicSherman merged 2 commits intocanaryfrom
enable-ts-strict
Jan 14, 2022
Merged

feat: Enable TS strict#244
DominicSherman merged 2 commits intocanaryfrom
enable-ts-strict

Conversation

@DominicSherman
Copy link
Copy Markdown
Contributor

Changes

  • Enable strict mode in the TS config
  • Fix all issues that arose from strict being enabled

Checklist

  • Generating a new app works

Copy link
Copy Markdown
Contributor

@kgajera kgajera left a comment

Choose a reason for hiding this comment

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

Good work! Found one typo that should be fixed. The other comments were more opinionated so feel free to leave comments if you disagree.

const { data } = await login({ variables: formData });

if (!data?.login?.token) {
throw new Error('Login failed.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably out of the scope of this PR, but we should create another issue to display some kind of user feedback when this is error is thrown.

const { data } = await signup({ variables });

if (!data?.signup?.token) {
throw new Error('Signpup failed.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo: "Signpup" should be "Signup"

.user();

if (!user) {
throw new ApolloError('User not found', '404');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would recommend creating a custom error, like NotFoundError, for this because we will need to use this frequently in real apps and we don't want to have to repeat the error code each time.

Just my opinion, but I would also favor using NOT_FOUND as the error code because Apollo doesn't use HTTP response codes for their built-in errors.

@DominicSherman DominicSherman merged commit abc7075 into canary Jan 14, 2022
@DominicSherman DominicSherman deleted the enable-ts-strict branch January 14, 2022 15:40
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