test: verify various typescript configurations #1075
Merged
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
This pull request adds an npm script called
verify-typescriptthat will attempt to compile some TypeScript projects with different configurations that use DOMPurify.Background & Context
See #1035 and #1073. It's easy to make a change to the TypeScript declarations and verify that it works for one or more configurations, but end up breaking another configuration. The goal of this change is to have a set of known TypeScript configurations that work. If we discover that another configuration doesn't work, then we can add the configuration to these tests and then go about fixing the TypeScript declarations to support that configuration, while also verifying that whatever change is made doesn't break any other configurations that we know about.
The TypeScript code in each project is not meant to be comprehensive. It is just enough to confirm that you can import from
dompurifyand call the functions.dompurifyverifies that the export is correct, and that the type declarations fortrusted-typesworks alongsidedompurify.dompurifyis a function that creates a newDOMPurifyinstance, and that it also defines thesanitizefunction.There are currently seven scenarios:
typesto include. Notably,trusted-typesis not one of them (this was actually what caused Compile of Angular app not possible since update to v3.2.x #1035 (comment)typeRootsto simulate not having@types/trusted-typesinstalled.typesto include (and, like the CommonJS one does not includetrusted-types)typeRootsto simulate not having@types/trusted-typesinstalled.moduleResolutionofnodenext.All of these projects compile successfully, and I have tried applying the change from #1073 and confirmed that it does result in compilation failures. 🎉
Example output when all succeed:
Example output when there are failures (in this case I applied the changes from #1073):
Tasks
N/A
Dependencies
N/A