What is the best and most convenient way to implement a Singleton pattern for a class in TypeScript? (Both with and without lazy initialisation).
I am surprised not to see the following pattern here, which actually looks very simple.
// shout.ts class ShoutSingleton { helloWorld() { return 'hi'; } } export let Shout = new ShoutSingleton();
Usage
import { Shout } from './shout'; Shout.helloWorld();