type predicate2021. 1. 11.
interface Article {
title: string;
body: string;
}
function isArticle(body: unknown): body is Article {
let b = body as Article;
return !!b && typeof b.body === 'string' && typeof b.title === 'string';
}
interface Article {
title: string;
body: string;
}
function isArticle(body: unknown): body is Article {
let b = body as Article;
return !!b && typeof b.body === 'string' && typeof b.title === 'string';
}