Generics in the decode function are useful to avoid type assertion on the returned value.
But here in the encode function the type T is not returned or exploited by the encode function itself, so it's probably not needed. To say a banality: "less is more" 😬