Skip to content

Commit

Permalink
Upgrade TS version (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcewen authored and celo-ci-bot-user committed Dec 12, 2019
1 parent 08d7b0d commit 87aa693
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ts-node": "^8.3.0",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.20.0",
"typescript": "^3.5.3",
"typescript": "^3.7.3",
"typescript-tslint-plugin": "^0.5.4"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/web3": "^1.0.18",
"jest-fetch-mock": "^2.1.2",
"tsc-watch": "^1.0.31",
"typescript": "^3.5.3"
"typescript": "^3.7.3"
},
"resolutions": {
"**/cross-fetch": "3.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cmds/deploy/upgrade/ethstats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const handler = async (argv: EthstatsArgv) => {
await createClusterIfNotExists()
await switchToClusterFromEnv()

if (argv.reset) {
if (argv.reset === true) {
await removeHelmRelease(argv.celoEnv)
await installHelmChart(argv.celoEnv)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cmds/deploy/upgrade/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const handler = async (argv: LeaderboardArgv) => {
await createClusterIfNotExists()
await switchToClusterFromEnv()

if (argv.reset) {
if (argv.reset === true) {
await removeHelmRelease(argv.celoEnv)
await installHelmChart(argv.celoEnv)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cmds/deploy/upgrade/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const handler = async (argv: TestnetArgv) => {

await upgradeStaticIPs(argv.celoEnv)

if (argv.reset) {
if (argv.reset === true) {
await resetAndUpgradeHelmChart(argv.celoEnv)
await uploadGenesisBlockToGoogleStorage(argv.celoEnv)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cmds/deploy/upgrade/vm-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const handler = async (argv: VmTestnetArgv) => {
await switchToClusterFromEnv()

let onDeployFailed = () => Promise.resolve()
if (argv.reset) {
if (argv.reset === true) {
onDeployFailed = () => untaintTestnet(argv.celoEnv)
await taintTestnet(argv.celoEnv)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@types/web3": "^1.0.18",
"globby": "^8",
"prettier": "1.13.5",
"typescript": "^3.5.3"
"typescript": "^3.7.3"
},
"files": [
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/notification-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/node-fetch": "^2.1.2",
"@types/utf8": "^2.1.6",
"@types/web3": "^1.0.18",
"typescript": "^3.5.3"
"typescript": "^3.7.3"
},
"engines": {
"node": "10"
Expand Down
49 changes: 34 additions & 15 deletions packages/react-components/analytics/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,45 @@ import CeloAnalyticsType from '@celo/react-components/analytics/CeloAnalytics'
import { DefaultEventNames } from '@celo/react-components/analytics/constants'
import ReactNativeLogger from '@celo/react-components/services/ReactNativeLogger'
import * as React from 'react'
// tslint:disable-next-line
import { Component, ComponentType, forwardRef, Ref } from 'react'

function getDisplayName<P extends {}>(WrappedComponent: React.ComponentType<P>) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
}

interface ForwardedRef {
forwardedRef?: React.Ref<React.ReactElement<any>>
}

export default function Initializer(CeloAnalytics: CeloAnalyticsType, Logger: ReactNativeLogger) {
// Wrapper type: https://medium.com/@jrwebdev/react-higher-order-component-patterns-in-typescript-42278f7590fb
// Wrapper type: https://gist.github.com/OliverJAsh/d2f462b03b3e6c24f5588ca7915d010e
// Component name: https://reactjs.org/docs/forwarding-refs.html

function componentWithAnalytics<P extends {}>(
WrappedComponent: React.ComponentType<P>
): React.ComponentClass<P> {
const displayName = getDisplayName(WrappedComponent)
function componentWithAnalytics<ComposedComponentProps extends {}>(
ComposedComponent: ComponentType<ComposedComponentProps>
) {
const displayName = getDisplayName(ComposedComponent)
// @ts-ignore
type ComposedComponentInstance = InstanceType<typeof ComposedComponent>
type WrapperComponentProps = ComposedComponentProps & {
wrapperComponentProp: number
}
type WrapperComponentPropsWithForwardedRef = WrapperComponentProps & {
forwardedRef: Ref<ComposedComponentInstance>
}

class ComponentWithAnalytics extends React.Component<P & ForwardedRef> {
class WrapperComponent extends Component<WrapperComponentPropsWithForwardedRef, {}> {
timestamp: number | undefined

render() {
return <WrappedComponent {...this.props} ref={this.props.forwardedRef} />
const { forwardedRef, wrapperComponentProp, ...composedComponentProps } = this.props

return (
<ComposedComponent
ref={forwardedRef}
// We need a cast because:
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/32355
// https://github.com/Microsoft/TypeScript/issues/28938#issuecomment-450636046
{...composedComponentProps as ComposedComponentProps}
/>
)
}

trackEvent(event: any, props: any, attachDeviceInfo = false) {
Expand Down Expand Up @@ -58,13 +74,16 @@ export default function Initializer(CeloAnalytics: CeloAnalyticsType, Logger: Re
}
}

function forwardRef(props: P, ref: any) {
return <ComponentWithAnalytics {...props} forwardedRef={ref} />
function forward(props: WrapperComponentProps, ref: Ref<ComposedComponentInstance>) {
return <WrapperComponent forwardedRef={ref} {...props} />
}

forwardRef.displayName = `WithAnalytics(${displayName})`
forward.displayName = `WithAnalytics(${displayName})`

return hoistNonReactStatics(React.forwardRef(forwardRef), WrappedComponent)
return hoistNonReactStatics(
forwardRef<ComposedComponentInstance, WrapperComponentProps>(forward),
ComposedComponent
)
}
return componentWithAnalytics
}
4 changes: 2 additions & 2 deletions packages/react-components/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
StyleSheet,
TextInput as RNTextInput,
TextInputFocusEventData,
TextInputProps,
TextInputProps as RNTextInputProps,
View,
} from 'react-native'

Expand All @@ -22,7 +22,7 @@ interface OwnProps {
forwardedRef?: React.RefObject<RNTextInput>
}

type Props = OwnProps & TextInputProps
type Props = OwnProps & RNTextInputProps

interface State {
isFocused: boolean
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32098,16 +32098,16 @@ typescript@^3.2.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3.tgz#f1657fc7daa27e1a8930758ace9ae8da31403221"
integrity sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==

typescript@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==

typescript@^3.6.4:
version "3.6.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4.tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d"
integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==

typescript@^3.7.3:
version "3.7.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.3.tgz#b36840668a16458a7025b9eabfad11b66ab85c69"
integrity sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==

typewise-core@^1.2, typewise-core@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/typewise-core/-/typewise-core-1.2.0.tgz#97eb91805c7f55d2f941748fa50d315d991ef195"
Expand Down

0 comments on commit 87aa693

Please sign in to comment.