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 s-34 solution screaming Argument of type '[]' is not assignable #18

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

Conversation

nthhai318
Copy link

Description

Solution 34 - 34-internationalization.solution line 38: Typescript is screaming

  const buttonText = translate(translations, "button");
// Argument of type '[]' is not assignable to parameter of type 'never'.
// Translation: I was expecting never, but you passed []
  ...args: TDynamicKeys extends string
    ? [dynamicArgs: Record<TDynamicKeys, string>]
    : []

Because TDynamicKeys (line 15) become never in case of button property of transalations
causing ...args to become type never

Fixes

check if TDynamicKeys is type never first

  ...args: [TDynamicKeys] extends [never] 
    ? []
    : TDynamicKeys extends string
    ? [dynamicArgs: Record<TDynamicKeys, string>]
    : []

Type of change

  • [ x ] Bug fix (non-breaking change which fixes an issue)

Because

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant