Suppose you have a very large object defined as a TypeScript interface:
interface AccountInterface {
accountIdentifier?: string;
sid?: string;
idToken?: {
aio?: string;
};
idTokenClaims?: {
aio?: string;
};
}
I would like the object to always have its properties and sub properties. They can either be a string or an empty string:
let account = {
accountIdentifier: "",
sid: "",
idToken: {
aio: "",
},
idTokenClaims: {
aio: "",
},
};
Reading the other questions I thought it would have been possible to do this:
const emptyAccount = {} as AccountInterface
console.log('emptyAccount ', emptyAccount)
console.log('emptyAccount.sid ', emptyAccount.sid)
But this doesn't create an object with all the properties as empty strings as desired.
It would be great if something like this would be possible, so there's no need to duplicate the object in the code, as in one for the interface and one for the object with empty string properties.