What is the best and most convenient way to implement a Singleton pattern for a class in TypeScript? (Both with and without lazy initialisation).
My solution for it:
export default class Modal { private static _instance : Modal = new Modal(); constructor () { if (Modal._instance) throw new Error("Use Modal.instance"); Modal._instance = this; } static get instance () { return Modal._instance; } }