Skip to content

Commit

Permalink
[core] add proper parameter type for TrustedTypePolicy createHTML c…
Browse files Browse the repository at this point in the history
…allback (Azure#25813)

### Packages impacted by this PR
`@azure/core-xml`, `@azure/core-http`

### Issues associated with this PR
Fixes issue Azure#24872.

### Describe the problem that is addressed by this PR

Upgrading to @trusted-types v2.0.3 caused compilation error. While it is
breaking, it surfaces an issue that we can address by adding proper
parameter type.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?
Pinning to v2.0.2 which isn't desirable as we want to stay on latest
dependency versions.
  • Loading branch information
jeremymeng authored and minhanh-phan committed Jun 12, 2023
1 parent 182d086 commit b3c8dd5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion common/config/rush/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* instead of the latest version.
*/
// "some-library": "1.2.3"
"@types/trusted-types": "2.0.2" // #24872
},
/**
* When set to true, for all projects in the repo, all dependencies will be automatically added as preferredVersions,
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/src/util/xml.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getSerializer(): XMLSerializer {
let ttPolicy: Pick<TrustedTypePolicy, "createHTML"> | undefined;
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/core-http#xml.browser", {
createHTML: (s) => s,
createHTML: (s: string) => s,
});
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-xml/src/xml.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let ttPolicy: Pick<TrustedTypePolicy, "createHTML"> | undefined;
try {
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/core-xml#xml.browser", {
createHTML: (s: any) => s,
createHTML: (s: string) => s,
});
}
} catch (e: any) {
Expand Down

0 comments on commit b3c8dd5

Please sign in to comment.