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

Type Aliases support? #2

Closed deepsweet closed 9 years ago

deepsweet commented 9 years ago

http://flowtype.org/docs/type-aliases.html

now they are just stripped out:

type T = number;

function test(a: T) {
}

:arrow_double_down:

"use strict";

function test(a) {
  if (!(a instanceof T)) throw new TypeError("Value of argument 'a' violates contract.");
}

I'm especially looking for Reusable Object Types. is it possible?

btw, thanks for the great plugin :wink:

phpnode commented 9 years ago

@deepsweet thanks, yes very keen to add support for this

nmn commented 9 years ago

+1

cesarandreu commented 9 years ago

+1

pillowsoft commented 9 years ago

+1

phpnode commented 9 years ago

We're waiting on Babel v6 for this. 6 comes with support for crossing module boundaries, which will make this feature viable, right now it's of very limited use.

why-jay commented 9 years ago

Hi @phpnode, I have a question that is irrelevant to this issue. Where can I find the discussion/documentation around Babel v6's "support for crossing module boundaries"? I'm wanting the exact feature for a plugin I'm writing. Any links would be helpful. Thanks.

phpnode commented 9 years ago

@chcokr there has been some discussion around this on slack, and there's mention of it in https://github.com/babel/babel/issues/2168 (see "Way to provide the entire dependency graph to Babel")

why-jay commented 9 years ago

Ah thanks. This feature can't come soon enough :)

yoni-tock commented 9 years ago

Out of curiosity, will this allow you to specify the shape of an object? That's the thing I most need right now as I'm just returning and passing Object everywhere. Examples of a workaround would also be great!

phpnode commented 9 years ago

@yoni-tock yes, the next version supports this. Will be released in the next day or two

yoni-tock commented 9 years ago

w00t!