TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

[Web API type definition issue] securitypolicyviolation event in WorkerGlobalScope should be typed as SecurityPolicyViolationEvent

Open SkyZeroZx opened this issue 6 months ago • 1 comments

Summary

Missing Type for SecurityPolicyViolationEvent in WorkerGlobalScope

Expected vs. Actual Behavior

securitypolicyviolation event in WorkerGlobalScope should be typed as SecurityPolicyViolationEvent

According to the MDN documentation, the securitypolicyviolation event in WorkerGlobalScope should provide a SecurityPolicyViolationEvent.

Currently, TypeScript types this event as a generic Event, which loses all the properties specific to SecurityPolicyViolationEvent such as documentURI, blockedURI, violatedDirective, effectiveDirective, etc.

It would be helpful if TypeScript provided proper typings so that developers can access these properties safely, for example:

self.addEventListener('securitypolicyviolation', (event: SecurityPolicyViolationEvent) => {
  console.log(event.violatedDirective);
});

Playground Link

No response

Browser Support

  • [x] This API is supported in at least two major browser engines (not two Chromium-based browsers).

Have Tried The Latest Releases

  • [x] This issue applies to the latest release of TypeScript.
  • [x] This issue applies to the latest release of @types/web.

Additional Context

No response

SkyZeroZx avatar Aug 24 '25 22:08 SkyZeroZx

PR proposed : https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/2124

SkyZeroZx avatar Aug 25 '25 02:08 SkyZeroZx