Files
ValueScript/inputs/passing/const/violateWithCustomMethodNested.ts
2023-04-05 10:15:19 +10:00

21 lines
312 B
TypeScript

// test_output! E: TypeError{"message":"Cannot mutate this because it is const"}
export default function () {
const foo = new Foo();
foo.callInc(); // Should throw
return foo.x;
}
class Foo {
x = 0;
inc() {
this.x++;
}
callInc() {
this.inc(); // Needs to propagate the constness
}
}