Skip to content

Commit

Permalink
fix: all type warnings on build (decentraland#350)
Browse files Browse the repository at this point in the history
* fix: all type warnings on build

* fix: package-lock

* chore: missing hook deps
  • Loading branch information
nicosantangelo authored Jul 1, 2021
1 parent bd84c09 commit 0bdb55a
Show file tree
Hide file tree
Showing 16 changed files with 47,102 additions and 10,971 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57,918 changes: 47,018 additions & 10,900 deletions webapp/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"react-lazy-images": "^1.1.0",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.1",
"react-scripts": "^4.0.3",
"redux": "^4.0.4",
"redux-logger": "^3.0.6",
"redux-saga": "^1.1.3",
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/components/NFTBrowse/NFTBrowse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ const NFTBrowse = (props: Props) => {
// Kick things off
useEffect(() => {
onSetView(view)
// eslint-disable-next-line
}, [view])
}, [onSetView, view])

useEffect(() => {
if (viewInState === view) {
Expand All @@ -42,7 +41,7 @@ const NFTBrowse = (props: Props) => {
onlyOnSale
})
}
}, [viewInState, onFetchNFTsFromRoute])
}, [view, vendor, address, onlyOnSale, viewInState, onFetchNFTsFromRoute])

// handlers
const handleSetFullscreen = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,59 @@ import {
getLoading
} from 'decentraland-dapps/dist/modules/authorization/selectors'
import {
GrantTokenRequestAction,
GRANT_TOKEN_REQUEST,
RevokeTokenRequestAction,
REVOKE_TOKEN_REQUEST,
grantTokenRequest,
revokeTokenRequest
} from 'decentraland-dapps/dist/modules/authorization/actions'
import { areEqual } from 'decentraland-dapps/dist/modules/authorization/utils'
import { hasTransactionPending } from '../../../modules/transaction/utils'
import { RootState } from '../../../modules/reducer'
import { getPendingAuthorizationTransactions } from '../../../modules/transaction/selectors'
import {
OwnProps,
MapStateProps,
MapDispatchProps,
MapDispatch
} from './Authorization.types'
import Authorization from './Authorization'

const mapState = (state: RootState): MapStateProps => ({
authorizations: getAuthorizations(state),
pendingTransactions: getPendingAuthorizationTransactions(state),
loading: getLoading(state)
})
const mapState = (
state: RootState,
{ authorization }: OwnProps
): MapStateProps => {
const { contractAddress, authorizedAddress } = authorization

const authorizations = getAuthorizations(state)
const pendingTransactions = getPendingAuthorizationTransactions(state)

const isLoading = getLoading(state).some(action => {
if (
action.type === GRANT_TOKEN_REQUEST ||
action.type === REVOKE_TOKEN_REQUEST
) {
const { payload } = action as
| GrantTokenRequestAction
| RevokeTokenRequestAction
return areEqual(authorization, payload.authorization)
}
return false
})

return {
authorizations,
pendingTransactions,
isLoading:
isLoading ||
hasTransactionPending(
pendingTransactions,
authorizedAddress,
contractAddress
)
}
}

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onGrant: authorization => dispatch(grantTokenRequest(authorization)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,16 @@ import React, { useCallback } from 'react'
import { Link } from 'react-router-dom'
import { t, T } from 'decentraland-dapps/dist/modules/translation/utils'
import { TransactionLink } from 'decentraland-dapps/dist/containers'
import {
GrantTokenRequestAction,
GRANT_TOKEN_REQUEST,
RevokeTokenRequestAction,
REVOKE_TOKEN_REQUEST
} from 'decentraland-dapps/dist/modules/authorization/actions'
import { getChainConfiguration } from 'decentraland-dapps/dist/lib/chainConfiguration'
import { areEqual } from 'decentraland-dapps/dist/modules/authorization/utils'
import { Form, Radio, Loader, Popup, RadioProps } from 'decentraland-ui'
import { locations } from '../../../modules/routing/locations'
import { hasTransactionPending } from '../../../modules/transaction/utils'
import { getContract } from '../../../modules/contract/utils'
import { isAuthorized } from './utils'
import { Props } from './Authorization.types'
import './Authorization.css'

const Authorization = (props: Props) => {
const {
authorization,
authorizations,
loading,
pendingTransactions,
onGrant,
onRevoke
} = props
const { authorization, authorizations, isLoading, onGrant, onRevoke } = props

const handleOnChange = useCallback(
(isChecked: boolean) =>
Expand All @@ -35,23 +20,6 @@ const Authorization = (props: Props) => {
)

const { contractAddress, authorizedAddress } = authorization
const isLoading =
loading.some(action => {
if (
action.type === GRANT_TOKEN_REQUEST ||
action.type === REVOKE_TOKEN_REQUEST
) {
const { payload } = action as
| GrantTokenRequestAction
| RevokeTokenRequestAction
return areEqual(authorization, payload.authorization)
}
}) ||
hasTransactionPending(
pendingTransactions,
authorizedAddress,
contractAddress
)

const contract = getContract({ address: authorizedAddress })
const token = getContract({ address: contractAddress })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import {
RevokeTokenRequestAction
} from 'decentraland-dapps/dist/modules/authorization/actions'
import { Authorization } from 'decentraland-dapps/dist/modules/authorization/types'
import { LoadingState } from 'decentraland-dapps/dist/modules/loading/reducer'
import { Transaction } from 'decentraland-dapps/dist/modules/transaction/types'
import { Dispatch } from 'redux'

export type Props = {
authorization: Authorization
authorizations: Authorization[]
pendingTransactions: Transaction[]
loading: LoadingState
isLoading: boolean
onGrant: typeof grantTokenRequest
onRevoke: typeof revokeTokenRequest
}

export type OwnProps = Pick<Props, 'authorization'>
export type MapStateProps = Pick<
Props,
'authorizations' | 'pendingTransactions' | 'loading'
'authorizations' | 'pendingTransactions' | 'isLoading'
>
export type MapDispatchProps = Pick<Props, 'onGrant' | 'onRevoke'>
export type MapDispatch = Dispatch<
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/lib/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useTimer = (delay: number): [boolean, () => void] => {
}
setRunningStatus(true)
timeoutRef.current = setTimeout(() => setRunningStatus(false), delay)
}, [timeoutRef.current])
}, [delay, timeoutRef])

