Followup to #40228: ```js var NS = {} NS.K =class { values() { return new NS.K() } } exports.K = NS.K; ``` **Expected behavior:** Should produce d.ts output: ```ts declare namespace NS { class _K { values(): _K; } export {_K as K}; } import _K = NS.K; export {_K as K}; ``` **Actual behavior:** ```ts export var K: { new (): { values(): any; }; }; ``` 1. Inlines and destroys the namespace. 3. Only exports a value, not a class. 2. 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.