Answer the question
In order to leave comments, you need to log in
Three dot typing in Typescript. How to resolve?
When using three dots to join objects typed by an interface, it does not throw an error when passing an invalid property that does not exist in this interface.
For example, is it possible to type this case?
interface IExampleInterface {
property1: number;
property2: string;
};
function test(props: IExampleInterface): IExampleInterface {
return {
...props,
property1: 123,
property2: 'test',
property3: 1 // Нет ошибки передачи
};
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question