TypeScript hỗ trợ recursive type aliases.
Hữu ích cho tree structures, nested JSON, linked lists.
typescript
type TreeNode<T> = {
value: T;
children: TreeNode<T>[]; // tự tham chiếu
};
// JSON có thể dùng JSON type chuẩn:
type Json = string | number | boolean | null
| Json[] | { [key: string]: Json };Interface luôn hỗ trợ recursive (vì là named type), type alias cũng hỗ trợ từ TS 3.7.