<!DOCTYPE html>
<html>

  <head>
    <script data-require="typescript@2.2.2" data-semver="2.2.2" src="https://cdnjs.cloudflare.com/ajax/libs/typescript/2.2.2/typescript.min.js"></script>
    <link rel="stylesheet" href="style.css" />
   
  </head>

  <body>
    
    <!-- // make console.log write to the page for better in-browser experience -->
    <script>
      (function () {
        var body = document.querySelector('body');
        body.style['fontFamily'] = 'monospace';
        body.style['fontSize'] = '2em';
        console.log = function (x, y) { 
          body.innerText += "name: " + x.name + "\n age: " + x.age + '\n' + "prop: " + y; };
      }());
    </script>
     <script src="script.js"></script>
  </body>

</html>
/* Styles go here */

function spyOn<O extends object, P extends keyof O>(obj: O, prop: P) {
  console.log(obj, prop)
}

interface Person {
  name: string,
  age: number
}

type PersonTypes = keyof Person

const person: Person = {
  name:'John',
  age: 22
}

spyOn(person, 'name')