Add triple-slash types reference to trusted-types. #1036
Merged
+70
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1035.
We need to tell TypeScript that we use the type declarations from
trusted-types
. This is done using a triple-slash directive. Without this, the references totrusted-types
in the type declaration file can cause compilation errors for certain configurations.I initially added
/// <reference types="trusted-types" preserve="true"/>
to the top ofpurify.ts
. Doing that resulted in the triple-slash directive being included in the type declaration files as expected, but it also ended up in the compiled JavaScript, but not at the top of the file (I think due to Rollup combining files together). To keep those files clean I've opted to add this directive via thefix-types.js
script (previously calledfix-cjs-types.js
).I've also installed
@types/node
as a dev dependency so thatfix-types.js
can have type checking performed to help avoid any mistakes when editing that file.