Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative Modules in Ambient Modules

As of TypeScript 1.6.2, there was a "fix" for a long term "defect" which made it impossible to import relative modules into ambient modules, now some of my code is breaking. We utilise an AMD environment where we have a plugin module that loads CommonJS modules when executing under Node. In particular I am using Intern as a testing framework and developing something that is designed to be used only as a CommonJS module.

For example, I used to have this declaration:

declare module 'intern/dojo/node!../../index' {
    import * as dtsGenerator from '../../index';
    export = dtsGenerator
}

But now I get Import or export declaration in an ambient module declaration cannot reference module through relative module name.

I cannot figure out how to resolve a module absolutely within my ambient module for something contained within my project. As of course the following indicates that index cannot be found:

declare module 'intern/dojo/node!../../index' {
    import * as dtsGenerator from 'index';
    export = dtsGenerator
}
like image 641
Kitson Avatar asked Sep 20 '15 19:09

Kitson


1 Answers

To dismiss errors, you can now use:

declare module '*';
like image 97
Jan Avatar answered Oct 10 '22 05:10

Jan