How can you implement a Singleton pattern in TypeScript?
Instruction: Describe the Singleton pattern and provide a TypeScript code example demonstrating its implementation.
Context: This question evaluates the candidate's understanding of design patterns and their ability to implement the Singleton pattern in TypeScript.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
A singleton exposes a controlled access point that reuses one instance within a particular scope. In TypeScript, a private constructor and a static accessor can express that convention for checked callers.
```typescript class AppSettings { private static instance: AppSettings | undefined; private constructor(private readonly label: string) {}...