NoInfer 유틸리티 타입
제네릭 추론을 방지하여 특정 인자에서 타입이 추론되지 않도록 합니다.
function createFSM<S extends string>(
initial: S,
transitions: Record<S, NoInfer<S>[]>
) { /* ... */ }
// initial에서만 S가 추론됨
createFSM("idle", {
idle: ["running"],
running: ["idle", "error"],
error: ["idle"],
});Object.groupBy 타입
const grouped = Object.groupBy(users, (user) => user.role);
// Record<string, User[]>
댓글 0