Set required attributes in TypeScript
<p>What is a proper way in TypeScript to mark some attributes as <strong>required</strong>? Let's say we have certain object, that must contain <strong>id</strong> field, but can also have as many other fields as it wants:</p>

<pre><code>interface SomeType {
    id: number;
}

let obj: SomeType = { name: "OBJ" };           // GOOD ERROR! We must have `id`
let obj: SomeType = { id: 123 };               // OK
let obj: SomeType = { id: 123, name: "OBJ" };  // BAD ERROR! I just want to add a name
</code></pre>

<p>I do know that you can make optional attributes with a question mark, like this: </p>

<pre><code>interface SomeType {
    id: number;
    name?: string;
    engine?: string;
    mother?: string;
}
</code></pre>

<p>But I don't want each time modify this interface by adding and mixing unrelated things to it.</p>

<p>Another option is of course to create a <em>swarm of interfaces</em> each extending the  main one, but that sounds like a lot of lines of code:</p>

<pre><code>interface SomeType {
    id: number;
}

interface FirstType extends SomeType {
    name: string;
}
</code></pre>

<p>At first I tried doing this:</p>

<pre><code>interface SomeType extends any {
    id: number;
}
</code></pre>

<p>But TypeScript can't find name <code>any</code>. Maybe there is something like this with an exclamation point?</p>

<pre><code>interface SomeType {
    id!: number;
}
</code></pre>

<p><strong>UPDATE</strong></p>

<p>I am using this type of interface when creating <a href="https://github.com/rackt/redux" rel="noreferrer">Redux</a> actions, which must have property <code>type</code> and any number of other additional attributes. There are really a lot of actions, so I was reluctant to use <code>any</code> as a type.</p>