Reputation: 6257
I receive a form on a server. The form can only contain keys from User
interface. But since it is encoded, all its values will be strings. I can parse them before inserting them in my database, but I need to inform typescript that all the data received have User
keys with string type.
Basically, how to make this:
// base
interface User {
name: string;
hobbies: string[];
age: number;
}
// desired output
interface User {
name: string;
hobbies: string;
age: string;
}
Obviously, the model is quite long so it's not an option to copy/paste it and replace all its type with a string value.
Upvotes: 2
Views: 764