arrow_backBACK TO DRILLS
Black Beltstate-basicslockPREMIUM

TypeScript Excess Property Checking Is Bypassed Through Structural Assignment to useState

This component defines a typed form state and updates it through an intermediate variable rather than an inline literal.

REACT_MODULE // 0x42
interface UserForm {
name: string;
email: string;
}
const [form, setForm] = useState<UserForm>({ name: "", email: "" });
const payload = { name: "Alice", email: "a@x.com", role: "admin" };
setForm(payload);

Why does this code compile without a TypeScript error, despite payload having a role property not present on UserForm?

lock

This Drill is Locked

This is a premium drill. Continue on to the next free drill in the sequence.

CONTINUE DRILLarrow_forward
BugDojo
BlogFAQ

© 2026. Carved in code.