Is it possible to restrict typescript object to contain only properties defined by its class ? : <p>Here is my code</p>

<pre><code>async getAll(): Promise&lt;GetAllUserData[]&gt; {
    return await dbQuery(); // dbQuery returns User[]
}

class User {
    id: number;
    name: string;
}

class GetAllUserData{
    id: number;
}
</code></pre>

<p><code>getAll</code> function returns <code>User[]</code>, and each element of array has the <code>name</code> property, event if it's return type is <code>GetAllUserData[]</code>.</p>

<p>I want to know if it is possible <code>out of the box</code> in typescript to restrict an object only to properties specified by it's type.</p>
