Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Convert to optional chaining doesn't show up for expressions with bracket accessor #40510

Copy link
Copy link
@mjbvz

Description

@mjbvz
Issue body actions

TypeScript Version: 4.1.0-dev.20200911

Search Terms:

Repro
For the code:

const a = { b: { c: 1 } }
if (a && a.b && a.b['c']) {
    
}

Select a && a.b && a.b['c'].

Expected behavior:
Convert to optional chaining refactoring is available. It would result in:

const a = { b: { c: 1 } }
if (a?.b?.['c']) {
    
}

Actual behavior:
No refactoring available

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.