diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts
index 40cb2826b8ff6..18028db1ef7d3 100644
--- a/src/services/symbolDisplay.ts
+++ b/src/services/symbolDisplay.ts
@@ -584,6 +584,19 @@ namespace ts.SymbolDisplay {
}
}
+ if (documentation.length === 0 && isIdentifier(location) && symbol.valueDeclaration && isBindingElement(symbol.valueDeclaration)) {
+ const declaration = symbol.valueDeclaration;
+ const parent = declaration.parent;
+ if (isIdentifier(declaration.name) && isObjectBindingPattern(parent)) {
+ const name = getTextOfIdentifierOrLiteral(declaration.name);
+ const objectType = typeChecker.getTypeAtLocation(parent);
+ documentation = firstDefined(objectType.isUnion() ? objectType.types : [objectType], t => {
+ const prop = t.getProperty(name);
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
+ }) || emptyArray;
+ }
+ }
+
if (tags.length === 0 && !hasMultipleSignatures) {
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
}
diff --git a/tests/baselines/reference/quickInfoForObjectBindingElementName03.baseline b/tests/baselines/reference/quickInfoForObjectBindingElementName03.baseline
new file mode 100644
index 0000000000000..4e311ef906f73
--- /dev/null
+++ b/tests/baselines/reference/quickInfoForObjectBindingElementName03.baseline
@@ -0,0 +1,57 @@
+[
+ {
+ "marker": {
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName03.ts",
+ "position": 122,
+ "name": "1"
+ },
+ "quickInfo": {
+ "kind": "parameter",
+ "kindModifiers": "",
+ "textSpan": {
+ "start": 119,
+ "length": 3
+ },
+ "displayParts": [
+ {
+ "text": "(",
+ "kind": "punctuation"
+ },
+ {
+ "text": "parameter",
+ "kind": "text"
+ },
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "foo",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "string",
+ "kind": "keyword"
+ }
+ ],
+ "documentation": [
+ {
+ "text": "A description of foo",
+ "kind": "text"
+ }
+ ]
+ }
+ }
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/quickInfoForObjectBindingElementName04.baseline b/tests/baselines/reference/quickInfoForObjectBindingElementName04.baseline
new file mode 100644
index 0000000000000..0370d38cdb46b
--- /dev/null
+++ b/tests/baselines/reference/quickInfoForObjectBindingElementName04.baseline
@@ -0,0 +1,148 @@
+[
+ {
+ "marker": {
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts",
+ "position": 193,
+ "name": "1"
+ },
+ "quickInfo": {
+ "kind": "parameter",
+ "kindModifiers": "",
+ "textSpan": {
+ "start": 192,
+ "length": 1
+ },
+ "displayParts": [
+ {
+ "text": "(",
+ "kind": "punctuation"
+ },
+ {
+ "text": "parameter",
+ "kind": "text"
+ },
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "a",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "{",
+ "kind": "punctuation"
+ },
+ {
+ "text": "\n",
+ "kind": "lineBreak"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "b",
+ "kind": "propertyName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "string",
+ "kind": "keyword"
+ },
+ {
+ "text": ";",
+ "kind": "punctuation"
+ },
+ {
+ "text": "\n",
+ "kind": "lineBreak"
+ },
+ {
+ "text": "}",
+ "kind": "punctuation"
+ }
+ ],
+ "documentation": [
+ {
+ "text": "A description of 'a'",
+ "kind": "text"
+ }
+ ]
+ }
+ },
+ {
+ "marker": {
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts",
+ "position": 200,
+ "name": "2"
+ },
+ "quickInfo": {
+ "kind": "parameter",
+ "kindModifiers": "",
+ "textSpan": {
+ "start": 199,
+ "length": 1
+ },
+ "displayParts": [
+ {
+ "text": "(",
+ "kind": "punctuation"
+ },
+ {
+ "text": "parameter",
+ "kind": "text"
+ },
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "b",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "string",
+ "kind": "keyword"
+ }
+ ],
+ "documentation": [
+ {
+ "text": "A description of 'b'",
+ "kind": "text"
+ }
+ ]
+ }
+ }
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/quickInfoForObjectBindingElementName05.baseline b/tests/baselines/reference/quickInfoForObjectBindingElementName05.baseline
new file mode 100644
index 0000000000000..9790245d186ee
--- /dev/null
+++ b/tests/baselines/reference/quickInfoForObjectBindingElementName05.baseline
@@ -0,0 +1,73 @@
+[
+ {
+ "marker": {
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts",
+ "position": 137,
+ "name": ""
+ },
+ "quickInfo": {
+ "kind": "parameter",
+ "kindModifiers": "",
+ "textSpan": {
+ "start": 136,
+ "length": 1
+ },
+ "displayParts": [
+ {
+ "text": "(",
+ "kind": "punctuation"
+ },
+ {
+ "text": "parameter",
+ "kind": "text"
+ },
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "a",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "string",
+ "kind": "keyword"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "|",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "number",
+ "kind": "keyword"
+ }
+ ],
+ "documentation": [
+ {
+ "text": "A description of a",
+ "kind": "text"
+ }
+ ]
+ }
+ }
+]
\ No newline at end of file
diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementName03.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementName03.ts
new file mode 100644
index 0000000000000..4ead56c90ed39
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoForObjectBindingElementName03.ts
@@ -0,0 +1,14 @@
+///
+
+////interface Options {
+//// /**
+//// * A description of foo
+//// */
+//// foo: string;
+////}
+////
+////function f({ foo }: Options) {
+//// foo/*1*/;
+////}
+
+verify.baselineQuickInfo();
diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts
new file mode 100644
index 0000000000000..c9844cb13ef32
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts
@@ -0,0 +1,20 @@
+///
+
+////interface Options {
+//// /**
+//// * A description of 'a'
+//// */
+//// a: {
+//// /**
+//// * A description of 'b'
+//// */
+//// b: string;
+//// }
+////}
+////
+////function f({ a, a: { b } }: Options) {
+//// a/*1*/;
+//// b/*2*/;
+////}
+
+verify.baselineQuickInfo();
diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts
new file mode 100644
index 0000000000000..defde63601945
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts
@@ -0,0 +1,17 @@
+///
+
+////interface A {
+//// /**
+//// * A description of a
+//// */
+//// a: number;
+////}
+////interface B {
+//// a: string;
+////}
+////
+////function f({ a }: A | B) {
+//// a/**/;
+////}
+
+verify.baselineQuickInfo();