step trail before-after now-you-try feedback A shared helper pickFirst(items: any[]) returns the first item from dashboards for users, projects, and alerts. Generic preservation: T[] in, T | undefined out The shortcut is to keep any[] because the helper works for many arrays. That hides the fact that every caller loses its item type. Find the relationship The helper does not need a user, project, or alert specifically. It needs to return the same kind of item the caller provided. A generic is justified because there is a real relationship to preserve: input item type to output item type. Add the…
Read the full lesson
Sign up free: one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in