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

Revert "Upgrade TS version" #2251

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.7.3",
"typescript": "^3.5.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 @@ -36,7 +36,7 @@
"@types/web3": "^1.0.18",
"jest-fetch-mock": "^2.1.2",
"tsc-watch": "^1.0.31",
"typescript": "^3.7.3"
"typescript": "^3.5.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 === true) {
if (argv.reset) {
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 === true) {
if (argv.reset) {
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 === true) {
if (argv.reset) {
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 === true) {
if (argv.reset) {
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.7.3"
"typescript": "^3.5.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.7.3"
"typescript": "^3.5.3"
},
"engines": {
"node": "10"
Expand Down
49 changes: 15 additions & 34 deletions packages/react-components/analytics/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,29 @@ 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://gist.github.com/OliverJAsh/d2f462b03b3e6c24f5588ca7915d010e
// Wrapper type: https://medium.com/@jrwebdev/react-higher-order-component-patterns-in-typescript-42278f7590fb
// Component name: https://reactjs.org/docs/forwarding-refs.html

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>
}
function componentWithAnalytics<P extends {}>(
WrappedComponent: React.ComponentType<P>
): React.ComponentClass<P> {
const displayName = getDisplayName(WrappedComponent)

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

render() {
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}
/>
)
return <WrappedComponent {...this.props} ref={this.props.forwardedRef} />
}

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

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

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

return hoistNonReactStatics(
forwardRef<ComposedComponentInstance, WrapperComponentProps>(forward),
ComposedComponent
)
return hoistNonReactStatics(React.forwardRef(forwardRef), WrappedComponent)
}
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 as RNTextInputProps,
TextInputProps,
View,
} from 'react-native'

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

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

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 @@ -32013,16 +32013,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