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

Importing of types #108

Closed ctrlplusb closed 8 years ago

ctrlplusb commented 8 years ago

Great work and library.

This is a feature request more than an issue.

It would be awesome to allow for the centralisation and importing of our types.

types.js

export type Foo = {
  name: string
}

bar.js

import { Foo } from './types';

export function bar(param: Foo): string {
  ...
}
phpnode commented 8 years ago

This already works:

import type {Foo} from './types';
export function bar(param: Foo): string {
  ...
}

Although it was having problems due to babel's plugin munging behaviour. It should be fixed in newish versions of babel 6.

ctrlplusb commented 8 years ago

Nice, thanks for the prompt reply.

Sorry for wasting your time on this one.