Typescript: Add ability to generate ambient declarations for external commonjs modules

Created on 21 Nov 2014  路  12Comments  路  Source: microsoft/TypeScript

Badly needed for commonjs modules where you are more likely to ship JS code plus a generated .d.ts file.

From codeplex : https://typescript.codeplex.com/workitem/2080

Suggestion

Most helpful comment

:+1:
We need tsc allow below syntax.

$ cat index.d.ts
// hand assemble
declare module "foobar" {
  export * from "./lib/main";
}

but, now we got below error message.

$ tsc --module commonjs index.d.ts
index.d.ts(3,3): error TS2439: Import or export declaration in an ambient module declaration cannot reference module through relative module name.

All 12 comments

This is related to, if not a duplicate of https://github.com/Microsoft/TypeScript/issues/575

Also I completely agree with emphasis. This is by far the biggest road block when trying to make use of Typescript within our organization.

Absolutely :+1:

The dts-bundle package (an admitted kludge) is the only way I was able to find to make commonjs modules resusable across projects. It was painful enough that I just switched to internal modules and shoved all the dependency management into my build script. Would be awesome to have commonjs modules "just work".

I believe this is a duplicate of, or very related to #17

We're using dts-bundle to get around this, it'd be great to have compiler support.

+1. We really really really need this.

+1. It would be really useful.

:+1:
We need tsc allow below syntax.

$ cat index.d.ts
// hand assemble
declare module "foobar" {
  export * from "./lib/main";
}

but, now we got below error message.

$ tsc --module commonjs index.d.ts
index.d.ts(3,3): error TS2439: Import or export declaration in an ambient module declaration cannot reference module through relative module name.

+1

Now that the compiler supports node module resolution this can be closed as far as I am concerned :rose:

If @basarat says it's good it's good with me too :smiley:

@basarat can you show how this can be done? I want to do the very thing the error is saying cannot be done. What is the alternative?
'Import or export declaration in an ambient module declaration cannot reference module through relative module name.'

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielRosenwasser picture DanielRosenwasser  路  3Comments

weswigham picture weswigham  路  3Comments

manekinekko picture manekinekko  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments

MartynasZilinskas picture MartynasZilinskas  路  3Comments