Skip to content

Commit a7e3454

Browse files
committed
Update comments on the CSP trusted types TypeScript types with additional caveats.
1 parent f470332 commit a7e3454

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ function isWildcard(accept: string | null) {
44
return accept && !!accept.split(',').find(x => x.match(/^\s*\*\/\*/))
55
}
66

7-
// We don't want to add `@types/trusted-types` as a dependency, so we use this stand-in.
8-
9-
interface CSPTrustedHTMLToStringable {
10-
toString: () => string
11-
}
7+
// CSP trusted types: We don't want to add `@types/trusted-types` as a
8+
// dependency, so we use the following types as a stand-in.
129
interface CSPTrustedTypesPolicy {
1310
createHTML: (s: string, response: Response) => CSPTrustedHTMLToStringable
1411
}
12+
// Note: basically every object (and some primitives) in JS satisfy this
13+
// `CSPTrustedHTMLToStringable` interface, but this is the most compatible shape
14+
// we can use.
15+
interface CSPTrustedHTMLToStringable {
16+
toString: () => string
17+
}
1518
let cspTrustedTypesPolicyPromise: Promise<CSPTrustedTypesPolicy> | null = null
1619
// Passing `null` clears the policy.
1720
export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise<CSPTrustedTypesPolicy> | null): void {

0 commit comments

Comments
 (0)