@@ -111,6 +111,7 @@ declare interface Window {
111111 }
112112 } ;
113113 ResizeObserver : ResizeObserver ;
114+ trustedTypes : TrustedTypePolicyFactory ;
114115}
115116
116117/**
@@ -162,3 +163,41 @@ interface ResizeObserverEntry {
162163 */
163164 readonly contentRect : DOMRectReadOnly ;
164165}
166+
167+ // https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types
168+
169+ type TrustedHTML = string ;
170+ type TrustedScript = string ;
171+ type TrustedScriptURL = string ;
172+ type TrustedType = TrustedHTML | TrustedScript | TrustedScriptURL ;
173+ type StringContext = 'TrustedHTML' | 'TrustedScript' | 'TrustedScriptURL' ;
174+
175+ // https://w3c.github.io/webappsec-trusted-types/dist/spec/#typedef-trustedtypepolicy
176+
177+ interface TrustedTypePolicy {
178+ createHTML ( input : string , ...arguments : any [ ] ) : TrustedHTML ;
179+ createScript ( input : string , ...arguments : any [ ] ) : TrustedScript ;
180+ createScriptURL ( input : string , ...arguments : any [ ] ) : TrustedScriptURL ;
181+ }
182+
183+ // https://w3c.github.io/webappsec-trusted-types/dist/spec/#typedef-trustedtypepolicyoptions
184+
185+ interface TrustedTypePolicyOptions {
186+ createHTML ?: ( input : string , ...arguments : any [ ] ) => TrustedHTML ;
187+ createScript ?: ( input : string , ...arguments : any [ ] ) => TrustedScript ;
188+ createScriptURL ?: ( input : string , ...arguments : any [ ] ) => TrustedScriptURL ;
189+ }
190+
191+ // https://w3c.github.io/webappsec-trusted-types/dist/spec/#typedef-trustedtypepolicyfactory
192+
193+ interface TrustedTypePolicyFactory {
194+ createPolicy ( policyName : string , policyOptions : TrustedTypePolicyOptions ) : TrustedTypePolicy
195+ isHTML ( value : any ) : boolean ;
196+ isScript ( value : any ) : boolean ;
197+ isScriptURL ( value : any ) : boolean ;
198+ readonly emptyHTML : TrustedHTML ;
199+ readonly emptyScript : TrustedScript ;
200+ getAttributeType ( tagName : string , attribute : string , elementNs ?: string , attrNs ?: string ) : StringContext | null ;
201+ getPropertyType ( tagName : string , property : string , elementNs ?: string ) : StringContext | null ;
202+ readonly defaultPolicy : TrustedTypePolicy | null ;
203+ }
0 commit comments