Per direction from @mhegazy I’m opening this ticket as a discussion point for loosening the restriction forbidding relative module IDs in ImportDeclarations in AmbientModuleDeclaration. Loosening the restriction prevents the need to rewrite import declarations when combining multiple external declarations to a single file, and maybe simplifies some internals of the compiler (I haven’t checked, but it should eliminate some code branches).
Relative module IDs should be resolvable by the same way that the rest of the tsc machinery works, by resolving the reference according to the StringLiteral in a module’s own AmbientExternalModuleDeclaration. For example:
declare module 'foo/Foo' {
import Bar = require('./Bar'); // resolve to `foo/Bar`
}
Right now you are not allowed to do this and need to write:
declare module 'foo/Foo' {
import Bar = require('foo/Bar');
}
Per direction from @mhegazy I’m opening this ticket as a discussion point for loosening the restriction forbidding relative module IDs in
ImportDeclarations inAmbientModuleDeclaration. Loosening the restriction prevents the need to rewrite import declarations when combining multiple external declarations to a single file, and maybe simplifies some internals of the compiler (I haven’t checked, but it should eliminate some code branches).Relative module IDs should be resolvable by the same way that the rest of the tsc machinery works, by resolving the reference according to the
StringLiteralin a module’s ownAmbientExternalModuleDeclaration. For example:Right now you are not allowed to do this and need to write: