Skip to content

Commit becccb6

Browse files
committed
fix(ts): don't emit a JSX-import resolution for an unresolved relative path
For a JSX component imported by a relative specifier (`import { Widget } from "./widget"`), the per-file pass emitted lsp_ts_jsx_import with the raw specifier as the module QN ("./widget.Widget"). That QN matches no node, but — winning the exact-equality/confidence join over the cross-file pass's correct resolution (equal confidence, emitted first) — it dropped the edge, so the strategy was absent. The cross-file pass re-runs with the specifier resolved to the real module QN and emits the correct "<proj>.widget.Widget" resolution. Skip the per-file emission for relative specifiers (mark unresolved) so the cross-file resolution stands. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 0366dfe commit becccb6

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎internal/cbm/lsp/ts_lsp.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,16 @@ static void resolve_jsx_element(TSLSPContext *ctx, TSNode element_node) {
26532653
const char *lname = ctx->import_local_names ? ctx->import_local_names[i] : NULL;
26542654
const char *mqn = ctx->import_module_qns ? ctx->import_module_qns[i] : NULL;
26552655
if (lname && mqn && strcmp(lname, tag_name) == 0) {
2656+
/* A relative module path ("./widget") is unresolved at the per-file
2657+
* stage — it is the raw specifier, not a module QN, so "./widget.Widget"
2658+
* matches no node and (winning the join on equal confidence) would drop
2659+
* the edge. The cross-file pass re-runs with the path resolved to the
2660+
* real module QN and emits the correct resolution, so skip the per-file
2661+
* emission for relative specifiers and let that one stand. */
2662+
if (mqn[0] == '.') {
2663+
ts_emit_unresolved_call(ctx, tag_name, "jsx_import_unresolved_path");
2664+
return;
2665+
}
26562666
const char *qn = cbm_arena_sprintf(ctx->arena, "%s.%s", mqn, tag_name);
26572667
ts_emit_resolved_call(ctx, qn, "lsp_ts_jsx_import", 0.85f);
26582668
return;

0 commit comments

Comments
 (0)