简体   繁体   中英

Typescript modules and importing - references?

Models/Objects/A.ts

module App.Models.Objects
{
    export class A
    {}
}

Models/Abstracts/ISomethingElse.ts

module App.Models.Abstracts
{
    export interface ISomethingElse
    {
        A: A;
    }
}

How do i use the module App.Models.Objects from the ISomethingElse.ts file?

I have tried referencing:

/// <reference path="../Objects/A.ts" />

But it still cannot find A because it's in the module. How do i import it?

I have tried importing:

/// <reference path="../Objects/A.ts" />
import A = require("App.Models.Objects");

But it still doesn't compile.

What am i doing wrong?

Assuming you're not using an editor that takes care of the references for you, the relative reference path you've used is wrong. The following should work:

 /// <reference path="../objects/A.ts"/> module App.Models.Abstracts { export interface ISomethingElse { a: App.Models.Objects.A; } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM