Skip to content

Commit 174e800

Browse files
committed
Fix missing properties codefix for property assignment declarations
1 parent 29e6d66 commit 174e800

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/services/codefixes/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ export function addNewNodeForMemberSymbol(
225225
switch (kind) {
226226
case SyntaxKind.PropertySignature:
227227
case SyntaxKind.PropertyDeclaration:
228+
case SyntaxKind.PropertyAssignment:
229+
case SyntaxKind.ShorthandPropertyAssignment:
228230
let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, InternalNodeBuilderFlags.AllowUnresolvedNames, getNoopSymbolTrackerWithResolver(context));
229231
if (importAdder) {
230232
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//// const b = "foo";
4+
////
5+
//// const t = {
6+
//// a: 1,
7+
//// b,
8+
//// };
9+
////
10+
//// type InferedT = typeof t;
11+
////
12+
//// class InferedTClass implements InferedT {}
13+
14+
verify.codeFix({
15+
description: "Implement interface 'InferedT'",
16+
newFileContent:
17+
`const b = "foo";
18+
19+
const t = {
20+
a: 1,
21+
b,
22+
};
23+
24+
type InferedT = typeof t;
25+
26+
class InferedTClass implements InferedT {
27+
a: number;
28+
b: string;
29+
}`,
30+
});

0 commit comments

Comments
 (0)