TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

ES6 syntax for import/export doesn't work in ambient modules

Open Koloto opened this issue 11 years ago • 7 comments

Code to reproduce:

// File: external.d.ts
export interface IFoo {}
// File: ambient.d.ts
declare module "moduleA" {
    import { IFoo } from "external"; // ERROR TS2307: Cannot find module 'external'.
}

Old syntax with require works fine:

// File: ambient.d.ts
declare module "moduleA" {
    import ext = require("external");
    import IFoo = ext.IFoo; // works
}

But I can't use require to export *. This is a problem (export = is not the same) Tested in TS 1.5.3 and 1.6.2 with --module amd compiler option.

Koloto avatar Sep 29 '15 11:09 Koloto

I can not repor this locally..

c:\test\5013>dir /B
ambient.d.ts
external.d.ts

c:\test\5013>type ambient.d.ts
// File: ambient.d.ts
declare module "moduleA" {
    import { IFoo } from "external";
}

declare module "moduleB" {
    import ext = require("external");
    import IFoo = ext.IFoo;
}

c:\test\5013>type external.d.ts
// File: external.d.ts
export interface IFoo { }

c:\test\5013>tsc --version
message TS6029: Version 1.6.2

c:\test\5013>tsc ambient.d.ts external.d.ts --m amd

mhegazy avatar Sep 29 '15 17:09 mhegazy

@mhegazy Remove declare module "moduleB" from ambient.d.ts

Koloto avatar Sep 29 '15 17:09 Koloto

thanks. my bad. @vladima can you take a look.

mhegazy avatar Sep 29 '15 18:09 mhegazy

@Koloto can you give tonight's typescript@next a try. the package is published to npm a little after 12:00 am PST.

mhegazy avatar Sep 30 '15 00:09 mhegazy

@mhegazy, @vladima thanks, typescript@next works fine. Could you fix this in 1.6?

Koloto avatar Sep 30 '15 08:09 Koloto

this will be in the next TypeScript release (TS 1.7).

mhegazy avatar Sep 30 '15 16:09 mhegazy

When to wait next release?

chandrush avatar Nov 05 '15 14:11 chandrush