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

String literal as object key ends with type error #83

Closed mkatrenik closed 8 years ago

mkatrenik commented 8 years ago

I have this code: headers = { 'x-user-isid': isid, ...headers }; and it fails with TypeError: ...file.js: Cannot read property 'name' of undefined

mkatrenik commented 8 years ago

Sorry, problem is actually object spread, but in other cases it works.

phpnode commented 8 years ago

@mkatrenik does the headers object have a type annotation? I can't replicate this using:

export default function demo (headers) {
  const isid = true;
  headers = { 'x-user-isid': isid, ...headers };
  return headers;
}
mkatrenik commented 8 years ago

nope, zero annotations in project. but the actual code is somObj.headers = { 'x-user-isid': isid, ...headers }; if you still can't replicate it, i will prepare some gist.

phpnode commented 8 years ago

@mkatrenik I added a passing test in #84, please would you mind checking out that branch and making that particular test fail? It'd be a big help, thanks.

phpnode commented 8 years ago

Ah ok, I see it now...

phpnode commented 8 years ago

fixed in 3.4.5