aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-01-10 19:39:37 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-01-10 19:43:50 +0800
commite34b0af25133629ad4c177c4d7d5050bd6ac19b8 (patch)
tree936eae17521984e5ccc28057973461e707322326 /packages/website/ts/components
parentfa7237fde7acea32c5492f0dcdef4d55b3ade6e1 (diff)
downloaddexon-0x-contracts-e34b0af25133629ad4c177c4d7d5050bd6ac19b8.tar.gz
dexon-0x-contracts-e34b0af25133629ad4c177c4d7d5050bd6ac19b8.tar.zst
dexon-0x-contracts-e34b0af25133629ad4c177c4d7d5050bd6ac19b8.zip
Fix ts error in portal after enabling more strict checks
Diffstat (limited to 'packages/website/ts/components')
-rw-r--r--packages/website/ts/components/dialogs/ledger_config_dialog.tsx10
-rw-r--r--packages/website/ts/components/fill_warning_dialog.tsx2
-rw-r--r--packages/website/ts/components/inputs/allowance_toggle.tsx7
-rw-r--r--packages/website/ts/components/inputs/token_amount_input.tsx2
-rw-r--r--packages/website/ts/components/portal.tsx10
-rw-r--r--packages/website/ts/components/top_bar.tsx12
6 files changed, 23 insertions, 20 deletions
diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
index c8547694a..60db93c52 100644
--- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
+++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
@@ -134,7 +134,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
labelReady="Update"
labelLoading="Updating..."
labelComplete="Updated!"
- onClickAsyncFn={this._onFetchAddressesForDerivationPathAsync.bind(this, true)}
+ onClickAsyncFn={this._onFetchAddressesForDerivationPathAsync.bind(this)}
/>
</div>
</div>
@@ -191,13 +191,15 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
const isOpen = false;
this.props.toggleDialogFn(isOpen);
}
- private async _onFetchAddressesForDerivationPathAsync() {
+ private async _onFetchAddressesForDerivationPathAsync(): Promise<boolean> {
const currentlySetPath = this.props.blockchain.getLedgerDerivationPathIfExists();
+ let didSucceed;
if (currentlySetPath === this.state.derivationPath) {
- return;
+ didSucceed = true;
+ return didSucceed;
}
this.props.blockchain.updateLedgerDerivationPathIfExists(this.state.derivationPath);
- const didSucceed = await this._fetchAddressesAndBalancesAsync();
+ didSucceed = await this._fetchAddressesAndBalancesAsync();
if (!didSucceed) {
this.setState({
derivationErrMsg: 'Failed to connect to Ledger.',
diff --git a/packages/website/ts/components/fill_warning_dialog.tsx b/packages/website/ts/components/fill_warning_dialog.tsx
index 38c10870b..165d21b34 100644
--- a/packages/website/ts/components/fill_warning_dialog.tsx
+++ b/packages/website/ts/components/fill_warning_dialog.tsx
@@ -5,7 +5,7 @@ import { colors } from 'ts/utils/colors';
interface FillWarningDialogProps {
isOpen: boolean;
- onToggleDialog: () => void;
+ onToggleDialog: (didUserCancel: boolean) => void;
}
export function FillWarningDialog(props: FillWarningDialogProps) {
diff --git a/packages/website/ts/components/inputs/allowance_toggle.tsx b/packages/website/ts/components/inputs/allowance_toggle.tsx
index b29511390..1be441e17 100644
--- a/packages/website/ts/components/inputs/allowance_toggle.tsx
+++ b/packages/website/ts/components/inputs/allowance_toggle.tsx
@@ -47,7 +47,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
<Toggle
disabled={this.state.isSpinnerVisible}
toggled={this._isAllowanceSet()}
- onToggle={this._onToggleAllowanceAsync.bind(this, this.props.token)}
+ onToggle={this._onToggleAllowanceAsync.bind(this)}
/>
</div>
{this.state.isSpinnerVisible && (
@@ -58,10 +58,9 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
</div>
);
}
- private async _onToggleAllowanceAsync() {
+ private async _onToggleAllowanceAsync(): Promise<void> {
if (this.props.userAddress === '') {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
- return false;
}
this.setState({
@@ -80,7 +79,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
});
const errMsg = '' + err;
if (_.includes(errMsg, 'User denied transaction')) {
- return false;
+ return;
}
utils.consoleLog(`Unexpected error encountered: ${err}`);
utils.consoleLog(err.stack);
diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx
index f3f522ce3..63966d759 100644
--- a/packages/website/ts/components/inputs/token_amount_input.tsx
+++ b/packages/website/ts/components/inputs/token_amount_input.tsx
@@ -63,6 +63,8 @@ export class TokenAmountInput extends React.Component<TokenAmountInputProps, Tok
</Link>
</span>
);
+ } else {
+ return undefined;
}
}
}
diff --git a/packages/website/ts/components/portal.tsx b/packages/website/ts/components/portal.tsx
index 22cdcbf20..e2e28e8b6 100644
--- a/packages/website/ts/components/portal.tsx
+++ b/packages/website/ts/components/portal.tsx
@@ -322,10 +322,10 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> {
isWethNoticeDialogOpen: false,
});
}
- private _getSharedOrderIfExists(): Order {
+ private _getSharedOrderIfExists(): Order | undefined {
const queryString = window.location.search;
if (queryString.length === 0) {
- return;
+ return undefined;
}
const queryParams = queryString.substring(1).split('&');
const orderQueryParam = _.find(queryParams, queryParam => {
@@ -333,11 +333,11 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> {
return queryPair[0] === 'order';
});
if (_.isUndefined(orderQueryParam)) {
- return;
+ return undefined;
}
const orderPair = orderQueryParam.split('=');
if (orderPair.length !== 2) {
- return;
+ return undefined;
}
const validator = new SchemaValidator();
@@ -345,7 +345,7 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> {
const validationResult = validator.validate(order, orderSchema);
if (validationResult.errors.length > 0) {
utils.consoleLog(`Invalid shared order: ${validationResult.errors}`);
- return;
+ return undefined;
}
return order;
}
diff --git a/packages/website/ts/components/top_bar.tsx b/packages/website/ts/components/top_bar.tsx
index cd835930b..601471222 100644
--- a/packages/website/ts/components/top_bar.tsx
+++ b/packages/website/ts/components/top_bar.tsx
@@ -238,12 +238,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</Drawer>
);
}
- private _renderDocsMenu() {
+ private _renderDocsMenu(): React.ReactNode {
if (
(!this._isViewing0xjsDocs() && !this._isViewingSmartContractsDocs() && !this._isViewingConnectDocs()) ||
_.isUndefined(this.props.menu)
) {
- return;
+ return undefined;
}
const sectionTitle = `${this.props.docsInfo.displayName} Docs`;
@@ -264,9 +264,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</div>
);
}
- private _renderWiki() {
+ private _renderWiki(): React.ReactNode {
if (!this._isViewingWiki()) {
- return;
+ return undefined;
}
return (
@@ -283,9 +283,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</div>
);
}
- private _renderPortalMenu() {
+ private _renderPortalMenu(): React.ReactNode {
if (!this._isViewingPortal()) {
- return;
+ return undefined;
}
return (