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

Export Flow types as part of the module #243

Open
2 of 10 tasks
Beanow opened this issue May 29, 2020 · 0 comments
Open
2 of 10 tasks

Export Flow types as part of the module #243

Beanow opened this issue May 29, 2020 · 0 comments

Comments

@Beanow
Copy link

Beanow commented May 29, 2020

This is a:

  • Bug Report
  • Feature Request
  • Question
  • Other

Which concerns:

  • flow-runtime
  • babel-plugin-flow-runtime
  • flow-runtime-validators
  • flow-runtime-mobx
  • flow-config-parser
  • The documentation website

What is the current behaviour?

Currently, the flow-runtime library does not export it's Flow types as part of the module.


What is the expected behaviour?

Incorrect usage of flow-runtime without babel should trigger Flow errors.

// @flow

import t, {type Type} from "flow-runtime";

opaque type PositiveNumber: number = number;

// Example refined type.
const PositiveNumberType: Type<PositiveNumber> = t.refinement(
  t.number(),
  (x: number) => {
    if (x < 0) return "must be positive";
  }
);

// Signature is accepts(input: any): boolean
// But we're passing more arguments and expecting wrong return type.
const _: string = PositiveNumberType.accepts(1, 2, 3, 4);

// Also should be caught by static Flow checks.
() => PositiveNumberType.methodDoesntExist();

Which package versions are you using?

flow-runtime: 0.17.0

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

No branches or pull requests

1 participant