I implemented a "Least Recently Used Cache" (LRU Cache) using a doubly linked list. The linked list consists of nodes (Node class) which are used within a LRUCache class.
To export my module I am using the following pattern:
export class Node { ... }
export class LRUCache { ... }
I am exporting my module as a CommonJS module. With the export class pattern above, I am able to use my module the following way:
var module = require('lru-cache');
var cache = new module.LRUCache();
That's okay, but I don't like the additional "module." part in front of LRUCache. I would like to use my CommonJS exported module like this:
var LRUCache = require('lru-cache');
var cache = new LRUCache();
So I changed my code into this:
class Node { ... }
class LRUCache { ... }
export = LRUCache;
But now TypeScript complains with:
error TS4055: Return type of public method from exported class has or is using private name 'Node'.
It's because LRUCache uses the Node class and Node is not exported when defining export = LRUCache;.
How can I solve this situation? I am using TypeScript 2.1.
Screenshot:

With typescript you can simply do:
And it will compile into:
If you prefer to use
require, you can:And then:
You can find much more info on this in the following two doc pages: