TypeScript/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts
Anders Hejlsberg ec292c92e2 Update test
2017-02-22 19:25:19 -08:00

20 lines
379 B
TypeScript

// @noImplicitAny: true
// @noImplicitThis: true
// @target: es5
interface Foo {
n: number;
x: number;
}
interface Bar {
wrong: "place" | "time" | "method" | "technique";
}
const mismatch = {
n: 13,
get x(this: Foo) { return this.n; },
set x(this: Bar, n) { this.wrong = "method"; }
}
const contextual: Foo = {
n: 16,
get x() { return this.n; }
}