microsoft / microsoft/TypeScript
Correct declaration emit of commonjs exports of namespace-nested classes
Open
@sandersn is already working on this.
Since Sep 10, 2020.
Bug
Domain: Declaration Emit
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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;
};
};
- Inlines and destroys the namespace.
- Only exports a value, not a class.
- Doesn't serialise nested typed references to
Kproperly.
The declaration emitter just needs code to support this; right now it's hitting inaccurate fallback code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.