{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10853","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10853/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10853/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10853/events","html_url":"https://github.com/Microsoft/TypeScript/issues/10853","id":176237853,"number":10853,"title":"Extending ES6 Map causes error - Constructor Map requires 'new'","user":{"login":"flyon","id":341567,"avatar_url":"https://avatars0.githubusercontent.com/u/341567?v=4","gravatar_id":"","url":"https://api.github.com/users/flyon","html_url":"https://github.com/flyon","followers_url":"https://api.github.com/users/flyon/followers","following_url":"https://api.github.com/users/flyon/following{/other_user}","gists_url":"https://api.github.com/users/flyon/gists{/gist_id}","starred_url":"https://api.github.com/users/flyon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flyon/subscriptions","organizations_url":"https://api.github.com/users/flyon/orgs","repos_url":"https://api.github.com/users/flyon/repos","events_url":"https://api.github.com/users/flyon/events{/privacy}","received_events_url":"https://api.github.com/users/flyon/received_events","type":"User","site_admin":false},"labels":[{"id":113971601,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/External","name":"External","color":"eb6420","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-11T10:44:21Z","updated_at":"2018-02-20T20:15:05Z","closed_at":"2016-09-20T23:13:40Z","author_association":"NONE","body":"I know native types should be extendable since this PR https://github.com/Microsoft/TypeScript/pull/3516 , but I can't seem to get extending ES6 Map to work.\n\nThe following code \n\n```\nclass ResourceMap extends Map {}\nvar x = new ResourceMap();\nx.set('foo',true);\n```\n\ncompiles correctly to: \n\n```\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar ResourceMap = (function (_super) {\n    __extends(ResourceMap, _super);\n    function ResourceMap() {\n        _super.apply(this, arguments);\n    }\n    return ResourceMap;\n}(Map));\n\n//[...]\nvar x = new ResourceMap();\nx.set('foo',true);\n```\n\nBut when I run it in chrome it gives an error `Uncaught TypeError: Constructor Map requires 'new'`\n\nWhen I run the _original_ typescript code directly in the chrome console (which is possible because it's also valid ES6 and only uses functions supported by chrome) then it _works correctly_. So it should be possible? \n\nIs there a way to extend ES6 Map from Typescript?\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/367104881","html_url":"https://github.com/Microsoft/TypeScript/issues/10853#issuecomment-367104881","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10853","id":367104881,"user":{"login":"Xample","id":944605,"avatar_url":"https://avatars1.githubusercontent.com/u/944605?v=4","gravatar_id":"","url":"https://api.github.com/users/Xample","html_url":"https://github.com/Xample","followers_url":"https://api.github.com/users/Xample/followers","following_url":"https://api.github.com/users/Xample/following{/other_user}","gists_url":"https://api.github.com/users/Xample/gists{/gist_id}","starred_url":"https://api.github.com/users/Xample/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xample/subscriptions","organizations_url":"https://api.github.com/users/Xample/orgs","repos_url":"https://api.github.com/users/Xample/repos","events_url":"https://api.github.com/users/Xample/events{/privacy}","received_events_url":"https://api.github.com/users/Xample/received_events","type":"User","site_admin":false},"created_at":"2018-02-20T20:15:05Z","updated_at":"2018-02-20T20:15:05Z","author_association":"NONE","body":"@Stradivario no it's not a ```void```, it's the type of the class, the constructor implicitly returns ```this```for you. For instance, if you do write an interface typing the constructor you will get:\r\n```ts\r\ninterface TypedConstructor {\r\n    new (parameter:string): TypedConstructor;\r\n}\r\n```\r\nIt's the way it is in ES6, [more reading](https://stackoverflow.com/a/28006379/532695)"}}
{"actor":{"display_login":"Xample"}}