This code runs fine with no errors, and passes deno lint. But vscode red-squigglies
line 17 with a deno-ts(2367) error. Apparently the throw in the line above
convinces the parser that the array length is exactly five, and ignores that a.clear()
has changed it to zero.
class A {
public a: number[] = [];
constructor(s: number) {
this.a = new Array(s).fill(0);
}
public clear() {
this.a.splice(0, this.a.length);
}
}
function run() {
const x = new A(5);
if (5 !== x.a.length) throw new Error("oops");
x.clear();
if (0 !== x.a.length) throw new Error("oops");
}
run();
I can see how trying to catch the side effects of every call might be too much to ask
for the parser, but is there a way I can suppress the red squiggly?
This code runs fine with no errors, and passes deno lint. But vscode red-squigglies line 17 with a deno-ts(2367) error. Apparently the throw in the line above convinces the parser that the array length is exactly five, and ignores that a.clear() has changed it to zero.
I can see how trying to catch the side effects of every call might be too much to ask for the parser, but is there a way I can suppress the red squiggly?
Screenshot:
vscode: 1.92.1 deno: 1.45.5 extension: 3.38.2