Avatar ·

How to properly define global constants in TypeScript for an Angular application?

Hello everyone! I'm new to TypeScript and Angular and I've run into a problem with defining global constants. \n\nI have an application that uses the same values in different components and services. For example, API URL, maximum number of items per page, event names, and so on. Currently, I just duplicate these values in each file, but this is clearly wrong — if I need to change the URL, I have to edit it in a dozen places.\n\nI tried declaring constants inside a class, but then they are not accessible from other files without importing an instance of the class. Here's an example of what I'm doing now:\n\n```typescript\n// in user.component.ts\nconst API_URL = 'https://api.example.com/v1';\nconst MAX_ITEMS = 10;\n\nexport class UserComponent {\n constructor() {\n console.log(API_U