Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Типизация, выбор и нюансы использования решений #17

Open
rqrqrqrq opened this issue May 8, 2018 · 1 comment

Comments

@rqrqrqrq
Copy link
Contributor

rqrqrqrq commented May 8, 2018

No description provided.

@rqrqrqrq
Copy link
Contributor Author

rqrqrqrq commented May 8, 2018

Типизация констант для flow, возможный вариант решения

/* @flow */

// если не указан тип, то проверки не будут работать нормально через $Values
const SUCCESS: 'success' = 'success';
const FAIL: 'fail' = 'fail';
const WAITING: 'waiting' = 'waiting';

const statuses = {
  SUCCESS,
  FAIL,
  WAITING,
}

type Status = $Values<typeof statuses>;

const a = (x: Status) => 0;

a('success');

// $FlowExpectedError
a('yoba');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant