Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(refactoring): add/from destructure bug fixes, this keyword support #183

Merged
merged 16 commits into from
Nov 15, 2023
Prev Previous commit
Next Next commit
fix: ensure initializer
Ilya Golovin committed Nov 12, 2023

Unverified

No user is associated with the committer email.
commit a572a5763f4ca18937c49bccd9660b5800422eba
4 changes: 2 additions & 2 deletions typescript/src/codeActions/custom/addDestructure.ts
Original file line number Diff line number Diff line change
@@ -26,10 +26,10 @@ const addDestructureToVariableWithSplittedPropertyAccessors = (
formatOptions: ts.FormatCodeSettings | undefined,
languageService: ts.LanguageService,
) => {
const isObjectVariableDecl = ts.isVariableDeclaration(node.parent) && node.parent.initializer && ts.isObjectLiteralExpression(node.parent.initializer)
const isValidInitializer = ts.isVariableDeclaration(node.parent) && node.parent.initializer && isValidInitializerForDestructure(node.parent.initializer)

// Make sure it only triggers on the destructuring object or parameter
if (!ts.isIdentifier(node) || !(isObjectVariableDecl || ts.isParameter(node.parent))) return
if (!ts.isIdentifier(node) || !(isValidInitializer || ts.isParameter(node.parent))) return

const highlightPositions = getPositionHighlights(node.getStart(), sourceFile, languageService)