Type checking chậm do: complex conditional types, deep recursion, large union types, excessive use of infer. Cải thiện: bật incremental compilation, dùng project references, skipLibCheck: true, tránh deeply recursive types, prefer interface over type cho object shapes (merge tốt hơn), dùng tsc --diagnostics để profile.
Lý do prefer interface cho performance: interface types được cached bởi identity — compiler có thể nhanh chóng xác định hai interface references là cùng một type mà không cần re-evaluate. Type alias (đặc biệt là complex types) phải re-evaluate mỗi lần dùng.
Type checking can be slow due to: complex conditional types, deep recursion, large union types, and excessive use of infer. Improvements: enable incremental compilation, use project references, set skipLibCheck: true, avoid deeply recursive types, prefer interface over type for object shapes (merges better), and use tsc --diagnostics to profile.
Why interface performs better: interface types are cached by identity — the compiler can quickly determine two interface references are the same type without re-evaluating. Type aliases (especially complex ones) must be re-evaluated each time they are used.