structural typing

A type rule where two types are compatible if they have the same shape, whatever they are called.

In more detail

In TypeScript an object is accepted wherever its properties match what is required, even if it was never declared as that type. The informal name duck typing comes from the saying that if it walks like a duck and quacks like a duck, it is a duck. This makes test data and composition easy, but two unrelated types with the same fields are interchangeable.

Related terms

Taught in

References