mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 19:27:35 -06:00
Add --noImplicitThis test for object literals
This commit is contained in:
parent
0a2ba0cc15
commit
8d45a73f12
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
22
tests/baselines/reference/noImplicitThisObjectLiterals.js
Normal file
22
tests/baselines/reference/noImplicitThisObjectLiterals.js
Normal file
@ -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
|
||||
}
|
||||
};
|
||||
10
tests/cases/compiler/noImplicitThisObjectLiterals.ts
Normal file
10
tests/cases/compiler/noImplicitThisObjectLiterals.ts
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user