codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

Failed type checking for object... expected: {x: number}, got: { } #155

Closed cricklet closed 7 years ago

cricklet commented 8 years ago

Any idea what's up here?

I'm on babel-plugin-typecheck@3.9.0 and babel-core@6.9.1


This fails:

type Player = {
  x: number,
  y: number,
  roomIndex: number
}

function thinkPlayer(player: Player): {x: number} {
  return {x: player.x + 123}
}

screen shot 2016-06-12 at 11 31 01 am


However, this works:

type Player = {
  x: number,
  y: number,
  roomIndex: number
}

function thinkPlayer(player: Player): {x: number} {
  let dp =  {x: player.x + 123}
  return dp
}
ForbesLindesay commented 8 years ago

I'm having the same problem

phpnode commented 7 years ago

Hi, sorry for taking so long to respond to this, this project is now deprecated in favour of https://codemix.github.io/flow-runtime which aims for full compatibility with Flow.

I checked and babel-plugin-flow-runtime does not have this particular bug, because we no longer do the static optimisations/checks.