Skip to content

Commit

Permalink
fix(noImplicitAny): Fixup 200 ts rules (Part 2 of 2) (#7193)
Browse files Browse the repository at this point in the history
* dx: begin client noImplicitAny

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* fix: 50 file checkpoint

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* remove getInProxy

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* finish all bugs in mutations dir

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* fix: finish remaining lint

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* turn on noImplicitAny for repo

Signed-off-by: Matt Krick <matt.krick@gmail.com>

* address CR comments

Signed-off-by: Matt Krick <matt.krick@gmail.com>

Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick committed Oct 7, 2022
1 parent d51ca5a commit c5b7306
Show file tree
Hide file tree
Showing 231 changed files with 1,053 additions and 991 deletions.
2 changes: 1 addition & 1 deletion packages/client/components/ActionMeetingUpdatesPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StyledHeader = styled(PhaseHeaderTitle)({
fontSize: 18
})

const getQuestion = (isConnected, taskCount, preferredName) => {
const getQuestion = (isConnected: boolean | null, taskCount: number, preferredName: string) => {
if (isConnected) {
return taskCount > 0 ? 'what’s changed with your tasks?' : 'what are you working on?'
}
Expand Down
5 changes: 3 additions & 2 deletions packages/client/components/AddTeamMemberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ICON_SIZE} from '~/styles/typographyV2'
import modalTeamInvitePng from '../../../static/images/illustrations/illus-modal-team-invite.png'
import useBreakpoint from '../hooks/useBreakpoint'
import InviteToTeamMutation from '../mutations/InviteToTeamMutation'
import {CompletedHandler} from '../types/relayMutations'
import parseEmailAddressList from '../utils/parseEmailAddressList'
import plural from '../utils/plural'
import {AddTeamMemberModal_teamMembers} from '../__generated__/AddTeamMemberModal_teamMembers.graphql'
Expand Down Expand Up @@ -135,7 +136,7 @@ const AddTeamMemberModal = (props: Props) => {
if (rawInvitees === nextValue) return
const {parsedInvitees, invalidEmailExists} = parseEmailAddressList(nextValue)
const allInvitees = parsedInvitees
? (parsedInvitees.map((invitee) => (invitee as any).address) as string[])
? (parsedInvitees.map((invitee: any) => invitee.address) as string[])
: []
const teamEmailSet = new Set(teamMembers.map(({email}) => email))
const uniqueInvitees = Array.from(new Set(allInvitees))
Expand Down Expand Up @@ -176,7 +177,7 @@ const AddTeamMemberModal = (props: Props) => {
const sendInvitations = () => {
if (invitees.length === 0) return
submitMutation()
const handleCompleted = (res) => {
const handleCompleted: CompletedHandler = (res) => {
setIsSubmitted(true)
onCompleted()
if (res) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/AndroidEditorFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const AndroidEditorFallback = (props: Props) => {
<TextAreaStyles
className={className}
aria-label={ariaLabel}
onHeightChange={(height) => setHeight(height)}
onHeightChange={(height: number) => setHeight(height)}
style={{height}}
inputRef={editorRef}
spellCheck
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/BillingLeaderActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const BillingLeaderActionMenu = (props: Props) => {
if (submitting) return
submitMutation()
const variables = {orgId, userId, role}
SetOrgUserRoleMutation(atmosphere, variables, {}, onError, onCompleted)
SetOrgUserRoleMutation(atmosphere, variables, {onError, onCompleted})
}

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/BottomNavIconLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Inner = styled('div')({
padding: '8px 8px 4px'
})

const StyledIcon = styled(Icon)<{iconColor?: string}>(({iconColor}) => ({
const StyledIcon = styled(Icon)<{iconColor?: keyof typeof paletteColors}>(({iconColor}) => ({
color: iconColor ? paletteColors[iconColor] : 'inherit',
height: 24
}))
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/Dashboard/DashModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface Props {

const DashModal = (props: Props) => {
const {children, onBackdropClick} = props
const onClick = (e) => {
const onClick = (e: React.MouseEvent) => {
if (onBackdropClick && e.target === e.currentTarget) {
onBackdropClick()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/DelayUnmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DelayUnmount extends Component<Props, State> {
return null
}

componentDidUpdate(_prevProps, prevState) {
componentDidUpdate(_prevProps: Props, prevState: State) {
if (
prevState.transitionState !== TransitionState.Exiting &&
this.state.transitionState === TransitionState.Exiting
Expand Down
4 changes: 2 additions & 2 deletions packages/client/components/DropdownMenuToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DropdownBlock = styled('div')({
interface InputStyleProps {
disabled: boolean
flat: boolean | undefined
size?: string
size?: 'small' | 'medium' | 'large'
}

const InputBlock = styled('div')<InputStyleProps>(
Expand Down Expand Up @@ -56,7 +56,7 @@ interface Props {
onMouseEnter?: () => void
// style hacks until a better pattern
flat?: boolean
size?: string
size?: 'small' | 'medium' | 'large'
}

const DropdownMenuToggle = forwardRef((props: Props, ref: Ref<HTMLDivElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/DueDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const DueDatePicker = (props: Props) => {
if (disabled || submitting) return
submitMutation()
const dueDate = selected ? null : day
UpdateTaskDueDateMutation(atmosphere, {taskId, dueDate}, onCompleted, onError)
UpdateTaskDueDateMutation(atmosphere, {taskId, dueDate}, {onCompleted, onError})
menuProps.closePortal()
;(document as any).activeElement?.blur()
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/components/DueDateToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface Props {
isArchived?: boolean
}

const formatDueDate = (dueDate) => {
const formatDueDate = (dueDate: string) => {
const date = new Date(dueDate)
const month = date.getMonth()
const day = date.getDate()
Expand All @@ -111,7 +111,7 @@ const formatDueDate = (dueDate) => {
}

const action = 'tap to change'
const getDateInfo = (dueDate) => {
const getDateInfo = (dueDate: string | null) => {
if (!dueDate) return {title: 'Add a Due Date'}
const date = new Date(dueDate)
const timeDiff = date.getTime() - Date.now()
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/EditableOrgName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const EditableOrgText = styled(EditableText)({

const EditableOrgName = (props: Props) => {
const atmosphere = useAtmosphere()
const handleSubmit = (rawName) => {
const handleSubmit = (rawName: string) => {
const {onError, onCompleted, setDirty, submitMutation, submitting, organization} = props
if (submitting) return
setDirty()
Expand Down
8 changes: 4 additions & 4 deletions packages/client/components/EditorInputWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const EditorInputWrapper = (props: Props) => {
setEditorState(editorState)
}

const onReturn = (e) => {
const onReturn = (e: React.KeyboardEvent) => {
if (handleReturn) {
return handleReturn(e, editorState)
}
Expand All @@ -92,7 +92,7 @@ const EditorInputWrapper = (props: Props) => {
return 'not-handled'
}

const onKeyBindingFn = (e) => {
const onKeyBindingFn = (e: React.KeyboardEvent) => {
if (keyBindingFn) {
const result = keyBindingFn(e)
if (result) {
Expand All @@ -109,10 +109,10 @@ const EditorInputWrapper = (props: Props) => {
return 'not-handled'
}

const onPastedText = (text): DraftHandleValue => {
const onPastedText = (text: string): DraftHandleValue => {
if (text) {
for (let i = 0; i < textTags.length; i++) {
const tag = textTags[i]
const tag = textTags[i]!
if (text.indexOf(tag) !== -1) {
const selection = editorState.getSelection()
entityPasteStartRef.current = {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/components/EstimatePhaseArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const SwipableEstimateItem = styled('div')<{isDesktop: boolean}>(({isDesktop}) =
paddingBottom: isDesktop ? 8 * 19 : 8 * 12
}))

const innerStyle = (isDesktop: boolean, hasSingleDimension: boolean) => {
const innerStyle = (isDesktop: boolean, hasSingleDimension: boolean): React.CSSProperties => {
return {
height: '100%',
margin: isDesktop ? '0 auto' : null,
maxWidth: hasSingleDimension ? (isDesktop ? 1536 : null) : isDesktop ? 1600 : null,
margin: isDesktop ? '0 auto' : undefined,
maxWidth: hasSingleDimension ? (isDesktop ? 1536 : undefined) : isDesktop ? 1600 : undefined,
padding: hasSingleDimension
? isDesktop
? '12px 8px 0'
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/FieldLabel/FieldLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LabelHeading from '../LabelHeading/LabelHeading'
const FieldLabelStyles = styled(LabelHeading)<
Pick<Props, 'customStyles' | 'fieldSize' | 'indent' | 'inline'>
>(({customStyles, fieldSize, indent, inline}) => {
const size = fieldSize || ui.buttonSizeOptions[1]
const size = (fieldSize || ui.buttonSizeOptions[1]) as 'small' | 'medium' | 'large'
const paddingLeft = fieldSize && indent ? ui.controlBlockPaddingHorizontal[size] : 0
const inlineSizeStyles = ui.fieldSizeStyles[size]
const inlineStyles = {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/components/ForgotPasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const linkStyle = {
textDecoration: 'underline'
}

const validateEmail = (email) => {
const validateEmail = (email: string) => {
return new Legitity(email)
.trim()
.required('Please enter an email address')
Expand Down Expand Up @@ -104,7 +104,7 @@ const ForgotPasswordPage = (props: Props) => {
}
}

const onSubmit = async (e) => {
const onSubmit = async (e: React.FormEvent) => {
e.preventDefault()
if (submitting) return
setDirtyField()
Expand Down Expand Up @@ -136,7 +136,7 @@ const ForgotPasswordPage = (props: Props) => {
[AuthenticationError.EXCEEDED_RESET_THRESHOLD]:
'Too many reset password attempts. Please try again later.'
}
const prettyError = error ? errorMessage[error.message] : undefined
const prettyError = error ? errorMessage[error.message as keyof typeof errorMessage] : undefined
return (
<AuthenticationDialog>
<DialogTitle>{'Forgot your password?'}</DialogTitle>
Expand Down
3 changes: 2 additions & 1 deletion packages/client/components/GitHubFieldDimensionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const GitHubFieldDimensionDropdown = (props: Props) => {
}

const label =
labelLookup[serviceFieldName] || interpolateGitHubLabelTemplate(serviceFieldName, finalScore)
labelLookup[serviceFieldName as keyof typeof labelLookup] ||
interpolateGitHubLabelTemplate(serviceFieldName, finalScore)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const GitLabFieldDimensionDropdown = (props: Props) => {
clearError()
}

const label = labelLookup[serviceFieldName]
const label = labelLookup[serviceFieldName as keyof typeof labelLookup]

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion packages/client/components/JiraFieldDimensionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const JiraFieldDimensionDropdown = (props: Props) => {
? serviceFieldName
: SprintPokerDefaults.SERVICE_FIELD_COMMENT

const label = labelLookup[lookupServiceFieldName] ?? lookupServiceFieldName
const label =
labelLookup[lookupServiceFieldName as keyof typeof labelLookup] ?? lookupServiceFieldName
return (
<Wrapper isFacilitator={isFacilitator} onClick={onClick} ref={originRef}>
<CurrentValue>{label}</CurrentValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const StyledIcon = styled(Icon)<{isFacilitator: boolean}>(({isFacilitator}) => (
const labelLookup = {
[SprintPokerDefaults.SERVICE_FIELD_COMMENT]: SprintPokerDefaults.SERVICE_FIELD_COMMENT_LABEL,
[SprintPokerDefaults.SERVICE_FIELD_NULL]: SprintPokerDefaults.SERVICE_FIELD_NULL_LABEL
}
} as const

const JiraServerFieldDimensionDropdown = (props: Props) => {
const {clearError, stageRef, isFacilitator, submitScore} = props
Expand Down Expand Up @@ -91,7 +91,8 @@ const JiraServerFieldDimensionDropdown = (props: Props) => {
? serviceFieldName
: SprintPokerDefaults.SERVICE_FIELD_COMMENT

const label = labelLookup[lookupServiceFieldName] ?? lookupServiceFieldName
const label =
labelLookup[lookupServiceFieldName as keyof typeof labelLookup] ?? lookupServiceFieldName
return (
<Wrapper isFacilitator={isFacilitator} onClick={onClick} ref={originRef}>
<CurrentValue>{label}</CurrentValue>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/MasonryCSSGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MasonryCSSGrid extends Component<Props> {
window.addEventListener('resize', this.setSpans, {passive: true})
}

componentDidUpdate(prevProps) {
componentDidUpdate(prevProps: Props) {
if (this.props.items !== prevProps.items) {
// the setTimeout is required for the task list (issue #2432), but it shouldn't be.
setTimeout(() => this.setSpans())
Expand Down
14 changes: 11 additions & 3 deletions packages/client/components/MeetingHelp/DelayedCopy.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import styled from '@emotion/styled'
import React from 'react'
import React, {ReactNode} from 'react'
import Ellipsis from '../Ellipsis/Ellipsis'
import HelpMenuCopy from './HelpMenuCopy'

const StyledHelpMenuCopy = styled(HelpMenuCopy)<{margin: string}>(({margin}) => ({margin}))
const StyledHelpMenuCopy = styled(HelpMenuCopy)<{margin: string | undefined | number}>(
({margin}) => ({margin})
)

const DelayedCopyInner = styled('span')<{show: number; thresh: number}>(({show, thresh}) => ({
opacity: show >= thresh ? 1 : 0,
transform: show >= thresh ? 'translateY(0)' : 'translateY(10px)',
transition: `all 500ms`
}))

const DelayedCopy = (props) => {
interface Props {
children: ReactNode
show: number
thresh: number
margin?: string | number
}
const DelayedCopy = (props: Props) => {
const {children, show, thresh, margin} = props
const showEllipsis = show === thresh - 1
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const MeetingSidebarTeamMemberStageItems = (props: Props) => {
const {facilitatorStageId, facilitatorUserId, localPhase, localStage, phases} = meeting
const sidebarPhase = phases.find((phase) => phase.phaseType === phaseType)
const localStageId = (localStage && localStage.id) || ''
const gotoStage = (teamMemberId) => () => {
const gotoStage = (teamMemberId: string) => () => {
const teamMemberStage =
sidebarPhase && sidebarPhase.stages.find((stage) => stage.teamMemberId === teamMemberId)
const teamMemberStageId = (teamMemberStage && teamMemberStage.id) || ''
Expand All @@ -63,7 +63,7 @@ const MeetingSidebarTeamMemberStageItems = (props: Props) => {
isNavigableByFacilitator,
isNavigable
} = stage
if (!teamMember) {
if (!teamMember || !teamMemberId) {
return null
}
const {picture, preferredName} = teamMember
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const NewMeetingActionsCurrentMeetings = (props: Props) => {
}
)
const {activeMeetings} = team
useSnacksForNewMeetings(activeMeetings)
useSnacksForNewMeetings(activeMeetings as any)
const meetingCount = activeMeetings.length
const label = `${meetingCount} Active ${plural(meetingCount, 'Meeting')}`
return (
Expand Down
6 changes: 3 additions & 3 deletions packages/client/components/NewMeetingSidebarPhaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ const NewMeetingSidebarPhaseListItem = (props: Props) => {
phaseCount,
phaseType
} = props
const label = phaseLabelLookup[phaseType]
const icon = phaseIconLookup[phaseType]
const Image = phaseImageLookup[phaseType]
const label = phaseLabelLookup[phaseType] as string | undefined
const icon = phaseIconLookup[phaseType] as string | undefined
const Image = phaseImageLookup[phaseType as keyof typeof phaseImageLookup]
const showPhaseCount = Boolean(phaseCount || phaseCount === 0)
return (
<NavListItemLink
Expand Down
4 changes: 2 additions & 2 deletions packages/client/components/ParabolScopingSearchResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ParabolScopingSearchResultItem = (props: Props) => {
if (!editorEl || editorEl.type !== 'textarea') return
const {value} = editorEl
if (!value && !isFocused) {
DeleteTaskMutation(atmosphere, serviceTaskId, teamId)
DeleteTaskMutation(atmosphere, {taskId: serviceTaskId})
} else {
const initialContentState = editorState.getCurrentContent()
const initialText = initialContentState.getPlainText()
Expand All @@ -107,7 +107,7 @@ const ParabolScopingSearchResultItem = (props: Props) => {
const nextContentState = editorState.getCurrentContent()
const hasText = nextContentState.hasText()
if (!hasText && !isFocused) {
DeleteTaskMutation(atmosphere, serviceTaskId, teamId)
DeleteTaskMutation(atmosphere, {taskId: serviceTaskId})
} else {
const nextContent = JSON.stringify(convertToRaw(nextContentState))
if (nextContent === content) return
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/PokerActiveVoting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const RevealLabel = styled('div')<{color: string}>(({color}) => ({
paddingLeft: 8
}))

const RevealButton = styled(RaisedButton)<{color}>(({color}) => ({
const RevealButton = styled(RaisedButton)<{color: string}>(({color}) => ({
backgroundColor: '#fff',
color,
fontWeight: 600,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/components/PokerDimensionFinalScorePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ const PokerDimensionFinalScorePicker = (props: Props) => {
JiraServerIssue: 'Jira Server',
_xGitLabIssue: 'GitLab',
AzureDevOpsWorkItem: 'Azure DevOps'
}
const title = titleByType[integrationType]
} as const
const title = titleByType[integrationType as keyof typeof titleByType]
const isDesktop = useBreakpoint(Breakpoint.SIDEBAR_LEFT)
const focusInput = () => inputRef.current!.focus()
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/client/components/PokerDiscussVoting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const PokerDiscussVoting = (props: Props) => {
const isLocallyValidatedRef = useRef(true)
const [cardScore, setCardScore] = useState(finalScore)

const isStale = (score) => {
const isStale = (score: string) => {
return score !== finalScore || lastSubmittedFieldRef.current !== serviceFieldName
}

Expand Down

0 comments on commit c5b7306

Please sign in to comment.