diff --git a/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt b/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt new file mode 100644 index 00000000000..6f25f2d3a08 --- /dev/null +++ b/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/noImplicitThisObjectLiterals.ts(2,8): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisObjectLiterals.ts(4,16): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisObjectLiterals.ts(7,16): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + +==== tests/cases/compiler/noImplicitThisObjectLiterals.ts (3 errors) ==== + let o = { + d: this, // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + m() { + return this.d.length; // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }, + f: function() { + return this.d.length; // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitThisObjectLiterals.js b/tests/baselines/reference/noImplicitThisObjectLiterals.js new file mode 100644 index 00000000000..3888708a8da --- /dev/null +++ b/tests/baselines/reference/noImplicitThisObjectLiterals.js @@ -0,0 +1,22 @@ +//// [noImplicitThisObjectLiterals.ts] +let o = { + d: this, // error, this: any + m() { + return this.d.length; // error, this: any + }, + f: function() { + return this.d.length; // error, this: any + } +} + + +//// [noImplicitThisObjectLiterals.js] +var o = { + d: this, + m: function () { + return this.d.length; // error, this: any + }, + f: function () { + return this.d.length; // error, this: any + } +}; diff --git a/tests/cases/compiler/noImplicitThisObjectLiterals.ts b/tests/cases/compiler/noImplicitThisObjectLiterals.ts new file mode 100644 index 00000000000..abd5d9dcfba --- /dev/null +++ b/tests/cases/compiler/noImplicitThisObjectLiterals.ts @@ -0,0 +1,10 @@ +// @noImplicitThis: true +let o = { + d: this, // error, this: any + m() { + return this.d.length; // error, this: any + }, + f: function() { + return this.d.length; // error, this: any + } +}