Core Concepts: Type Safety
interface Task defines exactly what a task looks like. If you try to add a task missing a property, it throws an error immediately.
TodoItemProps, the component guarantees it will only ever receive the exact correct data it needs to render.
task.isDone or task.done.
// Notice how interfaces and types are gone!
// The browser only sees this plain JS:
function renderCard(props) {
let count = props.initialCount || 0;
const btn = document.querySelector('#action-btn');
btn.addEventListener('click', (event) => {
count++;
console.log(`Count is strictly a number: ${count}`);
});
}
renderCard({
title: "Type Safety",
description: "Catching bugs at compile time."
});
Catching bugs at compile time.