0.5.0 • Published 7 months ago
@tolokoban/type-guards v0.5.0
@tolokoban/type-guards
import { assertType } from "@tolokoban/type-guards"
interface Article {
id: string
name: string
price: number
}
function printArticles(data: unknown): Article[] {
assertType<Article[]>(
data,
[
"array", {
id: "string",
name: "string",
price: "number"
}
]
)
for (const article of data) {
console.log(`#{article.name} #${article.id}`)
}
}