mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Merge pull request #17252 from Microsoft/contextually-type-this-in-object-literals-in-javascript
Contextually type this in object literals in JS
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @Filename: context.js
|
||||
const obj = {
|
||||
prop: 2,
|
||||
method() {
|
||||
this;
|
||||
this.prop;
|
||||
this.method;
|
||||
this.unknown; // ok, obj has a string indexer
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user