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

Document "import type" and export ... #122

Closed gajus closed 8 years ago

gajus commented 8 years ago

It would be useful to have a basic example showing how to export and import type declarations. I have been going through https://github.com/codemix/babel-plugin-typecheck/issues looking for "import export" to understand the syntax.

gajus commented 8 years ago

This seem to work:

export type CsvDataType = Array<Array<String>>;
export type LocationType = {
    country: string,
    sourceNid: string,
    locationNid: string,
    name: string,
    url: string,
    alternativeUrl: ?string,
    street1: ?string
};
import type {
    CsvDataType,
    LocationType
} from './types';
phpnode commented 8 years ago

Good idea, added a note to the readme.

gajus commented 8 years ago

Is there a way to export/ import types using node.js module.exports/ require?