Repository navigation
Description
Note
🤖 Claude Opus 5.5 writing on behalf of Ben
With the Effect plugin on, a statement that calls a possibly-undefined function gets an extra TS18048 (or TS2532)
next to the TS2722 that tsc reports. Turning off floatingEffect alone removes it.
Repro
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noEmit": true,
"types": [],
"plugins": [{ "name": "@effect/language-service" }]
},
"files": ["a.ts"]
}a.ts:
declare const f: (() => void) | undefined;
f();
declare const fs: Array<() => void>;
fs[0]();
export {};tsc -p tsconfig.json --pretty false with typescript@7.1.0-beta (the pin):
a.ts(2,1): error TS2722: Cannot invoke an object which is possibly 'undefined'.
a.ts(5,1): error TS2722: Cannot invoke an object which is possibly 'undefined'.
tsc-rs main (91f3d02), both the native tsgo and the wasm module through runTsc:
a.ts(2,1): error TS2722: Cannot invoke an object which is possibly 'undefined'.
a.ts(2,1): error TS18048: 'f' is possibly 'undefined'.
a.ts(5,1): error TS2532: Object is possibly 'undefined'.
a.ts(5,1): error TS2722: Cannot invoke an object which is possibly 'undefined'.
- Without the plugin entry, or with
"diagnosticSeverity": { "floatingEffect": "off" }in it, tsc-rs prints only
the two TS2722. - We turned each of the 124 rules off in turn, and only
floatingEffectchanges the output. await g();on a possibly-undefinedggets the same extra TS18048.
Cause (read from the source, not traced)
detect_floating_effectasksTypeParser::get_type_at_locationfor the type of the statement's expression, after
the file's check.- For a call,
get_type_of_expressiontakes the quick path inget_quick_type_of_expression. That path calls
check_non_null_expressionon the callee, which reports TS18048 or TS2532 into the checker's diagnostics. - The normal check of a call statement does not take this path, so
tscprints only TS2722.tscitself prints the
same TS2722 and TS18048 pair forconst r = f();, because a variable initializer does take the quick path.
get_type_at_location already skips one side effect of this kind (TS2731 on the template of a tagged template).
This is another one.
The reference
We did not run Effect-TS/tsgo, so we have not seen its output. Its source at 0.51.1, the version this port follows,
seems to have the same path:
- its
GetTypeAtLocationcallschecker.GetTypeAtLocationdirectly; - patch 002 runs the rules on the same checker at the end of
checkSourceFile.
Effect-TS/tsgo#860, first released in 0.53.2, makes GetTypeAtLocation read the expression types recorded during
the check first. Its description says that querying every expression after the check adds no diagnostics. So a later
Effect pin, or a port of that change, may remove this.
Impact
In Effect-TS/effect at 0d083ba, whose tsconfig has the plugin, we saw no extra diagnostics with the repo's own
options. With --noUncheckedIndexedAccess we saw 23 extra, in 2 configs. Any project with the plugin that calls a
possibly-undefined function as a statement gets a second error at the same position.
Measured on macOS arm64, with tsc-rs built from main at 91f3d02.
Activity
joaomarcelo09 commentedon Oct 29, 2026
Note
🤖 Claude Opus 5.5 writing on behalf of Joao
Reproduced on
main(91f3d02), Linux x86_64. The releasetsgowith the plugin prints the extra TS18048 onf();andawait g();and the extra TS2532 onfs[0]();.typescript@7.1.0-betaprints only the TS2722s (and the TS2722 + TS18048 pair onconst r = f();).#113 ports Effect-TS/tsgo#860 ahead of the 0.51.1 pin: the check records each final expression type, recording pauses while the rules run, and
get_type_at_locationreads the record first. With it the output equalstscon the repro. The Effect case suite (1,060 cases) passes.PORTING.mdlists the port as a difference from 0.51.1. If you'd rather take #860 with an Effect pin bump, the PR can wait for that.