diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0c6b5860e12..92112c42dee 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2059,7 +2059,9 @@ namespace ts { // Display-part writer helpers // #region export function isFirstDeclarationOfSymbolParameter(symbol: Symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter; + const declaration = symbol.declarations ? firstOrUndefined(symbol.declarations) : undefined; + return !!findAncestor(declaration, n => + isParameter(n) ? true : isBindingElement(n) || isObjectBindingPattern(n) || isArrayBindingPattern(n) ? false : "quit"); } const displayPartWriter = getDisplayPartWriter(); diff --git a/tests/cases/fourslash/findAllReferencesDynamicImport3.ts b/tests/cases/fourslash/findAllReferencesDynamicImport3.ts index 08160e403ad..675db892040 100644 --- a/tests/cases/fourslash/findAllReferencesDynamicImport3.ts +++ b/tests/cases/fourslash/findAllReferencesDynamicImport3.ts @@ -8,7 +8,7 @@ const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [{ definition: "function bar(): string", ranges: [r0, r1] }]); verify.referenceGroups(r1, [ { definition: "function bar(): string", ranges: [r0] }, - { definition: "var bar: () => string", ranges: [r1] }, + { definition: "(parameter) bar: () => string", ranges: [r1] }, ]); verify.renameLocations(r0, [r0, { range: r1, suffixText: ": bar" }]); verify.renameLocations(r1, [{ range: r1, prefixText: "bar: " }]) diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts index 19bbf7d6cd8..4989f530fc0 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -16,6 +16,6 @@ const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.referenceGroups([r0, r1], [{ definition: "(property) I.property1: number", ranges: [r0, r1, r2] }]); verify.referenceGroups(r2, [ { definition: "(property) I.property1: number", ranges: [r0, r1] }, - { definition: "var property1: number", ranges: [r2, r3] }, + { definition: "(parameter) property1: number", ranges: [r2, r3] }, ]); -verify.referenceGroups(r3, [{ definition: "var property1: number", ranges: [r2, r3] }]); +verify.referenceGroups(r3, [{ definition: "(parameter) property1: number", ranges: [r2, r3] }]); diff --git a/tests/cases/fourslash/parameterWithDestructuring.ts b/tests/cases/fourslash/parameterWithDestructuring.ts index 9cce8316a14..730b49fb129 100644 --- a/tests/cases/fourslash/parameterWithDestructuring.ts +++ b/tests/cases/fourslash/parameterWithDestructuring.ts @@ -1,19 +1,18 @@ /// -// Repros from issues #4949 and #4818 - -////const result = [{ foo: 'hello' }] -//// .map(({ /*1*/foo }) => /*2*/foo) -//// .map(foo => foo); +////const result = [{ a: 'hello' }] +//// .map(({ /*1*/a }) => /*2*/a) +//// .map(a => a); //// -////const f = (foo: (bar: string[]) => void) => { }; +////const f1 = (a: (b: string[]) => void) => {}; +////f1(([a, b]) => { /*3*/a.charAt(0); }); //// -////f(([a, b]) => { -//// /*3*/a.charAt(0); // Not okay: inferred as `any` -////}); +////function f2({/*4*/a }: { a: string; }, [/*5*/b]: [string]) {} verify.quickInfos({ - 1: "var foo: string", - 2: "var foo: string", - 3: "var a: string" + 1: "(parameter) a: string", + 2: "(parameter) a: string", + 3: "(parameter) a: string", + 4: "(parameter) a: string", + 5: "(parameter) b: string" }); diff --git a/tests/cases/fourslash/parameterWithNestedDestructuring.ts b/tests/cases/fourslash/parameterWithNestedDestructuring.ts index a40104259b7..da227441b92 100644 --- a/tests/cases/fourslash/parameterWithNestedDestructuring.ts +++ b/tests/cases/fourslash/parameterWithNestedDestructuring.ts @@ -1,9 +1,13 @@ /// -////[[{foo: 'hello', bar: [1]}]] -//// .map(([{foo, bar: [baz]}]) => /*1*/foo + /*2*/baz); +////[[{ a: 'hello', b: [1] }]] +//// .map(([{ a, b: [c] }]) => /*1*/a + /*2*/c); + +////function f([[/*3*/a]]: [[string]], { b1: { /*4*/b2 } }: { b1: { b2: string; } }) {} verify.quickInfos({ - 1: "var foo: string", - 2: "var baz: number" + 1: "(parameter) a: string", + 2: "(parameter) c: number", + 3: "(parameter) a: string", + 4: "(parameter) b2: string" }); diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedIife.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedIife.ts index 71e709a86ba..da48274ea5b 100644 --- a/tests/cases/fourslash/quickInfoForContextuallyTypedIife.ts +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedIife.ts @@ -9,13 +9,13 @@ ////((a/*9*/, b/*10*/, c/*11*/) => [a/*12*/,b/*13*/,c/*14*/])("foo", 101, false); verify.quickInfos({ - 1: "var q: number", - 2: "var qq: number", + 1: "(parameter) q: number", + 2: "(parameter) qq: number", 3: "(parameter) x: number", - 4: "var p: number", - 5: "var q: number", - 6: "var qq: number", - 7: "var p: number", + 4: "(parameter) p: number", + 5: "(parameter) q: number", + 6: "(parameter) qq: number", + 7: "(parameter) p: number", 8: "(parameter) x: number", 9: "(parameter) a: string", 10: "(parameter) b: number",