From b0de80f07efb9e6f1ddde1f7e2b471a47f9ec212 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 24 May 2017 08:14:52 -0700 Subject: [PATCH] Set '.declarations' on a property of a homomorphic mapped type --- src/compiler/checker.ts | 1 + .../server/quickInfoMappedSpreadTypes.ts | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/cases/fourslash/server/quickInfoMappedSpreadTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce982a113f2..e3aedd5fe51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5690,6 +5690,7 @@ namespace ts { prop.type = propType; if (propertySymbol) { prop.syntheticOrigin = propertySymbol; + prop.declarations = propertySymbol.declarations; } members.set(propName, prop); } diff --git a/tests/cases/fourslash/server/quickInfoMappedSpreadTypes.ts b/tests/cases/fourslash/server/quickInfoMappedSpreadTypes.ts new file mode 100644 index 00000000000..2a0c1668763 --- /dev/null +++ b/tests/cases/fourslash/server/quickInfoMappedSpreadTypes.ts @@ -0,0 +1,30 @@ +/// + +////interface Foo { +//// /** Doc */ +//// bar: number; +////} +//// +////const f: Foo = { bar: 0 }; +////f./*f*/bar; +//// +////const f2: { [TKey in keyof Foo]: string } = { bar: "0" }; +////f2./*f2*/bar; +//// +////const f3 = { ...f }; +////f3./*f3*/bar; +//// +////const f4 = { ...f2 }; +////f4./*f4*/bar; + +goTo.marker("f"); +verify.quickInfoIs("(property) Foo.bar: number", "Doc "); + +goTo.marker("f2"); +verify.quickInfoIs("(property) bar: string", "Doc "); + +goTo.marker("f3"); +verify.quickInfoIs("(property) Foo.bar: number", "Doc "); + +goTo.marker("f4"); +verify.quickInfoIs("(property) bar: string", "Doc ");