{"action":"closed","issue":{"url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/issues/35","repository_url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb","labels_url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/issues/35/comments","events_url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/issues/35/events","html_url":"https://github.com/gcanti/babel-plugin-tcomb/issues/35","id":157682193,"number":35,"title":"Proposal: do not throw if a default import of tcomb is not available","user":{"login":"gcanti","id":878912,"avatar_url":"https://avatars.githubusercontent.com/u/878912?v=3","gravatar_id":"","url":"https://api.github.com/users/gcanti","html_url":"https://github.com/gcanti","followers_url":"https://api.github.com/users/gcanti/followers","following_url":"https://api.github.com/users/gcanti/following{/other_user}","gists_url":"https://api.github.com/users/gcanti/gists{/gist_id}","starred_url":"https://api.github.com/users/gcanti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcanti/subscriptions","organizations_url":"https://api.github.com/users/gcanti/orgs","repos_url":"https://api.github.com/users/gcanti/repos","events_url":"https://api.github.com/users/gcanti/events{/privacy}","received_events_url":"https://api.github.com/users/gcanti/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"gcanti","id":878912,"avatar_url":"https://avatars.githubusercontent.com/u/878912?v=3","gravatar_id":"","url":"https://api.github.com/users/gcanti","html_url":"https://github.com/gcanti","followers_url":"https://api.github.com/users/gcanti/followers","following_url":"https://api.github.com/users/gcanti/following{/other_user}","gists_url":"https://api.github.com/users/gcanti/gists{/gist_id}","starred_url":"https://api.github.com/users/gcanti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcanti/subscriptions","organizations_url":"https://api.github.com/users/gcanti/orgs","repos_url":"https://api.github.com/users/gcanti/repos","events_url":"https://api.github.com/users/gcanti/events{/privacy}","received_events_url":"https://api.github.com/users/gcanti/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/milestones/4","html_url":"https://github.com/gcanti/babel-plugin-tcomb/milestones/0.3","labels_url":"https://api.github.com/repos/gcanti/babel-plugin-tcomb/milestones/4/labels","id":1803947,"number":4,"title":"0.3","description":"","creator":{"login":"gcanti","id":878912,"avatar_url":"https://avatars.githubusercontent.com/u/878912?v=3","gravatar_id":"","url":"https://api.github.com/users/gcanti","html_url":"https://github.com/gcanti","followers_url":"https://api.github.com/users/gcanti/followers","following_url":"https://api.github.com/users/gcanti/following{/other_user}","gists_url":"https://api.github.com/users/gcanti/gists{/gist_id}","starred_url":"https://api.github.com/users/gcanti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcanti/subscriptions","organizations_url":"https://api.github.com/users/gcanti/orgs","repos_url":"https://api.github.com/users/gcanti/repos","events_url":"https://api.github.com/users/gcanti/events{/privacy}","received_events_url":"https://api.github.com/users/gcanti/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":4,"state":"open","created_at":"2016-06-02T07:58:36Z","updated_at":"2016-06-08T06:42:20Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-05-31T14:14:13Z","updated_at":"2016-06-08T06:42:20Z","closed_at":"2016-06-08T06:42:20Z","body":"This seems legit:\r\n\r\n```js\r\nimport {\r\n  Number\r\n} from 'tcomb';\r\n\r\nfunction sum(a: Number, b: Number): Number {\r\n  return a + b;\r\n}\r\n```\r\n\r\nand could be compiled to\r\n\r\n```js\r\nimport { Number } from 'tcomb';\r\n\r\nfunction sum(a: Number, b: Number): Number {\r\n  require(\"tcomb\").assert(Number.is(a), 'Invalid argument a (expected a ' + require(\"tcomb\").getTypeName(Number) + ')');\r\n  require(\"tcomb\").assert(Number.is(b), 'Invalid argument b (expected a ' + require(\"tcomb\").getTypeName(Number) + ')');\r\n\r\n  var ret = function (a, b) {\r\n    return a + b;\r\n  }.call(this, a, b);\r\n\r\n  require(\"tcomb\").assert(Number.is(ret), 'Invalid argument ret (expected a ' + require(\"tcomb\").getTypeName(Number) + ')');\r\n  return ret;\r\n}\r\n\r\n```\r\n\r\nI propose to replace\r\n\r\n```js\r\nfunction guardTcombImport() {\r\n  if (!tcombLocalName) {\r\n    throw new Error(\r\n      'When setting type annotations on a function, an import of tcomb must be available within the scope of the function.');\r\n  }\r\n}\r\n```\r\n\r\nwith (or something equivalent)\r\n\r\n```js\r\nfunction guardTcombImport() {\r\n  if (!tcombLocalName) {\r\n    tcombLocalName = 'require(\"tcomb\")';\r\n  }\r\n}\r\n```\r\n\r\n/cc @ctrlplusb "}}
{"actor":{"display_login":"gcanti"}}