Two solutions below. I prefer the latter since it offers clean interfacing with Node JS modules, but unfortunately my IDE doesn't (yet) like it as much as I do...
Use references
Create a definitions.d.ts
file that will only contain the references to your classes/interfaces
/// <reference path="Parent.ts" />
/// <reference path="Child.ts" />
In Parent.ts
and Child.ts
, point to a single reference, the definitions.d.ts
file
/// <reference path="definitions.d.ts" />
Use import...require
pass the --module commonjs
flag to tsc
then import
what you require
and export
what you want to expose
In Parent.ts
import Child = require('Child')
interface Parent {
children: Child[]
}
export = Parent
In Child.ts
import Parent = require('Parent')
interface Child {
parent: Parent
}
export = Child
Please note, that you do not specify the extension '.ts' in require
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…