Skip to content

Connect prototype members across files - #480

Merged
eseliger merged 3 commits into
mainfrom
prototype-members
Oct 1, 2026
Merged

eseliger merged 3 commits into
mainfrom
prototype-members

Conversation

@eseliger

@eseliger eseliger commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

Treat object literals assigned to Constructor.prototype as members of the constructor when generating SCIP symbols. This gives the prototype object, method declarations, function-valued properties, and data properties stable constructor-owned symbols that connect to references in other files without dangling intermediate locals.

Fixes #409.

@eseliger eseliger changed the title prototype members Connect prototype members across files Aug 22, 2026
@eseliger
eseliger marked this pull request as ready for review August 22, 2026 23:32
@christoph-sg
christoph-sg force-pushed the prototype-members branch 2 times, most recently from c2f4bea to cc77479 Compare September 11, 2026 09:16
Base automatically changed from shorthand-properties to main September 11, 2026 09:44
@christoph-sg

Copy link
Copy Markdown
Contributor

This appears to cover only whole-object replacement (C.prototype = { ... }). The equally common C.prototype.method = function () {} and C.prototype.value = … forms still fall back to local symbols. Could we add cross-file snapshot cases for direct dot-property assignment and Object.assign(C.prototype, …)?

I think if we're doing this, we should also cover those common variants to avoid surprises (the first 5 in this table)

Pattern Covered?
C.prototype = { method: function () {} } Yes
C.prototype.method = function () {} No
C.prototype.value = 1 No
C.prototype["method"] = fn No
C["prototype"] = { method() {} } No
Object.assign(C.prototype, { method() {} }) No
Object.defineProperty(C.prototype, "method", …) No
C.prototype = Object.create(Base.prototype, …) No

Cover direct and bracket assignments and Object.defineProperty with stable constructor-owned symbols. Normalize literal member names and keep local owners out of shared caches.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0f298-28ec-7699-bc15-3ac5b66731e5
Co-authored-by: Amp <amp@ampcode.com>
@eseliger

Copy link
Copy Markdown
Member Author

Object.assign(C.prototype, { method() {} }) and C.prototype = Object.create(Base.prototype, …) don't seem to be supported by Typescript itself. We could implement this ourselves, but that's a bit more scope. I think covering the rest and being feature-equivalent would be a good win. WDYT? Pushed support for those.

@christoph-sg christoph-sg left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think covering the rest and being feature-equivalent would be a good win. WDYT? Pushed support for those.

Yeah that's exactly what I meant with

I think if we're doing this, we should also cover those common variants to avoid surprises (the first 5 in this table)

Thanks, this looks great!

@eseliger
eseliger merged commit 6d05447 into main Oct 1, 2026
6 of 7 checks passed
@eseliger
eseliger deleted the prototype-members branch October 1, 2026 08:24
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.

Cross file definition not connected

2 participants