Solution: Generics and Advanced Type Inferences

Review the solutions to the challenges discussed in the previous lesson.

Solution: Specifying types explicitly in generics

The error in the original code is that the type argument provided when calling the printGeneric function (<string>) doesn’t match the actual argument type as 1 is a number.

To fix the issue, we can specify the correct type explicitly when calling the printGeneric function. In the solution, we specify the type argument as <number> to match the actual argument being passed.

Get hands-on with 1200+ tech skills courses.