TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_functionDeclaration.ts
Andy Hanson b0450aed56
Add codefix for --noImplicitThis (#27565)
* Add codefix for --noImplicitThis

* Code review

* Back to building post-merge

* Remove redundant functions + update tests

Infer-from-usage also inserts `this: any` parameters when needed, so I
removed that from fixImplicitThis.

Otherwise, fixImplicitThis has better suggestions than inferFromUsage,
so I moved inferFromUsage later in the suggestion order.

* More redundancy removal

Don't need to add `@this` anymore either since inferFromUsage will do
that.

* More baseline updates

From moving inferFromUsage down in priority I think?

* remove now-redundant ad-hoc jsdoc emit

* fix more bad merge

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-17 13:00:14 -07:00

27 lines
464 B
TypeScript

/// <reference path='fourslash.ts' />
// @noImplicitThis: true
////class C {
//// m() {
//// function f() {
//// this;
//// f(); // self-reference OK
//// }
//// }
////}
verify.codeFix({
description: "Convert function declaration 'f' to arrow function",
index: 0,
newFileContent:
`class C {
m() {
const f = () => {
this;
f(); // self-reference OK
}
}
}`,
});