{"action":"created","issue":{"url":"https://api.github.com/repos/gcanti/tcomb/issues/142","labels_url":"https://api.github.com/repos/gcanti/tcomb/issues/142/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/tcomb/issues/142/comments","events_url":"https://api.github.com/repos/gcanti/tcomb/issues/142/events","html_url":"https://github.com/gcanti/tcomb/issues/142","id":106535589,"number":142,"title":"Tcomb breaks object type checking","user":{"login":"ivan-kleshnin","id":2128182,"avatar_url":"https://avatars.githubusercontent.com/u/2128182?v=3","gravatar_id":"","url":"https://api.github.com/users/ivan-kleshnin","html_url":"https://github.com/ivan-kleshnin","followers_url":"https://api.github.com/users/ivan-kleshnin/followers","following_url":"https://api.github.com/users/ivan-kleshnin/following{/other_user}","gists_url":"https://api.github.com/users/ivan-kleshnin/gists{/gist_id}","starred_url":"https://api.github.com/users/ivan-kleshnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivan-kleshnin/subscriptions","organizations_url":"https://api.github.com/users/ivan-kleshnin/orgs","repos_url":"https://api.github.com/users/ivan-kleshnin/repos","events_url":"https://api.github.com/users/ivan-kleshnin/events{/privacy}","received_events_url":"https://api.github.com/users/ivan-kleshnin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-15T11:24:52Z","updated_at":"2015-09-16T07:48:13Z","closed_at":null,"body":"I'm toying with **Tcomb** last days and did find that it wraps objects in its own structures.\r\n\r\nThis is a dealbreaker because noone wants another OOP. \r\nThere is no reason to go further than just freezing an Object.\r\n\r\n```js\r\nfunction Struct(value, path) {\r\n  // !!! evil\r\n  if (Struct.is(value)) { // makes Struct idempotent\r\n    return value;\r\n  }\r\n\r\n  ...\r\n\r\n  // !!! evil\r\n  if (!isInstanceOf(this, Struct)) { // makes `new` optional\r\n    return new Struct(value);\r\n  }\r\n\r\n  ... \r\n\r\n  // this is ok\r\n  if (process.env.NODE_ENV !== 'production') {\r\n    Object.freeze(this);\r\n  }\r\n}\r\n```\r\n\r\nI understand you made it for performance, but see:\r\n\r\n```js\r\nimport isPlainObject from \"is-plain-object\";\r\n\r\n// declare Robot\r\n\r\nconsole.log(isPlainObject(Robot({\r\n  id: \"ebffa860-5660-4561-a373-288f33544b71\",\r\n  name: \"Alec\",\r\n  manufacturer: \"USA\",\r\n  assemblyDate: new Date(),\r\n}))); // false\r\n````\r\n\r\nObject checking is no longer working, cause Object is wrapped.\r\nThis cuts down everything.\r\n\r\nI'm skeptical even about that performance gain because it seems most values will be passed through typing system only once. But this is another story. \r\n\r\nObject wrapping is OOP and requires from all code to be Tcomb-aware which goes straight against the purpose of the lib.\r\n\r\n`Something.is` can't replace native JS. \r\nIt may be supplemental, but all values must stay unwrapped to be compatible with existing ecosystem.\r\nBy wrapping natives you gain better performance and fashionable `console.log` but lose ecosystem compatibility. 100% not worth it.\r\n"},"comment":{"url":"https://api.github.com/repos/gcanti/tcomb/issues/comments/140658524","html_url":"https://github.com/gcanti/tcomb/issues/142#issuecomment-140658524","issue_url":"https://api.github.com/repos/gcanti/tcomb/issues/142","id":140658524,"user":{"login":"ivan-kleshnin","id":2128182,"avatar_url":"https://avatars.githubusercontent.com/u/2128182?v=3","gravatar_id":"","url":"https://api.github.com/users/ivan-kleshnin","html_url":"https://github.com/ivan-kleshnin","followers_url":"https://api.github.com/users/ivan-kleshnin/followers","following_url":"https://api.github.com/users/ivan-kleshnin/following{/other_user}","gists_url":"https://api.github.com/users/ivan-kleshnin/gists{/gist_id}","starred_url":"https://api.github.com/users/ivan-kleshnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivan-kleshnin/subscriptions","organizations_url":"https://api.github.com/users/ivan-kleshnin/orgs","repos_url":"https://api.github.com/users/ivan-kleshnin/repos","events_url":"https://api.github.com/users/ivan-kleshnin/events{/privacy}","received_events_url":"https://api.github.com/users/ivan-kleshnin/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T07:48:13Z","updated_at":"2015-09-16T07:48:13Z","body":"// ...you COULD write\r\n```js\r\nPerson.prototype.getFullName = function () {\r\n  return `${this.name} ${this.surname}`;\r\n};\r\n```\r\n\r\n> and then be sure the functions related to Person are accessible everytime you are managing a Person instance.\r\n\r\nThis is OOP which I avoid at all costs. I can get the same functionality by just importing standalone function which is easier to test and I'm free of prototype mess."}}