fix(isolated_declarations): collect types from private accessors for paired inference#21516
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 20, 2026
Conversation
prefer-dom-node-remove rule (#21470)
Member
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
77c7813 to
b1b017a
Compare
Member
Author
Merge activity
|
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 20, 2026
…paired inference (#21516) ## Summary A public (or protected) getter paired with a `private set(v: T)` should get its return type from the setter's parameter annotation — that's the standard `isolatedDeclarations` accessor-pair inference rule ("one annotated side is enough"). Previously, `collect_accessor_annotations` skipped any accessor with a `private` modifier, so the pairing never happened and `TS9009` fired on the untyped getter. This change: - No longer skips `private`-modifier accessors when collecting annotations for paired inference. - For private **setters**, collects the explicit parameter type annotation — same behavior as before for non-private setters (no body inference). - For private **getters**, only uses an explicit return type annotation. Running body inference would surface errors like `TS9038` on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway. ## Example ```ts export class MockProxy { get isRunning() { return this._state.isRunning; } private set isRunning(val: boolean) { this._state.isRunning = val; } } ``` Before: `TS9009: At least one accessor must have an explicit return type annotation`. After: no error — emits `get isRunning(): boolean;` and `private set isRunning(value);`, matching tsc. ## Test plan - [x] Added fixtures for both a public getter + private setter pair and a protected getter + private setter pair - [x] `cargo test -p oxc_isolated_declarations` — no regression on existing private-accessor snapshots Closes #21503 (case 2)
b1b017a to
811876a
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 20, 2026
…paired inference (#21516) ## Summary A public (or protected) getter paired with a `private set(v: T)` should get its return type from the setter's parameter annotation — that's the standard `isolatedDeclarations` accessor-pair inference rule ("one annotated side is enough"). Previously, `collect_accessor_annotations` skipped any accessor with a `private` modifier, so the pairing never happened and `TS9009` fired on the untyped getter. This change: - No longer skips `private`-modifier accessors when collecting annotations for paired inference. - For private **setters**, collects the explicit parameter type annotation — same behavior as before for non-private setters (no body inference). - For private **getters**, only uses an explicit return type annotation. Running body inference would surface errors like `TS9038` on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway. ## Example ```ts export class MockProxy { get isRunning() { return this._state.isRunning; } private set isRunning(val: boolean) { this._state.isRunning = val; } } ``` Before: `TS9009: At least one accessor must have an explicit return type annotation`. After: no error — emits `get isRunning(): boolean;` and `private set isRunning(value);`, matching tsc. ## Test plan - [x] Added fixtures for both a public getter + private setter pair and a protected getter + private setter pair - [x] `cargo test -p oxc_isolated_declarations` — no regression on existing private-accessor snapshots Closes #21503 (case 2)
811876a to
92c70bc
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 20, 2026
…paired inference (#21516) ## Summary A public (or protected) getter paired with a `private set(v: T)` should get its return type from the setter's parameter annotation — that's the standard `isolatedDeclarations` accessor-pair inference rule ("one annotated side is enough"). Previously, `collect_accessor_annotations` skipped any accessor with a `private` modifier, so the pairing never happened and `TS9009` fired on the untyped getter. This change: - No longer skips `private`-modifier accessors when collecting annotations for paired inference. - For private **setters**, collects the explicit parameter type annotation — same behavior as before for non-private setters (no body inference). - For private **getters**, only uses an explicit return type annotation. Running body inference would surface errors like `TS9038` on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway. ## Example ```ts export class MockProxy { get isRunning() { return this._state.isRunning; } private set isRunning(val: boolean) { this._state.isRunning = val; } } ``` Before: `TS9009: At least one accessor must have an explicit return type annotation`. After: no error — emits `get isRunning(): boolean;` and `private set isRunning(value);`, matching tsc. ## Test plan - [x] Added fixtures for both a public getter + private setter pair and a protected getter + private setter pair - [x] `cargo test -p oxc_isolated_declarations` — no regression on existing private-accessor snapshots Closes #21503 (case 2)
92c70bc to
c05af7a
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 20, 2026
…paired inference (#21516) ## Summary A public (or protected) getter paired with a `private set(v: T)` should get its return type from the setter's parameter annotation — that's the standard `isolatedDeclarations` accessor-pair inference rule ("one annotated side is enough"). Previously, `collect_accessor_annotations` skipped any accessor with a `private` modifier, so the pairing never happened and `TS9009` fired on the untyped getter. This change: - No longer skips `private`-modifier accessors when collecting annotations for paired inference. - For private **setters**, collects the explicit parameter type annotation — same behavior as before for non-private setters (no body inference). - For private **getters**, only uses an explicit return type annotation. Running body inference would surface errors like `TS9038` on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway. ## Example ```ts export class MockProxy { get isRunning() { return this._state.isRunning; } private set isRunning(val: boolean) { this._state.isRunning = val; } } ``` Before: `TS9009: At least one accessor must have an explicit return type annotation`. After: no error — emits `get isRunning(): boolean;` and `private set isRunning(value);`, matching tsc. ## Test plan - [x] Added fixtures for both a public getter + private setter pair and a protected getter + private setter pair - [x] `cargo test -p oxc_isolated_declarations` — no regression on existing private-accessor snapshots Closes #21503 (case 2)
c05af7a to
db81c89
Compare
…paired inference (#21516) ## Summary A public (or protected) getter paired with a `private set(v: T)` should get its return type from the setter's parameter annotation — that's the standard `isolatedDeclarations` accessor-pair inference rule ("one annotated side is enough"). Previously, `collect_accessor_annotations` skipped any accessor with a `private` modifier, so the pairing never happened and `TS9009` fired on the untyped getter. This change: - No longer skips `private`-modifier accessors when collecting annotations for paired inference. - For private **setters**, collects the explicit parameter type annotation — same behavior as before for non-private setters (no body inference). - For private **getters**, only uses an explicit return type annotation. Running body inference would surface errors like `TS9038` on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway. ## Example ```ts export class MockProxy { get isRunning() { return this._state.isRunning; } private set isRunning(val: boolean) { this._state.isRunning = val; } } ``` Before: `TS9009: At least one accessor must have an explicit return type annotation`. After: no error — emits `get isRunning(): boolean;` and `private set isRunning(value);`, matching tsc. ## Test plan - [x] Added fixtures for both a public getter + private setter pair and a protected getter + private setter pair - [x] `cargo test -p oxc_isolated_declarations` — no regression on existing private-accessor snapshots Closes #21503 (case 2)
db81c89 to
065ce47
Compare
camc314
added a commit
that referenced
this pull request
Apr 20, 2026
### 🐛 Bug Fixes - 48967e8 isolated_declarations: Drop required type check for private parameter properties on private constructors (#21515) (Dunqing) - 91e5bde transformer/typescript: Preserve computed-key static block when class has an empty constructor (#21562) (Dunqing) - 50e9d26 mangler: Assign correct slot to shadowed function-expression names (#21535) (Dunqing) - 065ce47 isolated_declarations: Collect types from private accessors for paired inference (#21516) (Dunqing) - 00fc136 codegen: Preserve coverage comments before object properties (#21312) (bab) - d676e0c minifier: Mark LHS of `??=` as read when converting from `== null &&` (#21546) (Gunnlaugur Thor Briem) ### ⚡ Performance - e45efc5 parser: Reduce `try_parse` usage in favour of `lookahead` (#21532) (Boshen) - ddb1bf8 parser: Avoid redundant `IdentifierReference` clone in shorthand property (#21511) (Boshen) - be2b392 allocator: Store pointers directly in `Arena` (#21483) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com> Co-authored-by: Cameron <cameron.clark@hey.com>
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.

Summary
A public (or protected) getter paired with a
private set(v: T)should get its return type from the setter's parameter annotation — that's the standardisolatedDeclarationsaccessor-pair inference rule ("one annotated side is enough"). Previously,collect_accessor_annotationsskipped any accessor with aprivatemodifier, so the pairing never happened andTS9009fired on the untyped getter.This change:
private-modifier accessors when collecting annotations for paired inference.TS9038on the private accessor's body, which is irrelevant because the private accessor is emitted as a type-erased class member anyway.Example
Before:
TS9009: At least one accessor must have an explicit return type annotation.After: no error — emits
get isRunning(): boolean;andprivate set isRunning(value);, matching tsc.Test plan
cargo test -p oxc_isolated_declarations— no regression on existing private-accessor snapshotsCloses #21503 (case 2)