Skip to content

fix(effect): rule type queries read the types the check recorded (#112) - #113

Open
joaomarcelo09 wants to merge 1 commit into
pingdotgg:mainfrom
joaomarcelo09:fix-effect-floating-type-query
Open

joaomarcelo09 wants to merge 1 commit into
pingdotgg:mainfrom
joaomarcelo09:fix-effect-floating-type-query

Conversation

@joaomarcelo09

@joaomarcelo09 joaomarcelo09 commented Oct 29, 2026 •

Copy link
Copy Markdown

Note

🤖 Claude Opus 5.5 writing on behalf of Joao

Fixes #112.

Problem

With the Effect plugin, a statement that calls a possibly-undefined function gets a TS18048 or TS2532 next to the TS2722 that tsc reports. floatingEffect asks TypeParser::get_type_at_location for the statement's type after the file's check. For a call, the checker's quick path (get_quick_type_of_expression) runs check_non_null_expression on the callee, and that reports the extra diagnostic.

Fix

A port of Effect-TS/tsgo#860 (first released in @effect/tsgo@0.53.2), ahead of the 0.51.1 pin:

  • checker/checker_p09.rs: exit_check_expression calls record_checked_expression_type (patch 033 ExpressionCheckedCallback). It runs only when the program has Effect options, as patch 004 does for relation errors.
  • effect/typeparser/checked_expression_types.rs (Go checked_expression_types.go): records final-mode results (Normal, or Contextual alone) while a file is checked, pause_checked_expression_types, and checked_expression_type, which reads the record, then the checker's resolved_type cache.
  • effect/mod.rs: after_check_source_file pauses recording while the rules run (Go defer typeparser.PauseCheckedExpressionTypes(c)()).
  • effect/typeparser/get_type_at_location.rs: reads checked_expression_type before it asks the checker.
  • effect/PORTING.md: lists this as a difference from 0.51.1.

The checker's own output does not change. Without the plugin no type is recorded.

Measured

Repro (the issue's, plus await g() and an initializer, where tsc itself reports the pair):

declare const f: (() => void) | undefined;
f();
declare const fs: Array<() => void>;
fs[0]();
declare const g: (() => Promise<void>) | undefined;
export async function h() { await g(); }
const r = f();
Output with the plugin
typescript@7.1.0-beta tsc 5 errors: TS2722 ×4, TS18048 on const r = f()
tsc-rs main (91f3d02) 8 errors: the same 5, plus TS18048 on f(), TS2532 on fs[0]() and TS18048 on await g()
This branch 5 errors, equal to tsc
  • New test tests/tsgo_effect_type_query.rs: the repro with and without the plugin, against the tsc output.
  • cargo test --release -p ts_goport --test effect_cases: 1,060 passed, 0 failed.
  • cargo clippy on the new test and rustfmt --edition 2024 on the changed files are clean.

Not run: the goport protected set (goport tests, gate, bound runs, LSP and API oracles). It needs the Blacksmith testboxes and hosts that a fork cannot use. Built on Arch Linux x86_64 with Rust 1.95.0 (stable, no nightly).


Ported and tested by Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…gdotgg#112)

With the Effect plugin, floatingEffect asked the checker for the type of a
call statement after the file's check. The checker's quick path for a call
(get_quick_type_of_expression) runs check_non_null_expression on the callee,
which added a TS18048 or TS2532 next to the TS2722 that tsc reports.

Port Effect-TS/tsgo#860 (first released in @effect/tsgo@0.53.2) ahead of the
0.51.1 pin: exit_check_expression records the final expression types of the
file's check (patch 033), after_check_source_file pauses recording while the
rules run, and get_type_at_location reads the record first. PORTING.md lists
the difference from 0.51.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7a5c0e67-5eea-4e0a-9df6-a82590178c4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

Effect plugin: floatingEffect's type query adds TS18048/TS2532 next to TS2722

1 participant