Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It seems the analyser to infer the types of your vars is fairly easily fooled. The following code compiles, but prints out "Hello undefined":

  interface person{
	firstname;
	lastname;
  }

  interface apple{
	colour;
  }

  function hello(p : person){
	alert("hello " + p.firstname);
  }

  var aPerson = {firstname: "joe", lastname : "blogs"};
  var anApple = {color: "red"};

  var foo;
  if(true){
	foo = anApple;
  }

  hello(foo);


When you paste this into the Playground, and hover over the `var




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: