Answer the question
In order to leave comments, you need to log in
How to change type in TypeScript?
In short, I get a data object with one type. You need to return the same object, but with changed fields. When you try to change the fields of the vehicle swears. Using any is not an option.
UserEntity {
id: number;
name: string;
email: string;
profile: ProfileEntity[];
contact: ContactEntity;
}
a.profile = [1,2,3];
a.contact = 159;
Answer the question
In order to leave comments, you need to log in
You can use the | operator, Union Types. Example
class UserEntity {
public name: number | string;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question