You need to conduct a code review of a small Vue 3.5 component on the Composition API and TypeScript 5.8.
Context:
customerId and shows a short customer card.customerId changes, a new request must be started.Mock layer API contract:
fetchCustomerCard(id: string, signal?: AbortSignal): Promise<CustomerCard>AbortSignal.id === 'slow', the response arrives in about 120 ms.id === 'fast', the response arrives in about 20 ms.DOMException and name === 'AbortError'.How to reproduce:
customerId="slow".customerId="fast".loading state, the card contents, and the empty state during the rapid change.Assumptions:
Describe the issues found and propose a correct fix.
Vue 3.5 Composition API, TypeScript 5.8, browser; additionally: Vite 5, DOM AbortController, execution mode — client-side rendering in the browser without SSR
Use line comments to explain the problem, its impact, the fix and how to test it.