Avatar ·

TypeScript: how to create an object with fields using an initializer, like in C#?

Hi everyone! I'm transitioning from C# to TypeScript and ran into a problem. In C#, I'm used to a convenient feature like object initializers: ```csharp var user = new User { Name = "John", Age = 30 }; ``` In TypeScript, I'm trying to do something similar: ```typescript interface User { name: string; age: number; } const user = new User(); // Error: 'User' refers to a type, but is being used as a value here. ``` I understand that an interface is not a class and cannot be instantiated. But how do I properly create an object with the `User` type and immediately fill its fields? I tried just writing: ```typescript const user: User = { name: "John", age: 30 }; ``` This works, but it feels like a workaround. In large projects with many fields, writing an object literal every time is not...