TypeScript/tests/cases/compiler/thisInPropertyBoundDeclarations.ts
2014-07-12 17:30:19 -07:00

67 lines
1.1 KiB
TypeScript

class Bug {
private name: string;
private static func: Function[] = [
(that: Bug, name: string) => {
that.foo(name);
}
];
private foo(name: string) {
this.name = name;
}
}
// Valid use of this in a property bound decl
class A {
prop1 = function() {
this;
};
prop2 = function() {
function inner() {
this;
}
() => this;
};
prop3 = () => {
function inner() {
this;
}
};
prop4 = {
a: function() { return this; },
};
prop5 = () => {
return {
a: function() { return this; },
};
};
}
class B {
prop1 = this;
prop2 = () => this;
prop3 = () => () => () => () => this;
prop4 = ' ' +
function() {
} +
' ' +
(() => () => () => this);
prop5 = {
a: () => { return this; }
};
prop6 = () => {
return {
a: () => { return this; }
};
};
}