Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct declaration emit of commonjs exports of namespace-nested classes #40479

Open
sandersn opened this issue Sep 10, 2020 · 0 comments
Open
Assignees
Labels
Bug A bug in TypeScript
Milestone

Comments

@sandersn
Copy link
Member

Followup to #40228:

var NS = {}
NS.K =class {
    values() {
        return new NS.K()
    }
}
exports.K = NS.K;

Expected behavior:

Should produce d.ts output:

declare namespace NS {
    class _K {
      values(): _K;
    }
    export {_K as K};
}
import _K = NS.K;
export {_K as K};

Actual behavior:

export var K: {
    new (): {
        values(): any;
    };
};
  1. Inlines and destroys the namespace.
  2. Only exports a value, not a class.
  3. Doesn't serialise nested typed references to K properly.

The declaration emitter just needs code to support this; right now it's hitting inaccurate fallback code.

@sandersn sandersn self-assigned this Sep 10, 2020
@sandersn sandersn added this to the Backlog milestone Sep 10, 2020
@sandersn sandersn added the Bug A bug in TypeScript label Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

1 participant