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

feat: Enable TS strict #244

Merged
merged 2 commits into from
Jan 14, 2022
Merged

feat: Enable TS strict #244

merged 2 commits into from
Jan 14, 2022

Conversation

DominicSherman
Copy link
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
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.

@@ -51,9 +51,14 @@ export function LoginForm() {
try {
setIsLoading(true);
const { data } = await login({ variables: formData });

if (!data?.login?.token) {
throw new Error('Login failed.');
Copy link
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.

@@ -65,10 +65,14 @@ export function SignupForm() {

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

if (!data?.signup?.token) {
throw new Error('Signpup failed.');
Copy link
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"

.findUnique({
where: { id: parent.id },
})
.user();

if (!user) {
throw new ApolloError('User not found', '404');
Copy link
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