{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21761","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21761/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21761/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21761/events","html_url":"https://github.com/Microsoft/TypeScript/issues/21761","id":295551372,"number":21761,"title":"Forced to call super leading to undefined is not a constructor","user":{"login":"jeffrose","id":618161,"avatar_url":"https://avatars3.githubusercontent.com/u/618161?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffrose","html_url":"https://github.com/jeffrose","followers_url":"https://api.github.com/users/jeffrose/followers","following_url":"https://api.github.com/users/jeffrose/following{/other_user}","gists_url":"https://api.github.com/users/jeffrose/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffrose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffrose/subscriptions","organizations_url":"https://api.github.com/users/jeffrose/orgs","repos_url":"https://api.github.com/users/jeffrose/repos","events_url":"https://api.github.com/users/jeffrose/events{/privacy}","received_events_url":"https://api.github.com/users/jeffrose/received_events","type":"User","site_admin":false},"labels":[{"id":113971558,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Question","name":"Question","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-08T15:20:16Z","updated_at":"2018-02-08T18:01:43Z","closed_at":null,"author_association":"NONE","body":"<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 -->\r\n<!--\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the CONTRIBUTING guidelines: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md\r\n  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n-->\r\n\r\n<!-- If you have a QUESTION:\r\n   THIS IS NOT A FORUM FOR QUESTIONS.\r\n   Ask questions at http://stackoverflow.com/questions/tagged/typescript\r\n    or https://gitter.im/Microsoft/TypeScript\r\n-->\r\n\r\n<!-- If you have a SUGGESTION:\r\n  Most suggestion reports are duplicates, please search extra hard before logging a new suggestion.\r\n  See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md\r\n-->\r\n\r\n<!-- If you have a BUG:\r\n  Please fill in the *entire* template below.\r\n-->\r\n\r\n<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:**  2.7.1\r\n\r\n<!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\nsuper constructor undefined\r\n\r\n**Code**\r\n\r\n*tsconfig.json*\r\n```json\r\n{\r\n  \"compilerOptions\": {\r\n    \"declaration\": true,\r\n    \"downlevelIteration\": true,\r\n    \"experimentalDecorators\": true,\r\n    \"lib\": [ \"esnext\", \"dom\" ],\r\n    \"module\": \"es2015\",\r\n    \"moduleResolution\": \"node\",\r\n    \"noUnusedLocals\": true,\r\n    \"noUnusedParameters\": true,\r\n    \"removeComments\": true,\r\n    \"skipLibCheck\": true,\r\n    \"sourceMap\": true,\r\n    \"target\": \"es5\"\r\n  }\r\n}\r\n```\r\n\r\n```ts\r\ntype Constructor<T = {}> = new( ...args: any[] ) => T;\r\nclass Null extends null { }\r\n\r\ninterface MyInterface {\r\n  myMixinMethod(): void;\r\n  myClassMethod(): void;\r\n}\r\n\r\nconst MyMixin = <T extends Constructor>( superclass: T ) => class extends superclass {\r\n myMixinMethod(): void {\r\n    console.log( 'Called my mixin method' );\r\n  }\r\n};\r\n\r\nabstract class AbstractMyClass extends MyMixin( Null ) implements MyInterface {\r\n abstract myClassMethod(): void;\r\n}\r\n\r\nclass MyClass extends AbstractMyClass {\r\n  constructor( public myProperty: string ){\r\n    // If super() is not called, it throws the error below\r\n    // [ts] Constructors for derived classes must contain a 'super' call.\r\n    super();\r\n  }\r\n  myClassMethod(): void {\r\n    console.log( 'Called my class method' );\r\n  }\r\n}\r\n\r\n// If super() is called in MyClass, it throws the error below\r\n// TypeError: undefined is not a constructor (evaluating '_super.call(this)')\r\nconst myClass = new MyClass( 'myValue' );\r\n```\r\n\r\n**Expected behavior:**\r\nIt should *not* require the `super()` call since parent class lacks a constructor.\r\n\r\n**Actual behavior:**\r\nIt requires a call to `super()` which results in the error `undefined is not a constructor`.\r\n\r\n**Related Issues:**\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/364196730","html_url":"https://github.com/Microsoft/TypeScript/issues/21761#issuecomment-364196730","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21761","id":364196730,"user":{"login":"jeffrose","id":618161,"avatar_url":"https://avatars3.githubusercontent.com/u/618161?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffrose","html_url":"https://github.com/jeffrose","followers_url":"https://api.github.com/users/jeffrose/followers","following_url":"https://api.github.com/users/jeffrose/following{/other_user}","gists_url":"https://api.github.com/users/jeffrose/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffrose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffrose/subscriptions","organizations_url":"https://api.github.com/users/jeffrose/orgs","repos_url":"https://api.github.com/users/jeffrose/repos","events_url":"https://api.github.com/users/jeffrose/events{/privacy}","received_events_url":"https://api.github.com/users/jeffrose/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T18:01:42Z","updated_at":"2018-02-08T18:01:42Z","author_association":"NONE","body":"It's more secure to inherit from null since modifications to `Object.prototype` would affect your class."}}
{"actor":{"display_login":"jeffrose"}}