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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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 bug Something isn't working 3. to review labels Oct 6, 2024
@ShGKme ShGKme requested a review from susnux October 6, 2024 15:45
@ShGKme ShGKme self-assigned this Oct 6, 2024
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@ShGKme ShGKme force-pushed the fix/typed-var-placeholder-keys branch from fdaf005 to 888f9fc Compare October 6, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant