Skip to content

Commit 9dc4de3

Browse files
committed
feat: use const type parameters for useTranslation()
TypeScript 5.0 has introduced const type parameters [1]. These indicate that a more specific type is preferred over a more general one. As a result, the resulting UseTranslationResponse will be more precise and retain the passed-in namespace and prefix. This can be used by extractors and other tooling to find out exactly which key is accessed by a translation function call. [1]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters
1 parent 1d6fef3 commit 9dc4de3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export type FallbackNs<Ns> = Ns extends undefined
9797
: _DefaultNamespace;
9898

9999
export function useTranslation<
100-
Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined,
101-
KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
100+
const Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined,
101+
const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
102102
>(
103103
ns?: Ns,
104104
options?: UseTranslationOptions<KPrefix>,

0 commit comments

Comments
 (0)