-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbol
Description
🔎 Search Terms
Convert to optional chain
🕗 Version & Regression Information
- This changed between versions ______ and ______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because playground doesn't support code actions
I'm able to repro this with versions 5.8.3 and 5.9.2 and VS Code Version: 1.104.3
⏯ Playground Link
💻 Code
interface Data {
keyData?: KeyData;
}
interface KeyData {
key: string;
description?: string;
}
declare const data: Data;
const keyDataString = data.keyData ? data.keyData.key + ':' + (data.keyData.description ?? '') : '';
Try to invoke "Convert to optional chain expression" code action before colon.
🙁 Actual behavior
This is result of the action
const keyDataString = data.keyData?.key ?? '';
🙂 Expected behavior
It should not offer the action here as it's not a simple case.
Additional information about the issue
I was able to repro this with the tsconfig settings used in Playground but also in VS Code editor without tsconfig file.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbol