@@ -8,10 +8,6 @@ import {
88
99type TKeys = "title" | "text" ;
1010
11- declare interface IWithNamespacesOverrideTest extends WithNamespaces {
12- t < T extends string | string [ ] > ( a : T ) : any ;
13- }
14-
1511function NamespacesConsumerTest ( ) {
1612 return (
1713 < NamespacesConsumer >
@@ -22,6 +18,7 @@ function NamespacesConsumerTest() {
2218 < span > { t ( "any" , { anyObject : { } } ) } </ span >
2319 < span > { t < TKeys > ( "text" ) } </ span >
2420 < span > { t < TKeys , { key : string } > ( "text" , { key : "foo" } ) } </ span >
21+ < span > { t < TKeys , { key : "bar" } , string > ( "text" , { key : "bar" } ) } </ span >
2522 </ div >
2623 }
2724 </ NamespacesConsumer >
@@ -45,7 +42,16 @@ const MyComponentWrapped = withNamespaces()(TransComponentTest);
4542
4643type ArticleKeys = "article.part1" | "article.part2" ;
4744type AnotherArticleKeys = "anotherArticle.part1" | "anotherArticle.part2" ;
48- class App extends React . Component < WithNamespaces > {
45+
46+ /**
47+ * Overload makes completion of arguments by without specifying type parameters
48+ */
49+ interface IOverloadedWithNamespaces extends WithNamespaces {
50+ t ( key : ArticleKeys , b ?: object ) : any ;
51+ t < T extends AnotherArticleKeys > ( key : T , b : { name : string } ) : any ;
52+ }
53+
54+ class App extends React . Component < IOverloadedWithNamespaces > {
4955 public render ( ) {
5056 const { t, i18n } = this . props ;
5157
@@ -64,12 +70,12 @@ class App extends React.Component<WithNamespaces> {
6470 < MyComponentWrapped />
6571 </ div >
6672 < article >
67- < div > { t < ArticleKeys > ( "article.part1" ) } </ div >
68- < div > { t < ArticleKeys > ( "article.part2" ) } </ div >
73+ < div > { t ( "article.part1" , { name : "foo" } ) } </ div >
74+ < div > { t ( "article.part2" ) } </ div >
6975 </ article >
7076 < article >
71- < div > { t < AnotherArticleKeys > ( "anotherArticle.part1" ) } </ div >
72- < div > { t < AnotherArticleKeys > ( "anotherArticle.part2" ) } </ div >
77+ < div > { t < AnotherArticleKeys > ( "anotherArticle.part1" , { name : "foo" } ) } </ div >
78+ < div > { t < AnotherArticleKeys > ( "anotherArticle.part2" , { name : "bar" } ) } </ div >
7379 </ article >
7480 </ div >
7581 ) ;
0 commit comments