You already have an example. "I like to swim". The verb "like" is transitive and the direct object is the infinitive (noun) "to swim".
Student or Learner
Usually, the infinitive is used after an intransitive verb:
"She came to see me".
"She gets to go".
"I happened to see him".
"I like to swim". In a dictionary, it says that intransitive "To like" means "wish" so I'm sure "To like" is not an intransitive verb here.
Sometimes, the infinitive is used as an object for a transtive verb but how?