Ambient external module declaration cannot reference external module through relative external module name.

Topics: General
Apr 27, 2014 at 3:19 AM
Edited Apr 27, 2014 at 3:19 AM
What is the reason this error exists?
error TS2197: Import declaration in an ambient external module declaration cannot reference external module through relative external module name.
The regular code can do this, so why not the declarations?
Coordinator
Apr 28, 2014 at 10:40 PM
Can you share the code snippet that's causing the error? Just so we have a more complete picture.
Apr 29, 2014 at 1:37 AM
I don't have the original case but I have a simple demo (code on github):
// in ./foo/foo.d.ts
declare module 'foo' {
    import bar = require('../bar/bar');
    class Foo {
        foo(): void;

        bar(): bar.Bar;
    }
    export = Foo;
}

// in ./bar/bar.d.ts
declare module 'bar' {
    class Bar {
        bar(): void;
    }
    export = Bar;
}
/ambient_import_relative/foo/foo.d.ts(2,2): error TS2071: Unable to resolve external module ''../bar/bar''.
/ambient_import_relative/foo/foo.d.ts(2,2): error TS2072: Module cannot be aliased to a non-module type.
/ambient_import_relative/foo/foo.d.ts(2,2): error TS2197: Import declaration in an ambient external module declaration cannot reference external module