Skip to catalogue

structural typing

Structural typing compares the shape of types rather than only their declared names.

Use this when Two values with similar shapes are being treated as interchangeable.

without the term

“TypeScript let me pass an order id where a user id was expected because they're both strings, and it caused a bug. Can you make those types not interchangeable?”

with the term · How do you ask a model for structural typing?

Review this boundary’s structural types. Validate incoming data and prevent mixing these domain values without relying on an unchecked assertion.

XBlueskyLinkedIn

What is structural typing?

TypeScript treats two types as compatible if their shapes match, whatever they are named. So a UserId and an OrderId that are both strings can be mixed up unless you brand them.

Why does structural typing matter when vibe coding?

A type assertion can conceal a wrong assumption about incoming data.

How do you do structural typing?

Use explicit boundary validation and strengthen domain types where similar shapes have different meanings.

What goes wrong with structural typing?

Assuming naming two interfaces differently makes their values incompatible.

adjacent

reviewed

report a correction