Nâng CaoTypeScript iconTypeScript

TypeScript performance: tại sao type checking có thể chậm và cách cải thiện?

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.

Xem toàn bộ TypeScript cùng filter theo level & chủ đề con.

Mở danh sách TypeScript