codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

Global declarations #146

Closed patrikholcak closed 8 years ago

patrikholcak commented 8 years ago

I was just curious if there’s any possibility of having support for declarations declared in the [libs] field of .flowconfig.

It would make this possible:

// should work without import type {…}

class App extends React.Component {
  static defaultProps = {};
  props: {
    dispatch: Dispatcher<Action>
  }

  doAction(ev: SyntheticEvent) {
    …
  }
}

where SyntheticEvent is global declaration in flow’s react module declarations and Dispatcher and Action are loaded from .flowconfig libs. This already works with flow check command.

Stumbled upon this when I was setting up a new project with flow. Running flow check did not report any errors but when I started a webpack server, I got a Dispatcher is not defined error.

phpnode commented 8 years ago

Absolutely yes, in v4 we parse the flow config to extract that kind of info, and then go and build our own model of those types. This will result in much better flow compatibility, but it's not close to release yet

patrikholcak commented 8 years ago

Awesome! And thanks for the quick reply. Is there any timeline on v4?

phpnode commented 8 years ago

With luck a couple of weeks, free time allowing

patrikholcak commented 8 years ago

Splendid! Thanks! 🍻