From d13af64bde925487932e1a1ea39276ec8de66a49 Mon Sep 17 00:00:00 2001 From: Felipe Armoni Date: Tue, 15 Feb 2022 21:09:01 +0000 Subject: [PATCH] Fix 47746 - Missing properties quickfix does not handle generic parameters (#47790) * Added test * Added extra test case --- .../codeFixAddMissingProperties17.ts | 16 +++++++++++++++ .../codeFixAddMissingProperties18.ts | 20 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/cases/fourslash/codeFixAddMissingProperties17.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingProperties18.ts diff --git a/tests/cases/fourslash/codeFixAddMissingProperties17.ts b/tests/cases/fourslash/codeFixAddMissingProperties17.ts new file mode 100644 index 0000000000000..3f1cb6ade3af7 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingProperties17.ts @@ -0,0 +1,16 @@ +/// + +////interface Foo { +//// foo(): T; +////} +////[|const x: Foo = {};|] + +verify.codeFix({ + index: 0, + description: ts.Diagnostics.Add_missing_properties.message, + newRangeContent: `const x: Foo = { + foo: function(): string { + throw new Error("Function not implemented."); + } +};`, +}); diff --git a/tests/cases/fourslash/codeFixAddMissingProperties18.ts b/tests/cases/fourslash/codeFixAddMissingProperties18.ts new file mode 100644 index 0000000000000..53629b59c7b79 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingProperties18.ts @@ -0,0 +1,20 @@ +/// + +////interface Bar { +//// a: number; +////} +//// +////interface Foo { +//// foo(a: T): U; +////} +////[|const x: Foo = {};|] + +verify.codeFix({ + index: 0, + description: ts.Diagnostics.Add_missing_properties.message, + newRangeContent: `const x: Foo = { + foo: function(a: string): Bar { + throw new Error("Function not implemented."); + } +};`, +});