Support recursive types

master
Vitaliy Filippov 2019-05-23 23:54:51 +03:00
parent 84aface8eb
commit 870756a440
2 changed files with 5 additions and 1 deletions

View File

@ -31,6 +31,10 @@ import {invariant} from '../utils';
function processTypeAlias(ctx: Context, node: TypeAlias | DeclareTypeAlias) {
const {name} = node.id;
// Forward declaration for the recursive types
ctx.define(name, t.createAny());
const type = makeType(ctx, node.right);
// TODO: support function aliases.

View File

@ -84,7 +84,7 @@ export default class Scope {
if (declared) {
invariant(decl);
invariant(decl.kind === 'declaration');
invariant(decl.kind === 'declaration' || decl.kind === 'definition');
} else {
invariant(!decl);
}