Skip to content

Merge and re-export module in external module declaration #2019

Closed
@jbrantly

Description

@jbrantly

Let's say I'm writing a declaration file for a library that exports two external modules: myLib and myLibWithExtras. The myLibWithExtras module is exactly myLib but with some additional items.

As an example of what I'm trying to do:

// myLib.d.ts
declare module "myLib" {
  function doSomething(): void;
}

declare module "myLibWithExtras" {
  // this doesn't work 
  import myLib= require("myLib");
  module myLib {
    function doSomethingElse(): void;
  }
  export = myLib;
}

// consumer.ts
import myLib = require("myLib")
import myLibWithExtras = require("myLibWithExtras")
myLib.doSomething();
myLib.doSomethingElse(); // should not compile
myLibWithExtras.doSomething();
myLibWithExtras.doSomethingElse();

Is there any way to accomplish this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions