You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lib.dom.d.ts: AudioContextState enum is missing "interrupted" state #61823
The AudioContextState enum type definition in lib.dom.d.ts currently lacks the "interrupted" state. This state is part of the Web Audio API specification and is already implemented and used in certain browser environments (notably WebKit/Safari).
When running Web Audio API code in Safari (macOS Sonoma 14.5, iOS Safari), AudioContext.state can transition to "interrupted" (e.g., upon screen lock with navigator.audioSession.type = "auto", or during a phone call). However, the TypeScript definition for AudioContextState only includes "closed" | "running" | "suspended".
This leads to TypeScript errors when attempting to check for or handle the "interrupted" state:
constaudioCtx=newAudioContext();audioCtx.onstatechange=()=>{// TypeScript will issue an error here (e.g., ts(2367))// because "interrupted" is not a known literal in AudioContextStateif(audioCtx.state==="interrupted"){console.log("AudioContext was interrupted by the UA.");}};
constaudioCtx=newAudioContext();audioCtx.onstatechange=()=>{// TypeScript will issue an error here (e.g., ts(2367))// because "interrupted" is not a known literal in AudioContextStateif(audioCtx.state==="interrupted"){console.log("AudioContext was interrupted by the UA.");}};
🙁 Actual behavior
TypeScript raises a ts(2367) error: This comparison appears to be unintentional because the types 'AudioContextState' and '"interrupted"' have no overlap.ts(2367)
🙂 Expected behavior
The AudioContextState type definition in lib.dom.d.ts should be updated to include the "interrupted" state, reflecting its presence in modern Web Audio API implementations and ongoing specification discussions.
Activity
idango10 commentedon Jun 11, 2025
Looks like it was fixed in this PR: #61647
patricksuo commentedon Jun 12, 2025
Idan Goshen (@idango10) Thanks for pointing out the fix in #61647 . It's not released yet, but I'll track the Release Notes. Closing this Issue.