{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5944","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5944/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5944/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5944/events","html_url":"https://github.com/Microsoft/TypeScript/issues/5944","id":120531275,"number":5944,"title":"Extending the Function interface in the presence of an import statement","user":{"login":"bgrieder","id":797684,"avatar_url":"https://avatars.githubusercontent.com/u/797684?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrieder","html_url":"https://github.com/bgrieder","followers_url":"https://api.github.com/users/bgrieder/followers","following_url":"https://api.github.com/users/bgrieder/following{/other_user}","gists_url":"https://api.github.com/users/bgrieder/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrieder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrieder/subscriptions","organizations_url":"https://api.github.com/users/bgrieder/orgs","repos_url":"https://api.github.com/users/bgrieder/repos","events_url":"https://api.github.com/users/bgrieder/events{/privacy}","received_events_url":"https://api.github.com/users/bgrieder/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-05T05:35:21Z","updated_at":"2015-12-05T20:21:07Z","closed_at":"2015-12-05T15:46:46Z","body":"I would like to extend `Function` and this compiles fine\r\n\r\n    interface Function {\r\n    \thello(): any\r\n    }\r\n    Function.prototype.hello = function() {\r\n    \tconsole.log('hello world')\r\n    }\r\n\t\r\n\tfunction noop() {}\r\n\t\r\n\tnoop.hello() //==> 'hello world' in the console\r\n\r\n\r\nHowever, as soon as I try to add an import statement, say\r\n\r\n    import { sayHello } from './Anything'\r\n\r\nwhere `Anything` only contains\r\n\r\n    export function sayHello() { console.log('hello')}\r\n\r\nThe compilation fails on `Function.protoype.hello` with the message `error TS2339: Property 'hello' does not exist on type 'Function'`\r\n\r\nWhy ?\r\n\r\n[View in Playground][1]\r\n\r\n\r\nNote1: the compilation fails with tsc options set to either `--target es5 --module commonjs` or `--target es6`\r\nNote2: my final goal is to export utilities in a library to be able to write code like `myfunc.liftM(myMonad1, MyMonad2)` or `myfunc1.compose(myfunc2)`, etc...\r\n\r\n\r\n  [1]: http://www.typescriptlang.org/Playground#src=%0A%20%20%20%20interface%20Function%20%7B%0A%20%20%20%20%09hello()%3A%20any%0A%20%20%20%20%7D%0A%20%20%20%20Function.prototype.hello%20%3D%20function()%20%7B%0A%20%20%20%20%09console.log('hello%20world')%0A%20%20%20%20%7D%0A%09%0A%09function%20noop()%20%7B%7D%0A%09%0A%09noop.hello()%0A%09%0A%09%2F%2Fimport%20%7B%20hello%20%7D%20from%20'whatever'%20%20%0A%09%2F*%0A%09%20*%20Adding%20the%20import%20statement%20(also)%20triggers%20the%20Error%3A%20%0A%09%20*%20Property%20'hello'%20does%20not%20exists%20on%20type%20%60Function%60%0A%09%20*%20Why%20%3F%0A%09%20*%2F"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/162243160","html_url":"https://github.com/Microsoft/TypeScript/issues/5944#issuecomment-162243160","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5944","id":162243160,"user":{"login":"yortus","id":1252361,"avatar_url":"https://avatars.githubusercontent.com/u/1252361?v=3","gravatar_id":"","url":"https://api.github.com/users/yortus","html_url":"https://github.com/yortus","followers_url":"https://api.github.com/users/yortus/followers","following_url":"https://api.github.com/users/yortus/following{/other_user}","gists_url":"https://api.github.com/users/yortus/gists{/gist_id}","starred_url":"https://api.github.com/users/yortus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yortus/subscriptions","organizations_url":"https://api.github.com/users/yortus/orgs","repos_url":"https://api.github.com/users/yortus/repos","events_url":"https://api.github.com/users/yortus/events{/privacy}","received_events_url":"https://api.github.com/users/yortus/received_events","type":"User","site_admin":false},"created_at":"2015-12-05T20:21:07Z","updated_at":"2015-12-05T20:21:07Z","body":"Agreed. It's trivial to do in JavaScript, so it would be good to be able to model it just as easily in TypeScript. "}}