Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-extractor]: update getGlobalVariableAnalyzer to support changes to typescript internals in v4.7 #3394

Conversation

chrisdholt
Copy link
Member

@chrisdholt chrisdholt commented May 4, 2022

Summary

This PR is intended to (hopefully) provide a backwards compatible solution for incoming breaking changes in typescript's internals as of v4.7.0 (currently in beta). This PR closes #3349.

API-Extractor relies on Typescript internals to function, and those internals have been changed with this PR for the upcoming minor version of Typescript: https://github.com/microsoft/TypeScript/pull/36747/files.

Details

This change checks the validity of either API and should execute based on one being available. I tended towards keeping things less verbose to keep from requiring multiple nested if statements, etc. One place this is apparent is the error thrown. Rather than trying to track down which instance is missing, it seemed that providing a note that either is missing keeps parity for the error intent. I'm certainly open to a more verbosity in the checks, it simply seemed unnecessary as we really care that one of these API's exists (depending on version).

This change should not break compatibility from what I can tell, though I'm not super familiar with the use of internals here.

I don't believe this should result in a significant performance degradation - though more verbose alternatives possibly could.

NOTE: I chose to submit this as a patch because it doesn't seem fundamentally additive to the API Extractor in any meaningful way. While it does affect the package, it's both backwards compatible and relatively specific to the internals from what I can tell. Happy to update to minor if folks feel that's needed, but patch seemed most reasonable in my own assessment.

How it was tested

I'm pushing this up for PR first as I assume there may be conversation required about this change - I plan on manually testing this primarily against the v4.7.0-beta branch in one of our local repositories to ensure that things run correctly.

Updated a local version of the project to 4.7.0-beta and it appears as though this ran successfully. No project changes meant no changes to our docs, but the error no longer throws and we get green. Edit (again): Ran with changes and api-extractor completed successfully in that scenario as well.

image

@chrisdholt chrisdholt force-pushed the users/chhol/update-api-for-getDiagnosticsProducingTypeChecker branch from a0b14e7 to fe1b26b Compare May 4, 2022 21:32
@iclanton iclanton enabled auto-merge May 4, 2022 22:51
@iclanton iclanton merged commit 7ffca33 into microsoft:main May 4, 2022
@chrisdholt chrisdholt deleted the users/chhol/update-api-for-getDiagnosticsProducingTypeChecker branch May 4, 2022 23:03
@sosukesuzuki
Copy link

New api-extractor seems to be work fine with typescript 4.7-beta! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[api-extractor] Internal Error: Missing Program.getDiagnosticsProducingTypeChecker with [email protected]
3 participants