rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] preserve ts-ignore directives on imports

Open stainless-em opened this issue 2 months ago • 1 comments

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.

stainless-em avatar Oct 31 '25 20:10 stainless-em

@microsoft-github-policy-service agree company="Stainless Software"

stainless-em avatar Oct 31 '25 20:10 stainless-em