← All notes

Type compatibility and structural typing

Answer: Languages like C# and Java use nominal typing instead.

Example

interface Pet { name: string }
class Dog { name = "Rex"; bark() {} }
let p: Pet = new Dog(); // OK: Dog has name

Rules of thumb

Building types from types

Because compatibility is about shape, TypeScript offers operators to derive shapes: keyof, typeof, indexed access, conditional types, mapped types and template literal types.

type Keys = keyof Pet;                 // "name"
type ReadonlyPet = { readonly [K in keyof Pet]: Pet[K] };

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: TypeScript (Microsoft), TypeScript: Documentation - Type Compatibility, CC BY 4.0 (microsoft/TypeScript-Website); TypeScript (Microsoft), TypeScript: Documentation - Creating Types from Types, CC BY 4.0 (microsoft/TypeScript-Website).

Cite this

Permanent ID: iil:note:20z5qj5r

iinventedlight. 2026. "Type compatibility and structural typing." iinventedlight Library, iil:note:20z5qj5r, version of 2026-11-04. https://iinventedlight.com/library/notes/typescript-type-compatibility/. License: CC-BY-4.0.

@misc{iil_note_20z5qj5r,
  author = {{iinventedlight}},
  title = {{Type compatibility and structural typing}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/typescript-type-compatibility/},
  note = {Permanent ID iil:note:20z5qj5r. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/typescript-type-compatibility.md.