TypeScript Version
- tsc 6.0.2
- tsgo 7.0.0-dev.20260421.2
Search Terms
for...of, @ts-ignore, TS2488, TS2339, error recovery, parity
Code
type A = {
a: string
}
type B = {
b: string
}
declare const data: A[] | B
// @ts-ignore
for (const item of data) {
item.b
}
Commands
tsc --ignoreConfig --noEmit --strict --target es2022 case4.ts
tsc --ignoreConfig --noEmit --strict --target es2022 --stableTypeOrdering case4.ts
tsgo --ignoreConfig --noEmit --strict --target es2022 case4.ts
Expected Behavior
tsgo should match tsc 6.0.2 here.
With the @ts-ignore on the for...of line, tsc 6.0.2 reports no errors, including with --stableTypeOrdering.
Actual Behavior
tsgo reports:
case4.ts(13,8): error TS2339: Property 'b' does not exist on type 'A'.
Additional Notes
If I remove the @ts-ignore, tsc 6.0.2 reports only the for...of error (TS2488), while tsgo reports both the TS2488 and the downstream TS2339 in the loop body.
So this appears to be a parity difference in error recovery or loop variable typing after an invalid for...of.
TypeScript Version
Search Terms
for...of, @ts-ignore, TS2488, TS2339, error recovery, parity
Code
Commands
Expected Behavior
tsgoshould matchtsc6.0.2 here.With the
@ts-ignoreon thefor...ofline,tsc6.0.2 reports no errors, including with--stableTypeOrdering.Actual Behavior
tsgoreports:Additional Notes
If I remove the
@ts-ignore,tsc6.0.2 reports only thefor...oferror (TS2488), whiletsgoreports both theTS2488and the downstreamTS2339in the loop body.So this appears to be a parity difference in error recovery or loop variable typing after an invalid
for...of.