diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index ebb58bae13c09..c83f5482198a3 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -225,6 +225,8 @@ export function addNewNodeForMemberSymbol( switch (kind) { case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, InternalNodeBuilderFlags.AllowUnresolvedNames, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyAssignment1.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyAssignment1.ts new file mode 100644 index 0000000000000..286e77d99657a --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyAssignment1.ts @@ -0,0 +1,30 @@ +/// + +//// const b = "foo"; +//// +//// const t = { +//// a: 1, +//// b, +//// }; +//// +//// type InferedT = typeof t; +//// +//// class InferedTClass implements InferedT {} + +verify.codeFix({ + description: "Implement interface 'InferedT'", + newFileContent: +`const b = "foo"; + +const t = { + a: 1, + b, +}; + +type InferedT = typeof t; + +class InferedTClass implements InferedT { + a: number; + b: string; +}`, +});