TypeScript/tests/cases/fourslash/codeFixAddMissingMember19_declarePrivateMethod.ts
Alexander T 683b3ec058
feat(37782): 'declare method' quick fix for adding a private method (#37806)
* feat(37782): add quick-fix action to declare a private method for names that start from underscore

* better merge order in messages json

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-05-06 15:10:02 -07:00

30 lines
671 B
TypeScript

/// <reference path='fourslash.ts' />
////class A {
//// foo() {
//// this._bar();
//// }
////}
verify.codeFixAvailable([
{ description: "Declare private method '_bar'" },
{ description: "Declare method '_bar'" },
{ description: "Declare private property '_bar'" },
{ description: "Declare property '_bar'" },
{ description: "Add index signature for property '_bar'" }
])
verify.codeFix({
description: [ts.Diagnostics.Declare_private_method_0.message, "_bar"],
index: 0,
newFileContent:
`class A {
foo() {
this._bar();
}
private _bar() {
throw new Error("Method not implemented.");
}
}`
});