Skip to content

Conversation

@luxscious
Copy link
Contributor

Fixes #538

The diff command couldn't match variable keys to auto-generated constant aliases.

Problem: Alias map has MY_VARIABLE: 'my-variable', but lookup tried aliasMap['my-variable'] → undefined

Solution: Try both direct and transformed lookup: aliasMap[name] || aliasMap[keyToConstant(name)]

@luxscious luxscious marked this pull request as ready for review November 5, 2025 17:04
@luxscious luxscious requested a review from a team as a code owner November 5, 2025 17:04
Copilot AI review requested due to automatic review settings November 5, 2025 17:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extracts common variable key-to-constant name transformation logic into a reusable utility function. The refactoring consolidates duplicate logic that converts variable keys (like 'my-variable') into constant names (like 'MY_VARIABLE') and enables better handling of variable aliases in the diff command.

  • Extracted keyToConstant utility function to centralize the transformation logic
  • Updated generate/types.ts to use the new utility instead of inline logic
  • Enhanced diff/index.ts to handle aliased variable matching using both direct name and constant-transformed name

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/keyToConstant.ts New utility function for transforming variable keys to constant format
src/commands/generate/types.ts Refactored to use the new keyToConstant utility
src/commands/diff/index.ts Enhanced alias matching to support constant-transformed variable names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@luxscious luxscious requested a review from a team November 5, 2025 21:22
Copilot AI review requested due to automatic review settings November 5, 2025 21:50
@luxscious luxscious force-pushed the tso-317-diff-is-not-matching-the-valuesalias-from-the-generated branch from f7549da to 34075ee Compare November 5, 2025 21:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

--- /dev/null
+++ b/test-utils/fixtures/diff/sampleDiff.ts
@@ -1,1 +1,21 @@
+const config = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to call the useVariableValue here for a more accurate test instead of a string match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use useVariableValue then the bug doesn't get caught 🙃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug is related to the use of the variableKey and the VariableAlias, should get caught either way

@luxscious luxscious merged commit a8f5d29 into main Nov 6, 2025
9 checks passed
@luxscious luxscious deleted the tso-317-diff-is-not-matching-the-valuesalias-from-the-generated branch November 6, 2025 14:20
luxscious added a commit that referenced this pull request Nov 6, 2025
luxscious added a commit that referenced this pull request Nov 6, 2025
…#542)

Revert "fix: match variable aliases using transformed constant names (#539)"

This reverts commit a8f5d29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Diff is not matching the values/alias from the generated TypeScript file

3 participants