{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23394","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23394/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23394/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23394/events","html_url":"https://github.com/Microsoft/TypeScript/issues/23394","id":314022387,"number":23394,"title":"Incorrect behaviour for class methods redefenition","user":{"login":"awinogradov","id":982072,"avatar_url":"https://avatars0.githubusercontent.com/u/982072?v=4","gravatar_id":"","url":"https://api.github.com/users/awinogradov","html_url":"https://github.com/awinogradov","followers_url":"https://api.github.com/users/awinogradov/followers","following_url":"https://api.github.com/users/awinogradov/following{/other_user}","gists_url":"https://api.github.com/users/awinogradov/gists{/gist_id}","starred_url":"https://api.github.com/users/awinogradov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awinogradov/subscriptions","organizations_url":"https://api.github.com/users/awinogradov/orgs","repos_url":"https://api.github.com/users/awinogradov/repos","events_url":"https://api.github.com/users/awinogradov/events{/privacy}","received_events_url":"https://api.github.com/users/awinogradov/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":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-13T08:54:11Z","updated_at":"2018-04-13T19:37:16Z","closed_at":"2018-04-13T19:37:16Z","author_association":"NONE","body":"**Search Terms:**\r\nclass, methods\r\n\r\n**Code**\r\n\r\nFirstly, u can see this problem if you use a pattern of redefinition methods in children class which has a declared type of returning value.\r\n\r\n```ts\r\nclass Base {\r\n  method(): string {\r\n    return 'mystring'\r\n  }\r\n}\r\n\r\nclass Children extends Base {\r\n  method(): number {\r\n    return 1;\r\n  }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors, it's fully redefinition.\r\n\r\n**Actual behavior:**\r\nError: Type 'number' is not assignable to type 'string'.\r\n\r\nSecondly, u can see the same problem with the methods args.\r\n\r\n```ts\r\nclass Base {\r\n  method(arg: string) {\r\n    return arg\r\n  }\r\n}\r\n\r\nclass Children extends Base {\r\n  method(arg: number ) {\r\n    return arg;\r\n  }\r\n}\r\n\r\n// BUT\r\n\r\nclass Children2 extends Base {\r\n  method(arg) { // <--- any\r\n    return arg;\r\n  }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors, it's fully redefinition.\r\n\r\n**Actual behavior:**\r\nError: \r\nTypes of parameters 'arg' and 'arg' are incompatible.\r\nType 'string' is not assignable to type 'number'."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/381240719","html_url":"https://github.com/Microsoft/TypeScript/issues/23394#issuecomment-381240719","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23394","id":381240719,"user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars3.githubusercontent.com/u/6685088?v=4","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"created_at":"2018-04-13T19:37:16Z","updated_at":"2018-04-13T19:37:16Z","author_association":"MEMBER","body":"Derived classes can accept wider types than their base types, as is described by substitutability. Please read the FAQ and/or ask questions on StackOverflow."}}
{"actor":{"display_login":"RyanCavanaugh"}}