microsoft / microsoft/TypeScript
Preserve comments with object destructuring assignment
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
object destructuring assignment, comment
Suggestion
interface MyInterface {
/**
* I am x
*/
x : number;
/**
* I am y
*/
y : number;
}
declare const myInterface : MyInterface;
const {x, y} = myInterface;
/**
* Expected tooltip to have comment,
* > I am x
*
* Actual: No comment
*/
x;
/**
* Expected tooltip to have comment,
* > I am y
*
* Actual: No comment
*/
y;
/**
* Expected tooltip to have comment,
* > I am x
*
* Actual:
* Tooltip has comment,
* > I am x
*/
myInterface.x;
/**
* Expected tooltip to have comment,
* > I am y
*
* Actual:
* Tooltip has comment,
* > I am y
*/
myInterface.y;
/**
* I am z
*/
const z = 1;
/**
* Expected tooltip to have comment,
* > I am z
*
* Actual:
* Tooltip has comment,
* > I am z
*/
z;
Use Cases
I came across this idea after writing code like this,
function foo (
{
somePropertyA,
somePropertyB,
somePropertyC,
} : SomeObject
) {
/* Use these properties */
}
And I was hazy on the details of what each property was for.
So, I hovered my cursor over the variables somePropertyA, somePropertyB, somePropertyC and noticed there were no comments.
I had to go to the declaration of somePropertyA, somePropertyB, somePropertyC and look at each property individually.
At the moment, the way to get comments is to just do,
function foo (
o : SomeObject
) {
/* Use these properties */
}
Then the tooltip for o.somePropertyA, o.somePropertyB, o.somePropertyC will have comments
Examples
See above suggestion
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduzieren Sie das Verhalten im verknüpften TypeScript Playground, indem Sie Hover-Tooltips für direkt zugegriffene Eigenschaften und durch Object-Destructuring eingeführte Variablen vergleichen. Verfolgen Sie den Language-Service-/Type-Checking-Pfad, der Kommentare für destrukturierte Bindings auflöst; die Aufgabe ist abgeschlossen, wenn die Kommentare der deklarierten Eigenschaften für x, y und destrukturierte Funktionsparameter erscheinen, ohne die Laufzeitausgabe zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100