Missing Cancellation Token (ARCH3024)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key typescript.async.missing-abort-signal · Severity warning · Category async
Public or long-running async operations should accept an AbortSignal parameter and propagate it to inner calls so the work can be cancelled. Without it, the operation cannot be stopped in time.
Incorrect
Section titled “Incorrect”async function fetchReport(id: string): Promise<Report> { const res = await fetch(`/api/reports/${id}`); return res.json();}Correct
Section titled “Correct”async function fetchReport(id: string, signal?: AbortSignal): Promise<Report> { const res = await fetch(`/api/reports/${id}`, { signal }); return res.json();}Add a signal?: AbortSignal parameter to the signature and pass it through to the async APIs you call.