return [isRunning, startTimer]
}
10 changes: 5 additions & 5 deletions webapp/src/modules/nft/wearable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ export const RARITY_COLOR = {
[WearableRarity.COMMON]: '#ABC1C1'
}

export enum BodyShape {
MALE = 'BaseMale',
FEMALE = 'BaseFemale'
}

export type Wearable = {
description: string
category: WearableCategory
rarity: WearableRarity
bodyShapes: BodyShape[]
}

export enum BodyShape {
MALE = 'BaseMale',
FEMALE = 'BaseFemale'
}

export enum WearableGender {
MALE = 'male',
FEMALE = 'female'
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/modules/routing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { VendorName } from '../vendor/types'
import { Section } from '../vendor/routing/types'
import { View } from '../ui/types'

export { Section }
export { Section } from '../vendor/routing/types'

export enum SortBy {
NAME = 'name',
Expand Down
1 change: 1 addition & 0 deletions webapp/src/modules/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const View = {
ATLAS: 'atlas'
} as const

// eslint-disable-next-line @typescript-eslint/no-redeclare -- Intentionally naming the variable the same as the type
export type View = typeof View[keyof typeof View]
4 changes: 2 additions & 2 deletions webapp/src/modules/vendor/makers_place/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type MakersPlaceAsset = {
sale_contract_address?: string
}

export type FetchOneResponse = FetchOneSuccessResponse | FetchOneFailureResponse
export type FetchOneSuccessResponse = {
item: MakersPlaceAsset
status: 'success'
Expand All @@ -43,8 +42,8 @@ export type FetchOneFailureResponse = {
status: 'failure'
errors: Record<string, string[]>
}
export type FetchOneResponse = FetchOneSuccessResponse | FetchOneFailureResponse

export type FetchResponse = FetchSuccessResponse | FetchFailureResponse
export type FetchSuccessResponse = {
items: MakersPlaceAsset[]
page_num: number
Expand All @@ -57,5 +56,6 @@ export type FetchFailureResponse = {
status: 'failure'
errors: string[]
}
export type FetchResponse = FetchSuccessResponse | FetchFailureResponse

export type Response = FetchOneResponse | FetchResponse
1 change: 1 addition & 0 deletions webapp/src/modules/vendor/routing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type Section =
| makersPlace.Section
| knownOrigin.Section

// eslint-disable-next-line @typescript-eslint/no-redeclare -- Intentionally naming the variable the same as the type
export const Section = {
[VendorName.DECENTRALAND]: { ...decentraland.Section },
[VendorName.SUPER_RARE]: { ...superRare.Section },
Expand Down
32 changes: 16 additions & 16 deletions webapp/src/modules/vendor/super_rare/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export type SuperRareOrder = {
asset: SuperRareAsset
taker: SuperRareOwner | null
maker: SuperRareOwner | null
marketContractAddress: string
timestamp: string
amount: number
amountWithFee: number
export type SuperRareOwner = {
address: string
user: {
username: string
ethereumAddress: string
superRareUrl: string
avatar: string | null
}
}

export type SuperRareAsset = {
Expand All @@ -25,14 +25,14 @@ export type SuperRareAsset = {
tags: string[]
}

export type SuperRareOwner = {
address: string
user: {
username: string
ethereumAddress: string
superRareUrl: string
avatar: string | null
}
export type SuperRareOrder = {
asset: SuperRareAsset
taker: SuperRareOwner | null
maker: SuperRareOwner | null
marketContractAddress: string
timestamp: string
amount: number
amountWithFee: number
}

export type SuperRareFetchNFTOptions = Partial<{
Expand Down
1 change: 1 addition & 0 deletions webapp/src/modules/vendor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ContractName = {
...knownOrigin.ContractName
}

// eslint-disable-next-line @typescript-eslint/no-redeclare -- Intentionally naming the variable the same as the type
export type ContractName = typeof ContractName

export const getContractNames = () =>
Expand Down
1 change: 1 addition & 0 deletions webapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"noUnusedParameters": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noFallthroughCasesInSwitch": true,
"noEmit": true,
"jsx": "react",
"types": ["jest"]
Expand Down

0 comments on commit 0bdb55a

Please sign in to comment.