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

chore(noImplicitAny): fix more errors #6161

Merged
merged 5 commits into from
Mar 17, 2022
Merged

chore(noImplicitAny): fix more errors #6161

merged 5 commits into from
Mar 17, 2022

Conversation

mattkrick
Copy link
Member

fix #5831

notes:

  • removed stripe.js in favor of the new StripeManager, quicker than writing types for the legacy file

comments.push(comment)
const comment = commentLookup[reflection.id as keyof typeof commentLookup]
if (Array.isArray(comment)) {
// I think this was a bug before...
Copy link
Member Author

Choose a reason for hiding this comment

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

noImplicitAny caught a bug here

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why the array check is necessary? If reflection.id doesn't exist in commentLookup, comment should be undefined? +1 could elaborate on the comment here

Copy link
Member Author

Choose a reason for hiding this comment

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

all the values in commentLookup are arrays. perhaps that was an error? i didn't want to change that though

@@ -1,5 +1,6 @@
import graphql from 'babel-plugin-relay/macro'
import Parser from 'json2csv/lib/JSON2CSVParser' // only grab the sync parser
import type {Parser as JSON2CSVParser} from 'json2csv'
Copy link
Member Author

Choose a reason for hiding this comment

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

i don't usually import type, but i wanted to be sure we aren't imported the whole package because it's a big one

@@ -307,14 +307,6 @@ export const enum SubscriptionChannel {
ORGANIZATION = 'organization'
}

export const enum SuggestedActionTypeEnum {
Copy link
Member Author

Choose a reason for hiding this comment

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

we now have a single source of truth for these in the graphql enum

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, single source of truth! the keyof typeof is really helpful when doing TypeScript legacy support.
btw: have we tried any migration tool like ts-migrate before? I'm curious about how it will actually work.

Copy link
Member Author

Choose a reason for hiding this comment

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

the last time i checked it out it was still a little buggy & at best it would just explicitly cast things as any as a fallback.
this little exercise probably took the team 30-40 hours to complete, but we uncovered some cool bugs & got some really useful patterns (like keyof typeof) in place so future developers have some good patterns to go off of.

)
// turned into a noop to remove dependency on stripe
const subscriptions = []
// const orgIds = Object.keys(orgs)
Copy link
Member Author

Choose a reason for hiding this comment

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

deleted the stripe helper, which this depends on, so had to remove any logic using it.
in the future, we shouldn't do stripe things in migrations, but this was 6 years ago

@@ -18,9 +17,9 @@ const headerStyle = {
paddingTop: 24
}

const getHeaderText = (meetingType) => {
const getHeaderText = (meetingType: 'retrospective' | 'action' | 'poker') => {
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we use the same way as TSuggestedActionTypeEnum, to use the MeetingTypeEnum type extracted from GraphQLEnumType?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep! the relay-compiler gives us those enums in the generated files so we don't have to reference the server from the client so I'll just pull from there.

import {
  MeetingMembersWithoutTasks_meeting,
  MeetingTypeEnum
} from 'parabol-client/__generated__/MeetingMembersWithoutTasks_meeting.graphql'

Copy link
Contributor

@nickoferrall nickoferrall left a comment

Choose a reason for hiding this comment

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

LGTM!

comments.push(comment)
const comment = commentLookup[reflection.id as keyof typeof commentLookup]
if (Array.isArray(comment)) {
// I think this was a bug before...
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why the array check is necessary? If reflection.id doesn't exist in commentLookup, comment should be undefined? +1 could elaborate on the comment here

@@ -26,7 +26,7 @@ const innerStyle = {
width: '100%'
} as const

const EmailBlock = (props) => {
const EmailBlock = (props: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 could add types here and remove propTypes?

type Props = {
  align?: 'center' | 'left'
  children: ReactNode
  innerMaxWidth: number
  hasBackgroundColor?: boolean
}

const EmailBlock = (props: Props) => {
  const {align = 'left', hasBackgroundColor, children, innerMaxWidth} = props

It looks like align and width properties can be removed from <table>

Copy link
Member Author

Choose a reason for hiding this comment

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

this component is HTML4 😨
that's the only way to write components so they work in email

packages/client/utils/date/relativeDate.ts Outdated Show resolved Hide resolved
orgId,
startAt: fromEpochSeconds(stripeInvoice.period_start),
startingBalance: stripeInvoice.startingBalance,
startingBalance: stripeInvoice.starting_balance,
Copy link
Contributor

Choose a reason for hiding this comment

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

+2 TypeScript FTW 🎉

{first, queryString, isJQL, projectKeyFilters},
{authToken}: GQLContext
) => {
resolve: async ({teamId, userId, accessToken, cloudIds}, args: any, {authToken}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering why you didn't do args: IssueArgs and remove the casting below, but I see it makes the field type incompatible. Annoying that you can't define the args type in a GraphQLObjectType

@mattkrick mattkrick merged commit 072cdfc into master Mar 17, 2022
@mattkrick mattkrick deleted the chore/noImplicitAny branch March 17, 2022 18:17
Dschoordsch added a commit that referenced this pull request Mar 18, 2022
Migration is many years old and the used stripe manager was deleted in
PR #6161.
mattkrick pushed a commit that referenced this pull request Mar 21, 2022
Migration is many years old and the used stripe manager was deleted in
PR #6161.
@adaniels-parabol adaniels-parabol mentioned this pull request Mar 25, 2022
16 tasks
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.

Add noImplicitAny to server tsconfig (Part 6 of 8)
3 participants