[PR #4423] [CLOSED] fix(javascript): keep TypeScript parameter properties as declarations (#4371) #6231

Closed
opened 2026-10-31 01:12:53 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4423
Author: @DeryFerd
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/4371-typescript-parameter-property-reads


📝 Commits (1)

  • 972a53f fix(javascript): keep TypeScript parameter properties as declarations

📊 Changes

2 files changed (+56 additions, -0 deletions)

View changed files

📝 src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts (+41 -0)
📝 src/domain/javascript/javascriptSemanticProjection.ts (+15 -0)

📄 Description

Summary

A constructor parameter property such as constructor(public x: number) {} was emitted as an x:read reference in the semantic IR even though the constructor body never reads it. The parameter binding is recorded through the TSParameterProperty wrapper, but reference-role classification did not unwrap that wrapper, so the declaration fell through to the default read role. The initialized form public x = 1 was affected the same way through its AssignmentPattern. Both forms are now recognized as declarations, and the actual reads in the controls are unchanged.

Fixes #4371.

Problem and expected behavior

The smallest trigger is a valid TypeScript class whose constructor declares a parameter property and does not read it. For class C { constructor(public x: number) {} } the reference collector produced one x:read at the declaration, while the ordinary control constructor(x: number) {} produced none. The same happened for constructor(public x = 1) {}.

The violated invariant is that a declaration must not be reported as an identifier read. The expected behavior is that the parameter-property declaration emits no reference, that a real body read still emits one read, and that a default-value read such as constructor(public x = seed) {} still emits exactly one seed:read.

Change and scope

src/domain/javascript/javascriptSemanticProjection.ts now recognizes the TSParameterProperty wrapper in two places that together cover both spellings. isDeclarationIdentifier unwraps the wrapper when the identifier's parent is the TSParameterProperty itself (the typed form public x: number). isPatternOwnerDeclaration treats a TSParameterProperty as a pattern-owning declaration, which covers the AssignmentPattern parent produced by the initialized form public x = 1. A small parameterPropertyBinds helper decides whether the wrapper's inner pattern binds the identifier.

The change mirrors the existing parameter-binding collector in javascriptSemanticAnalysis.ts, which already unwraps TSParameterProperty when it records the binding. It does not change how bindings are created, does not touch reference collection for other syntax, and does not alter body reads or default-value reads.

Contract and boundary impact

  • Semantic owner and earliest changed stage: semantic reference-role classification in src/domain/javascript/javascriptSemanticProjection.ts; the earliest changed stage is identifier-role assignment during reference collection.
  • Contribution scope fit and linked maintainer decision: ordinary defect fix within the existing semantic-analysis boundary; a separate maintainer scope decision is not applicable.
  • CLI and MCP/tool-catalog contract: no tool, schema, or catalog change; the fix corrects the references carried in the existing semantic IR.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: reference roles and locations remain the recorded facts; only the spurious declaration read is removed. No inferred value or new observation is introduced.
  • Target selection, authority, upstream behavior, and cleanup details: inert source analysis only; no target execution, injection, mutation, or cleanup change.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts gains three cases. A table-driven case asserts no x reference for the typed and initialized parameter-property declarations. A control case asserts the initialized form constructor(public x = seed) {} still emits one seed:read, and that constructor(x: number) { console.log(x); } still emits one x:read.
  • Base reproduction or other evidence: the report's source-boundary script was reproduced at the current main revision. Before the fix the two parameter-property inputs emitted x:read and the ordinary declaration control emitted none; after the fix the parameter-property declarations emit none while the controls keep their single reads.
  • User-visible CLI/MCP output (if applicable): not applicable; this is semantic IR consumed by application analysis, and the CLI/MCP projection was not run.
  • Remaining proof gaps: the report is source-only with respect to the public CLI/MCP workflows, and this change is verified at the semantic-analysis boundary. The application/CLI projection of these references was not executed. Other TypeScript declaration wrappers were not surveyed.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts --project domain — 75 passed, including the three new cases.
  • Red-green check — reverting javascriptSemanticProjection.ts makes the new parameter-property cases fail with the spurious x:read; restoring it makes all 75 pass. Removing either recognition site alone leaves the typed form failing, confirming both are needed.
  • npx vitest run src/domain/javascript/ --project domain — 79 files, 1932 tests passed.
  • npx oxlint on both changed files — 0 errors.
  • npx oxfmt --check on both changed files — format clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. The change removes a false reference; it does not change any public input or output contract shape.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; pure source analysis.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: inert parsing and reference classification only; no execution, network, or filesystem change.

Author readiness

Human owner: @DeryFerd

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4423 **Author:** [@DeryFerd](https://github.com/DeryFerd) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/4371-typescript-parameter-property-reads` --- ### 📝 Commits (1) - [`972a53f`](https://github.com/morluto/rea/commit/972a53fa14f4759b01abfe7e61f2b29a26c77b45) fix(javascript): keep TypeScript parameter properties as declarations ### 📊 Changes **2 files changed** (+56 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` (+41 -0) 📝 `src/domain/javascript/javascriptSemanticProjection.ts` (+15 -0) </details> ### 📄 Description ## Summary A constructor parameter property such as `constructor(public x: number) {}` was emitted as an `x:read` reference in the semantic IR even though the constructor body never reads it. The parameter binding is recorded through the `TSParameterProperty` wrapper, but reference-role classification did not unwrap that wrapper, so the declaration fell through to the default `read` role. The initialized form `public x = 1` was affected the same way through its `AssignmentPattern`. Both forms are now recognized as declarations, and the actual reads in the controls are unchanged. Fixes #4371. ## Problem and expected behavior The smallest trigger is a valid TypeScript class whose constructor declares a parameter property and does not read it. For `class C { constructor(public x: number) {} }` the reference collector produced one `x:read` at the declaration, while the ordinary control `constructor(x: number) {}` produced none. The same happened for `constructor(public x = 1) {}`. The violated invariant is that a declaration must not be reported as an identifier read. The expected behavior is that the parameter-property declaration emits no reference, that a real body read still emits one `read`, and that a default-value read such as `constructor(public x = seed) {}` still emits exactly one `seed:read`. ## Change and scope `src/domain/javascript/javascriptSemanticProjection.ts` now recognizes the `TSParameterProperty` wrapper in two places that together cover both spellings. `isDeclarationIdentifier` unwraps the wrapper when the identifier's parent is the `TSParameterProperty` itself (the typed form `public x: number`). `isPatternOwnerDeclaration` treats a `TSParameterProperty` as a pattern-owning declaration, which covers the `AssignmentPattern` parent produced by the initialized form `public x = 1`. A small `parameterPropertyBinds` helper decides whether the wrapper's inner pattern binds the identifier. The change mirrors the existing parameter-binding collector in `javascriptSemanticAnalysis.ts`, which already unwraps `TSParameterProperty` when it records the binding. It does not change how bindings are created, does not touch reference collection for other syntax, and does not alter body reads or default-value reads. ## Contract and boundary impact - Semantic owner and earliest changed stage: semantic reference-role classification in `src/domain/javascript/javascriptSemanticProjection.ts`; the earliest changed stage is identifier-role assignment during reference collection. - Contribution scope fit and linked maintainer decision: ordinary defect fix within the existing semantic-analysis boundary; a separate maintainer scope decision is not applicable. - CLI and MCP/tool-catalog contract: no tool, schema, or catalog change; the fix corrects the references carried in the existing semantic IR. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: reference roles and locations remain the recorded facts; only the spurious declaration read is removed. No inferred value or new observation is introduced. - Target selection, authority, upstream behavior, and cleanup details: inert source analysis only; no target execution, injection, mutation, or cleanup change. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` gains three cases. A table-driven case asserts no `x` reference for the typed and initialized parameter-property declarations. A control case asserts the initialized form `constructor(public x = seed) {}` still emits one `seed:read`, and that `constructor(x: number) { console.log(x); }` still emits one `x:read`. - Base reproduction or other evidence: the report's source-boundary script was reproduced at the current main revision. Before the fix the two parameter-property inputs emitted `x:read` and the ordinary declaration control emitted none; after the fix the parameter-property declarations emit none while the controls keep their single reads. - User-visible CLI/MCP output (if applicable): not applicable; this is semantic IR consumed by application analysis, and the CLI/MCP projection was not run. - Remaining proof gaps: the report is source-only with respect to the public CLI/MCP workflows, and this change is verified at the semantic-analysis boundary. The application/CLI projection of these references was not executed. Other TypeScript declaration wrappers were not surveyed. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts --project domain` — 75 passed, including the three new cases. - Red-green check — reverting `javascriptSemanticProjection.ts` makes the new parameter-property cases fail with the spurious `x:read`; restoring it makes all 75 pass. Removing either recognition site alone leaves the typed form failing, confirming both are needed. - `npx vitest run src/domain/javascript/ --project domain` — 79 files, 1932 tests passed. - `npx oxlint` on both changed files — 0 errors. - `npx oxfmt --check` on both changed files — format clean. ## Compatibility, safety, and release - Breaking changes or migration steps: none. The change removes a false reference; it does not change any public input or output contract shape. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; pure source analysis. - Package or release metadata impact: none. - Security, privacy, process, or containment review: inert parsing and reference classification only; no execution, network, or filesystem change. ## Author readiness Human owner: @DeryFerd - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6231
No description provided.