Files
scriptc/tests/coverage-fixtures/mixed.ts
T
Malte UblandClaude Opus 5.5 f2b8162a6d Keep the coverage fixture's blocker refused now that array position patterns compile
tests/coverage-fixtures/mixed.ts used `const { length: firstItem } = items`
as its SC1031 example. Object patterns of positions and length over arrays
compile now, so coverage counted 13/13 static. The example now destructures
a union source (array | string), which keeps the SC1031 object-pattern fence
at the same line and column; only the message's source kind changes, from
array-typed to union-typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 10:19:59 -07:00

18 lines
573 B
TypeScript

function score(n: number): number {
let total = 0;
for (let i = 0; i < n; i++) {
total += i % 3 === 0 ? 2 : 1;
}
return total;
}
const items = [1, 2, 3];
const handler = (x: number) => x * 2;
const anyone: unknown = score(1);
const flags = anyone == score(2); // unknown/object coercion keeps the fence; static primitive pairs lower
const { length: firstItem } = score(3) > 99 ? items : "abc"; // a union source keeps the object-pattern fence (narrow first)
let label = "score: ";
label += score(10);
console.log(label);
console.log(items.length, handler(2));