Support recursive types
parent
84aface8eb
commit
870756a440
|
@ -31,6 +31,10 @@ import {invariant} from '../utils';
|
||||||
|
|
||||||
function processTypeAlias(ctx: Context, node: TypeAlias | DeclareTypeAlias) {
|
function processTypeAlias(ctx: Context, node: TypeAlias | DeclareTypeAlias) {
|
||||||
const {name} = node.id;
|
const {name} = node.id;
|
||||||
|
|
||||||
|
// Forward declaration for the recursive types
|
||||||
|
ctx.define(name, t.createAny());
|
||||||
|
|
||||||
const type = makeType(ctx, node.right);
|
const type = makeType(ctx, node.right);
|
||||||
|
|
||||||
// TODO: support function aliases.
|
// TODO: support function aliases.
|
||||||
|
|
|
@ -84,7 +84,7 @@ export default class Scope {
|
||||||
|
|
||||||
if (declared) {
|
if (declared) {
|
||||||
invariant(decl);
|
invariant(decl);
|
||||||
invariant(decl.kind === 'declaration');
|
invariant(decl.kind === 'declaration' || decl.kind === 'definition');
|
||||||
} else {
|
} else {
|
||||||
invariant(!decl);
|
invariant(!decl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue