I am not sure if I got the question. But I will try to give a better example.
Let's say you have a generic interface:
interfaceItem<T>{value:T;}constitem1:Item<string>={value:"Gleb"}interfacePerson{name:string;age:number;}constitem2:Item<Person>={value:{name:"Gleb",age:27}}constitem3:Item={}// Error: Generic type 'Item<T>' requires 1 type argument(s)
If you set a default value of the generic type, item3 will not cause an error. It will set the type of value to any.
You can use any type as a default:
interfaceItem<T=number>{value:T;// Will be number, if no other type is passed to the interface}constitem:Item={value:1}
I am not sure if I got the question. But I will try to give a better example.
Let's say you have a generic interface:
If you set a default value of the generic type,
item3
will not cause an error. It will set the type ofvalue
toany
.You can use any type as a default:
Does it answer your question?
Yes I think I saw no value in this: