Skip to content

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