namespace PrintLinkedList { class LinkedListNode < T > { value : T ; next : LinkedListNode < T > | undefined ; constructor ( value ) { this . value = value ; } } function printLinkedList < T > ( head ) { let current = head ; while ( current ) { console . log ( current . value ) ; current = current . next ; } } let head = new LinkedListNode ( "Hello" ) ; head . next = new LinkedListNode ( "World" ) ; head . next . next = new LinkedListNode ( "!!!" ) ; printLinkedList ( head ) ; }