Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Moving helper functions from dex-react #69

Merged
merged 2 commits into from Jan 24, 2020

Conversation

alfetopito
Copy link
Contributor

Part of gnosis/gp-v1-ui#436

Moving helper functions from dex-react:

  • assert
  • isNeverExpiresOrder

import { AssertionError } from 'assert'

export function assert<T>(val: T, message: string): asserts val is NonNullable<T> {
if (!val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly a NonNullable assertion, though it may be ok for our purposes
!val will break on every falsy value (0, '')

https://www.typescriptlang.org/docs/handbook/utility-types.html#nonnullablet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion on how to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do sth like val ?? somethingElse where 0 and '' will be accepted but nothing else

nullish coalescense or sth similar in TS 3.7+

@alfetopito alfetopito merged commit 5d90fa6 into master Jan 24, 2020
@alfetopito alfetopito deleted the 436/refactoring-dex-telegram branch January 27, 2020 16:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants