fix(extract): skip declare ambient class properties in class-member extraction#849
Open
BartWaardenburg wants to merge 3 commits into
Open
fix(extract): skip declare ambient class properties in class-member extraction#849BartWaardenburg wants to merge 3 commits into
declare ambient class properties in class-member extraction#849BartWaardenburg wants to merge 3 commits into
Conversation
… extraction Fixes #839
- Bump extract CACHE_VERSION 107 -> 108: skipping declare ambient class members changes the persisted CachedExport.members shape, so warm caches would otherwise retain the false unused-class-member finding across upgrade. - Add CHANGELOG entry under Unreleased/Fixed. - Add detection.md note for the declare exclusion.
7d7f952 to
9e303a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DRAFT: Reviewer verdict was FIX. The following must be resolved before merge:
CACHE_VERSIONfrom 106 to 107 incrates/extract/src/cache/types.rs(line 108) and add a doc paragraph explaining that pre-fix caches may retain thedeclaremember as unused until the file is re-extracted.Summary
Added a
&& !prop.declareguard in theClassElement::PropertyDefinitionarm ofextract_class_membersincrates/extract/src/visitor/helpers.rs. TypeScriptdeclareproperties are ambient-only (no emitted JS) and cannot be value-referenced, so they must not appear as extracted class members. The regression testdeclare_ambient_property_excluded_from_class_membersparses a class with adeclare readonly __input?: Ifield plus a normal method and asserts the ambient field is absent from extracted members while the method is present.Review
Verdict: FIX
CACHE_VERSIONbump.extract_class_membersoutput is persisted in the parse cache (CachedExport.members: Vec<CachedMember>incrates/extract/src/cache/types.rs:326,CACHE_VERSION=106). The fix changes the content of cached member data (now omits thedeclaremember), an extraction-semantics change. Without bumping 106 to 107, a user upgrading to get this fix keeps the stale cached__inputmember and the false unused-class-member finding persists across the upgrade until each affected file is touched. The assertion atcache/types.rs:145explicitly triggers on "wire shape OR extraction semantics."Closes #839