Answer the question
In order to leave comments, you need to log in
Why does typescript not complain about the return value of the callback and how to fix it?
ts playground
interface Animal {
name: string;
}
type Callback = (v: Animal) => Animal;
const mutate = (animal: Animal, cb: Callback) => {
cb(animal);
};
mutate({ name: 'Reb' }, () => {
return {
name: 'Oooops',
a: 1232131, // ожидается ошибка, но её нет
}
});
Answer the question
In order to leave comments, you need to log in
https://github.com/Microsoft/TypeScript/wiki/FAQ#w...
https://www.typescriptlang.org/docs/handbook/type-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question