Skip to content

Commit 429e77b

Browse files
committed
fix #1899
1 parent 3b4e102 commit 429e77b

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface IcuTransContentDeclaration {
4747
* Props for IcuTransWithoutContext component (no React context)
4848
*/
4949
export type IcuTransWithoutContextProps<
50-
Key extends ParseKeys<Ns, TOpt, KPrefix> = string,
50+
Key extends ParseKeys<Ns, TOpt, KPrefix>,
5151
Ns extends Namespace = _DefaultNamespace,
5252
KPrefix = undefined,
5353
TContext extends string | undefined = undefined,
@@ -73,7 +73,7 @@ export type IcuTransWithoutContextProps<
7373
* Props for IcuTrans component (with React context support)
7474
*/
7575
export type IcuTransProps<
76-
Key extends ParseKeys<Ns, TOpt, KPrefix> = string,
76+
Key extends ParseKeys<Ns, TOpt, KPrefix>,
7777
Ns extends Namespace = _DefaultNamespace,
7878
KPrefix = undefined,
7979
TContext extends string | undefined = undefined,
@@ -96,7 +96,7 @@ export type IcuTransProps<
9696
*/
9797
export interface IcuTransComponent {
9898
<
99-
Key extends ParseKeys<Ns, TOpt, KPrefix> = string,
99+
Key extends ParseKeys<Ns, TOpt, KPrefix>,
100100
Ns extends Namespace = _DefaultNamespace,
101101
KPrefix = undefined,
102102
TContext extends string | undefined = undefined,
@@ -123,7 +123,7 @@ export interface IcuTransComponent {
123123
*/
124124
export interface IcuTransWithoutContextComponent {
125125
<
126-
Key extends ParseKeys<Ns, TOpt, KPrefix> = string,
126+
Key extends ParseKeys<Ns, TOpt, KPrefix>,
127127
Ns extends Namespace = _DefaultNamespace,
128128
KPrefix = undefined,
129129
TContext extends string | undefined = undefined,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { describe, it, expectTypeOf } from 'vitest';
2+
import { IcuTrans } from '../../..';
3+
4+
describe('<IcuTrans /> with bug report config', () => {
5+
it('standard usage should work', () => {
6+
// This is the basic test case from issue #1899
7+
// The bug is that when resources are defined, the default type parameter
8+
// `= string` becomes invalid because ParseKeys<...> returns specific keys
9+
expectTypeOf(IcuTrans).toBeCallableWith({
10+
i18nKey: 'foo',
11+
defaultTranslation: 'foo',
12+
content: [],
13+
});
14+
});
15+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'i18next';
2+
3+
declare module 'i18next' {
4+
interface CustomTypeOptions {
5+
defaultNS: 'app';
6+
keySeparator: '.';
7+
resources: {
8+
app: { foo: string; bar: string };
9+
};
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"include": ["./**/*"],
4+
"exclude": [],
5+
"compilerOptions": {
6+
"skipLibCheck": false
7+
}
8+
}

0 commit comments

Comments
 (0)