-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The TypeScript type definitions in @transifex/react (packages/react/src/index.d.ts) are incomplete and don't accurately reflect the actual API of the package. This is making it difficult to properly use the library with full type safety and IDE support.
Current state
Essentially, the current index.d.ts file tries to reference types through a namespace (TransifexReact.T, TransifexReact.useLanguages, etc.) but doesn't provide any actual type definitions for those properties, so everything is falling back to any.
Proposed types
Here's what I expect the type definition file for @transifex/react to contain, replacing the current packages/react/src/index.d.ts:
import * as React from 'react'
import type { TxNative, ITranslateParams, ILanguage } from '@transifex/native'
// Re-export for consumers
export type { ILanguage }
export type TFunction = (_str: string, options?: ITranslateParams) => string
export interface TProps extends ITranslateParams {
_str: string
}
export interface UTProps extends TProps {
_inline?: boolean
}
// Hooks
export function useLanguages(txInstance?: TxNative): ILanguage[]
export function useLocale(txInstance?: TxNative): string
export function useTX(): TxNative
export function useTranslations(filterTags?: string, txInstance?: TxNative): { ready: boolean }
export function useT(txInstance?: TxNative): TFunction
// Components
export const T: React.FC<TProps>
export const UT: React.FC<UTProps>
export const TXProvider: React.FC<{
instance?: TxNative
children: React.ReactNode
}>
export const LanguagePicker: React.FC<{ className?: string }>👉🏻 We'll need to export the ILanguage interface from @transifex/native so that we can use it here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working