diff --git a/src/components/AccountDetails/index.tsx b/src/components/AccountDetails/index.tsx index e2703867de..bac5f700e6 100644 --- a/src/components/AccountDetails/index.tsx +++ b/src/components/AccountDetails/index.tsx @@ -200,7 +200,7 @@ const MainWalletAction = styled(WalletAction)` color: ${({ theme }) => theme.primary1}; ` -function renderTransactions(transactions) { +function renderTransactions(transactions: string[]) { return ( {transactions.map((hash, i) => { @@ -212,8 +212,8 @@ function renderTransactions(transactions) { interface AccountDetailsProps { toggleWalletModal: () => void - pendingTransactions: any[] - confirmedTransactions: any[] + pendingTransactions: string[] + confirmedTransactions: string[] ENSName?: string openOptions: () => void } diff --git a/src/components/NumericalInput/index.tsx b/src/components/NumericalInput/index.tsx index b361cbf080..3fcb1a1778 100644 --- a/src/components/NumericalInput/index.tsx +++ b/src/components/NumericalInput/index.tsx @@ -46,7 +46,7 @@ export const Input = React.memo(function InnerInput({ ...rest }: { value: string | number - onUserInput: (string) => void + onUserInput: (input: string) => void error?: boolean fontSize?: string align?: 'right' | 'left' diff --git a/src/components/Popups/ListUpdatePopup.tsx b/src/components/Popups/ListUpdatePopup.tsx index 09f484570e..11734250c4 100644 --- a/src/components/Popups/ListUpdatePopup.tsx +++ b/src/components/Popups/ListUpdatePopup.tsx @@ -44,7 +44,8 @@ export default function ListUpdatePopup({ return diffTokenLists(oldList.tokens, newList.tokens) }, [newList.tokens, oldList.tokens]) const numTokensChanged = useMemo( - () => Object.keys(tokensChanged).reduce((memo, chainId) => memo + Object.keys(tokensChanged[chainId]).length, 0), + () => + Object.keys(tokensChanged).reduce((memo, chainId: any) => memo + Object.keys(tokensChanged[chainId]).length, 0), [tokensChanged] ) diff --git a/src/components/TransactionSettings/index.tsx b/src/components/TransactionSettings/index.tsx index ec87509bb7..1e56cda0a6 100644 --- a/src/components/TransactionSettings/index.tsx +++ b/src/components/TransactionSettings/index.tsx @@ -118,12 +118,12 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se deadlineError = DeadlineError.InvalidInput } - function parseCustomSlippage(event) { - setSlippageInput(event.target.value) + function parseCustomSlippage(value: string) { + setSlippageInput(value) let valueAsIntFromRoundedFloat: number try { - valueAsIntFromRoundedFloat = Number.parseInt((Number.parseFloat(event.target.value) * 100).toString()) + valueAsIntFromRoundedFloat = Number.parseInt((Number.parseFloat(value) * 100).toString()) } catch {} if ( @@ -135,12 +135,12 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se } } - function parseCustomDeadline(event) { - setDeadlineInput(event.target.value) + function parseCustomDeadline(value: string) { + setDeadlineInput(value) let valueAsInt: number try { - valueAsInt = Number.parseInt(event.target.value) * 60 + valueAsInt = Number.parseInt(value) * 60 } catch {} if (typeof valueAsInt === 'number' && !Number.isNaN(valueAsInt) && valueAsInt > 0) { @@ -200,9 +200,9 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se placeholder={(rawSlippage / 100).toFixed(2)} value={slippageInput} onBlur={() => { - parseCustomSlippage({ target: { value: (rawSlippage / 100).toFixed(2) } }) + parseCustomSlippage((rawSlippage / 100).toFixed(2)) }} - onChange={parseCustomSlippage} + onChange={e => parseCustomSlippage(e.target.value)} color={!slippageInputIsValid ? 'red' : ''} /> % @@ -238,11 +238,11 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se { - parseCustomDeadline({ target: { value: (deadline / 60).toString() } }) + parseCustomDeadline((deadline / 60).toString()) }} placeholder={(deadline / 60).toString()} value={deadlineInput} - onChange={parseCustomDeadline} + onChange={e => parseCustomDeadline(e.target.value)} /> diff --git a/src/components/WalletModal/index.tsx b/src/components/WalletModal/index.tsx index b6b2356bba..29831e9445 100644 --- a/src/components/WalletModal/index.tsx +++ b/src/components/WalletModal/index.tsx @@ -17,6 +17,7 @@ import { ReactComponent as Close } from '../../assets/images/x.svg' import { injected, fortmatic, portis } from '../../connectors' import { OVERLAY_READY } from '../../connectors/Fortmatic' import { WalletConnectConnector } from '@web3-react/walletconnect-connector' +import { AbstractConnector } from '@web3-react/abstract-connector' const CloseIcon = styled.div` position: absolute; @@ -128,7 +129,7 @@ export default function WalletModal({ const [walletView, setWalletView] = useState(WALLET_VIEWS.ACCOUNT) - const [pendingWallet, setPendingWallet] = useState() + const [pendingWallet, setPendingWallet] = useState() const [pendingError, setPendingError] = useState() @@ -161,7 +162,7 @@ export default function WalletModal({ } }, [setWalletView, active, error, connector, walletModalOpen, activePrevious, connectorPrevious]) - const tryActivation = async connector => { + const tryActivation = async (connector: AbstractConnector | undefined) => { let name = '' Object.keys(SUPPORTED_WALLETS).map(key => { if (connector === SUPPORTED_WALLETS[key].connector) { diff --git a/src/components/Web3ReactManager/index.tsx b/src/components/Web3ReactManager/index.tsx index 1aa7843db9..d309bb39ff 100644 --- a/src/components/Web3ReactManager/index.tsx +++ b/src/components/Web3ReactManager/index.tsx @@ -19,7 +19,7 @@ const Message = styled.h2` color: ${({ theme }) => theme.secondary1}; ` -export default function Web3ReactManager({ children }) { +export default function Web3ReactManager({ children }: { children: JSX.Element }): JSX.Element { const { t } = useTranslation() const { active } = useWeb3React() const { active: networkActive, error: networkError, activate: activateNetwork } = useWeb3React(NetworkContextName) diff --git a/src/components/analytics/GoogleAnalyticsReporter.tsx b/src/components/analytics/GoogleAnalyticsReporter.tsx index 78756961dd..9e5761f17e 100644 --- a/src/components/analytics/GoogleAnalyticsReporter.tsx +++ b/src/components/analytics/GoogleAnalyticsReporter.tsx @@ -3,7 +3,7 @@ import ReactGA from 'react-ga' import { RouteComponentProps } from 'react-router-dom' // fires a GA pageview every time the route changes -export default function GoogleAnalyticsReporter({ location: { pathname, search } }: RouteComponentProps) { +export default function GoogleAnalyticsReporter({ location: { pathname, search } }: RouteComponentProps): null { useEffect(() => { ReactGA.pageview(`${pathname}${search}`) }, [pathname, search]) diff --git a/src/connectors/Fortmatic.ts b/src/connectors/Fortmatic.ts index ed577857bb..8d2b9c140c 100644 --- a/src/connectors/Fortmatic.ts +++ b/src/connectors/Fortmatic.ts @@ -16,6 +16,7 @@ export class FortmaticConnector extends FortmaticConnectorCore { async activate() { if (!this.fortmatic) { const { default: Fortmatic } = await import('fortmatic') + const { apiKey, chainId } = this as any if (chainId in CHAIN_ID_NETWORK_ARGUMENT) { this.fortmatic = new Fortmatic(apiKey, CHAIN_ID_NETWORK_ARGUMENT[chainId as FormaticSupportedChains]) diff --git a/src/ethereum.d.ts b/src/ethereum.d.ts deleted file mode 100644 index 8951fd08b2..0000000000 --- a/src/ethereum.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface Window { - ethereum?: { - isMetaMask?: true - on?: (...args: any[]) => void - removeListener?: (...args: any[]) => void - } - web3?: {} -} diff --git a/src/hooks/ethereum.d.ts b/src/hooks/ethereum.d.ts deleted file mode 100644 index 8951fd08b2..0000000000 --- a/src/hooks/ethereum.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface Window { - ethereum?: { - isMetaMask?: true - on?: (...args: any[]) => void - removeListener?: (...args: any[]) => void - } - web3?: {} -} diff --git a/src/pages/MigrateV1/RemoveV1Exchange.tsx b/src/pages/MigrateV1/RemoveV1Exchange.tsx index 2f0603bc57..4444b6fcab 100644 --- a/src/pages/MigrateV1/RemoveV1Exchange.tsx +++ b/src/pages/MigrateV1/RemoveV1Exchange.tsx @@ -83,7 +83,7 @@ function V1PairRemoval({ }) setPendingRemovalHash(response.hash) }) - .catch(error => { + .catch((error: Error) => { console.error(error) setConfirmingRemoval(false) }) diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 6431bc5fc6..e03b385aba 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -1 +1,26 @@ /// + +declare module 'jazzicon' { + export default function(diameter: number, seed: number): HTMLElement +} + +declare module 'fortmatic' + +interface Window { + ethereum?: { + isMetaMask?: true + on?: (...args: any[]) => void + removeListener?: (...args: any[]) => void + } + web3?: {} +} + +declare module 'content-hash' { + declare function decode(x: string): string + declare function getCodec(x: string): string +} + +declare module 'multihashes' { + declare function decode(buff: Uint8Array): { code: number; name: string; length: number; digest: Uint8Array } + declare function toB58String(hash: Uint8Array): string +} diff --git a/src/state/application/updater.ts b/src/state/application/updater.ts index 9dc783f7c5..79765d67fd 100644 --- a/src/state/application/updater.ts +++ b/src/state/application/updater.ts @@ -5,7 +5,7 @@ import useIsWindowVisible from '../../hooks/useIsWindowVisible' import { updateBlockNumber } from './actions' import { useDispatch } from 'react-redux' -export default function Updater() { +export default function Updater(): null { const { library, chainId } = useActiveWeb3React() const dispatch = useDispatch() diff --git a/src/state/multicall/updater.tsx b/src/state/multicall/updater.tsx index a360f7652b..67d935eb09 100644 --- a/src/state/multicall/updater.tsx +++ b/src/state/multicall/updater.tsx @@ -110,7 +110,7 @@ export function outdatedListeningKeys( }) } -export default function Updater() { +export default function Updater(): null { const dispatch = useDispatch() const state = useSelector(state => state.multicall) // wait for listeners to settle before triggering updates diff --git a/src/state/transactions/updater.tsx b/src/state/transactions/updater.tsx index 8adb6a7e29..1ea7de7f21 100644 --- a/src/state/transactions/updater.tsx +++ b/src/state/transactions/updater.tsx @@ -26,7 +26,7 @@ export function shouldCheck( } } -export default function Updater() { +export default function Updater(): null { const { chainId, library } = useActiveWeb3React() const lastBlockNumber = useBlockNumber() diff --git a/src/state/user/updater.tsx b/src/state/user/updater.tsx index 226d5a7951..03e76f59a6 100644 --- a/src/state/user/updater.tsx +++ b/src/state/user/updater.tsx @@ -3,7 +3,7 @@ import { useDispatch } from 'react-redux' import { AppDispatch } from '../index' import { updateMatchesDarkMode } from './actions' -export default function Updater() { +export default function Updater(): null { const dispatch = useDispatch() // keep dark mode in sync with the system diff --git a/src/theme/DarkModeQueryParamReader.tsx b/src/theme/DarkModeQueryParamReader.tsx index 44f3d4b2c8..9571464dd0 100644 --- a/src/theme/DarkModeQueryParamReader.tsx +++ b/src/theme/DarkModeQueryParamReader.tsx @@ -5,7 +5,7 @@ import { parse } from 'qs' import { AppDispatch } from '../state' import { updateUserDarkMode } from '../state/user/actions' -export default function DarkModeQueryParamReader({ location: { search } }: RouteComponentProps) { +export default function DarkModeQueryParamReader({ location: { search } }: RouteComponentProps): null { const dispatch = useDispatch() useEffect(() => { diff --git a/src/utils/content-hash.d.ts b/src/utils/content-hash.d.ts deleted file mode 100644 index 5fedf8a21d..0000000000 --- a/src/utils/content-hash.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'content-hash' { - declare function decode(x: string): string - declare function getCodec(x: string): string -} diff --git a/src/utils/multihashes.d.ts b/src/utils/multihashes.d.ts deleted file mode 100644 index 262ed17e2f..0000000000 --- a/src/utils/multihashes.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'multihashes' { - declare function decode(buff: Uint8Array): { code: number; name: string; length: number; digest: Uint8Array } - declare function toB58String(hash: Uint8Array): string -} diff --git a/tsconfig.json b/tsconfig.json index 1ae60a5224..195ca7bade 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "module": "esnext", "noUnusedLocals": true, "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, "noImplicitThis": true, "noImplicitReturns": true, "moduleResolution": "node", diff --git a/tsconfig.strict.json b/tsconfig.strict.json index ef486d1531..6f324d301c 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "strict": true, - "noImplicitAny": true, "alwaysStrict": true, "strictNullChecks": true }