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

fix(types): type translation variable keys #807

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Oct 6, 2024

Before

// ✅ Ok
t('app', 'Hello, {name}!', { name: 'Alice' })

// ✅ Ok
t('app', 'Hello, {name}!', { user: 'Alice' })

// ✅ Ok
t('app', 'Hello, {name}!', {})

After

// ✅ Ok
t('app', 'Hello, {name}!', { name: 'Alice' })

// ❌ Object literal may only specify known properties, and 'user' does not exist in type 'TranslationVariables<"Hello, {name}!">'
t('app', 'Hello, {name}!', { user: 'Alice' })

// ❌ Argument of type '{}' is not assignable to parameter of type 'TranslationVariables<"Hello, {name}!">'.
//  Property 'name' is missing in type '{}' but required in type 'TranslationVariables<"Hello, {name}!">'
t('app', 'Hello, {name}!', {})

@ShGKme ShGKme added type: bug 🐛 Something isn't working 3. to review 3️⃣ Waiting for reviews labels Oct 6, 2024
@ShGKme ShGKme requested a review from susnux October 6, 2024 15:45
@ShGKme ShGKme self-assigned this Oct 6, 2024
@ShGKme ShGKme force-pushed the fix/typed-var-placeholder-keys branch from fdaf005 to 888f9fc Compare October 6, 2024 17:00
@susnux susnux merged commit 08cdafe into main Jan 10, 2025
13 checks passed
@susnux susnux deleted the fix/typed-var-placeholder-keys branch January 10, 2025 07:40
@susnux susnux mentioned this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review 3️⃣ Waiting for reviews type: bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants