Repository navigation
fix(resolution): a TS local set by a member call on an imported const takes the type the member returns - #3616
Open
inth3shadows wants to merge 1 commit into
Conversation
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Dec 3, 2026
# Conflicts: # CHANGELOG.md
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Dec 3, 2026
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Dec 4, 2026
README: kept both fork-carries entries (colbymchenry#3616 and #26).
… takes the type the member returns (colbymchenry#3572) const parent = client.create({}); parent.extend({}) linked parent.extend to Client::extend only when client was a parameter or a const of the same file (colbymchenry#3422). A const the file imports from a project module is now read where it is declared: the type written on it, with its names resolved in that file, including a capitalized const (API.create()). A let or var, a const with nothing written that says its value, and an import from a package are read as before. The const's file is recorded for a sync, and what an import resolves to and what a const's declaration says are each read once per pass.
inth3shadows
force-pushed
the
fix/3572-imported-const-method-result
branch
from
December 4, 2026 23:17
9d4e852 to
d9242f3
Compare
This branch has not been deployed
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.
Fixes #3572
What
const parent = client.create({}); parent.extend({}), whereclientis a const imported from another file (export const client: Client = makeClient()), now linksparent.extendtoClient::extend, as it already did since #3422 whenclientis a parameter or a const of the same file. Before,parentgot no type, so the call linked only whenextendwas the one method of that name in the project.How
tsValueType(name-matcher.ts#L28203) read the receiver only from a binding in the call's own file. When there is none and the file imports the name, it now follows that import to the project's top-levelconstand reads what its declaration says, in the declaring file: the type written on it, with the names in that type resolved there. Then it carries on as for a same-file const. This covers a capitalized const too (API.create()), which before stopped at the check for a class of that name.constis read. Aletorvarthe module may reassign, a const with nothing written that says its value, and an import from a package are read as before.Designs tried and dropped during review on this branch:
Measured (base
8ef378de66e65a7d4986d53ae7b8d86cfc4118afvs this branch, Node 22.23.2, Linux x64,CODEGRAPH_KERNEL=0)ts-member-call-result-types.test.ts, which passes 11/11. Onmainthe 5 bug tests fail and the other 6 pass, among them the new case that an imported const with no type and a typedletare read as before.compare-graphs.mjsagainst73cd6e48, with the kernel and withCODEGRAPH_KERNEL=0): 0 changed lines.main5.8 s / 5.6 s, this branch 6.9 s / 6.6 s.main15.6 s, this branch 21.5 s.p.extend()) thatmainleaves to the name match.main11.9 s / 11.5 s, this branch 10.6 s / 10.1 s.npm run gate, native kernel built, on the rebased tree):PASS: 174 projects, 171 growth cases.73cd6e48847850ede14554b9b84e04e9f2d4dc2f): 13,689 passed, 0 failed, 2 expected fail. Platforms run: Linux x64; not tested on: macOS, Windows.8ef378de66e65a7d4986d53ae7b8d86cfc4118af, before the rebase onto73cd6e48847850ede14554b9b84e04e9f2d4dc2f(fix(rust): indexing no longer hangs on uses that start with their own name #3611), where only the changelog conflicted. The suite, gate and real-repo diff were run again on the rebased tree. The last change before measuring (reading each import once per file) was checked by the gate and the full suite, not by a further review round.Checked with graph-assay
I maintain graph-assay. Its fixture
issue-3572, the issue's own files, goes from BROKEN onmain(73cd6e48847850ede14554b9b84e04e9f2d4dc2f) to FIXED on this branch. No other fixture verdict changed. Side effects: none on the measured repos.Rerun:
node bin/graph-assay replay <this branch>/dist/bin/codegraph.js issue-3572Known limits
get: () => Responsebecomingget: () => Body) takes effect when the call's own file is indexed again. A local receiver onmainhas the same one-file wait.type R = LocalbecomingLocal2).maindoes the same for a local receiver.maindoes the same for the first call on it.ns.client.create()) is read as before.Edit (2026-12-03): the suite, the gate and the real-repo diff were run again on the rebased tree; the Measured numbers above are from that run.
Edit (2026-12-03): added the graph-assay section, after its fixture for this issue merged.