Answers for "typescript create empty object from type"

3

init empty object typescript

type User = {
    Username: string;
    Email: string;
}

const user01 = {} as User;
const user02 = <User>{};

user01.Email = "[email protected]";
Posted by: Guest on May-27-2020
0

empty object typescript

type EmptyObject = {
    [K in any] : never
}

const one: EmptyObject = {}; // yes ok
const two: EmptyObject = {a: 1}; // error
Posted by: Guest on October-13-2021

Code answers related to "typescript create empty object from type"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language