Skip to content
Justice Tech School

Object Types and Excess Properties

Object literals are checked for extra properties. Variables are not, which is structural typing.

Example
type P = { x: number };
const v = { x: 1, y: 2 };
const p: P = v;
console.log(p.x);

Result

1

Exercise

Shape matching.

TypeScript uses  typing

Quiz Test

What is structural typing?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.