GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Destructuring array, ability to explicitly tell the variable is unused · Issue #31388 · microsoft/TypeScript Closed Labels CommittedThe team has roadmapped this issueThe team has roadmapped this issueFix AvailableA PR has been opened for this issueA PR has been opened for this issueFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript Milestone DescriptionSearch Terms
SuggestionWhen you're destructuring an array, I want some variables/const to be declared but explicitly make them unused. Typescript has a feature of underscoring the unused parameters for functions: But it doesn't work for array destruction: The motivation of the current behavior is that you can destruct array like this: But you can't do this (this is invalid syntax): But whatever syntax is valid, what I say is that the ability to explicitly say a variable is unused, with leading underscore - it's good practice, it's convenient, and it should be supported when destructuring arrays, not in functions only. P.S. Originally I've described the issue here - #31357, but it's wrongly described as a "bug request", so here's a feature request Use CasesToday you make some changes to the code that don't require such a variable, so you don't construct it from the array. You had a perfectly named variable, but you remove it. Tomorrow's programmer needs that variable, but he gives it a different name. Of course, there's code review, etc., so eventually it will get a proper name again - it just adds additional communication which is not needed, consumes time which could be used to something more useful. Additionally, this syntax looks very weird (don't you think?): Instead, it's much better to have this: ExamplesHaving this code: To receive no errors from typescript when
ChecklistMy suggestion meets these guidelines:
Reacted by Ian MacLeod, Brandon Bloom, Oleksii Makodzeba, Jerry Green, Thomas Hoorn..., Eric Sundquist, Michael Boselowitz, Zane Hitchcox, Cina Saffary, Michael K and 18 more Reacted by Giovanni Matina, Oleksandr Tarasiuk and CAO THAI DUONG Activity
MetadataMetadataAssigneesLabelsCommittedThe team has roadmapped this issueThe team has roadmapped this issueFix AvailableA PR has been opened for this issueA PR has been opened for this issueFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |