TypeScript: a local initialized from a library call takes the one-method guess (follow-up to #2589)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, react, typescript
- Ambito
- devtools
Direzione di ricerca
Reproduce the five functions from the issue in a TypeScript fixture and run the resolver with CODEGRAPH_KERNEL=0, then trace where a local initialized from an outside-project call is assigned the single same-named project method. Compare that path with the annotated-local handling from #2589/#2811 and the outside-type rule in #2169; the fix belongs there, not in variable-name heuristics. Done means a-d emit no instance-method edge while existing project-local cases still resolve, with coverage for package imports, node: namespaces and DOM-typed receivers.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Follow-up to #2589. A method call on an untyped local initialized from a library call still links to the project's only method with that name. #2811 fixed this for a class component's render() and lifecycle methods, but an ordinary class method is still guessed.
// app.ts
export class App { render(): void {} translate(x: number): void {} close(): void {} }
// use.ts
import { createRoot } from 'react-dom/client';
import * as net from 'net';
import { createServer } from 'net';
export function a(el: HTMLElement) { const root = createRoot(el); root.render(null); }
export function b() { const s = net.createServer(); s.close(); }
export function c() { const s = createServer(); s.close(); }
export function d(canvas: HTMLCanvasElement) { const ctx = canvas.getContext('2d')!; ctx.translate(1); }
export function e(canvas: HTMLCanvasElement) { canvas.getContext('2d')!.translate(1); }
| function | edge on main |
expected |
|---|---|---|
a |
App.render (instance-method) |
none |
b |
App.close |
none |
c |
App.close |
none |
d |
App.translate |
none |
e (chained, no local) |
none | none |
Renaming the locals doesn't change anything, so this isn't the variable-name guess in #2946. The chained form e already links nothing; only the assigned local takes the guess. In each case the local's value comes from something the project doesn't declare: a package import, a node: namespace, or a method on a DOM-typed parameter. That fits #2169's "an outside type is not a project type" rule, but the type is never written down, so the rule doesn't fire.
Reproduced on main at 31ec9082 (6162d872 since then only touches the watcher), with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
Scale (found by checking every TS calls edge against the TypeScript checker). On excalidraw (14bb42e), 63 instance-method edges land on project code where tsc says the method is a library one. For example, every context.translate(…) on a canvas.getContext("2d")! local, as in packages/element/src/renderElement.ts, links to App.translate in packages/excalidraw/components/App.viewport.ts. On this repo there are 58. For example, server.close() on net.createServer(…) in __tests__/cli-unlock.test.ts links to the close() of the viewer's server interface in src/ui-server/index.ts. The interface method gets callers it never has.
Possible direction (not verified). When the local's initializer is a call whose callee resolves outside the project (an import from a package or node:, or a member of a receiver already typed as an outside type), treat the local as outside-typed: the same "no guess" outcome as an annotated const r: Root = createRoot(el) in #2589. #2152 has PHP's version of this ("an untyped receiver keeps a unique method only when named for it").
Related: #2589, #2811, #2169, #2946.
- Lingua principale
- C
- Stelle
- 73.2k
- Fork
- 4.7k
- Merge medio
- 3h 13m
- PR unite (30g)
- 579
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di colbymchenry/codegraph
-
mcp: a projectPath naming a file inside a project returns isError ("Path is not a directory")Forse già presa @maxmilian l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
colbymchenry/codegraph#2982 ·
I maintainer di solito rispondono entro 1 giorno
-
mcp: a non-object tools/call arguments crashes the handler and is reported as an internal error to retryForse già presa @kjgggggg l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
colbymchenry/codegraph#2981 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
colbymchenry/codegraph#2974 ·
I maintainer di solito rispondono entro 1 giorno
-
search: FTS special characters are deleted, not separated, so leaf(entry) matches nothingForse già presa @kjgggggg l’ha presa 1 giorno fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
colbymchenry/codegraph#2971 ·
I maintainer di solito rispondono entro 1 giorno
-
[Security Vulnerabiliy] Vulnerable bundled `node.exe` detected (Node2Shell - CVE-2026-111497)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
colbymchenry/codegraph#2959 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di colbymchenry/codegraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
InukaAsith/TwinDesk#84 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CanadaHonk/porffor#426 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
FujiNetWIFI/fujinet-firmware#2221 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
raysan5/raylib.com#132 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100