rushstack
rushstack copied to clipboard
[api-extractor] preserve ts-ignore directives on imports
Summary
Some libraries need to conditionally import types (ex. for optional peer dependencies), which requires a @ts-ignore annotation on the import in case the user doesn't have the dependency installed. This PR makes api-extractor preserve ts-ignore directives, which would otherwise be lost in the DTS rollup process.
Details
This uses an internal typescript compiler API to be as accurate as possible without introducing a lot of new code to find directive ranges using the public API.
How it was tested
I modified the tests to cover this functionality and ran rush test -t tag:api-extractor-tests.
@microsoft-github-policy-service agree company="Stainless Software"