{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/20974","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/20974/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/20974/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/20974/events","html_url":"https://github.com/Microsoft/TypeScript/issues/20974","id":285542669,"number":20974,"title":"non-null assertion not working on type parameter with constraint","user":{"login":"ajafff","id":11968040,"avatar_url":"https://avatars0.githubusercontent.com/u/11968040?v=4","gravatar_id":"","url":"https://api.github.com/users/ajafff","html_url":"https://github.com/ajafff","followers_url":"https://api.github.com/users/ajafff/followers","following_url":"https://api.github.com/users/ajafff/following{/other_user}","gists_url":"https://api.github.com/users/ajafff/gists{/gist_id}","starred_url":"https://api.github.com/users/ajafff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajafff/subscriptions","organizations_url":"https://api.github.com/users/ajafff/orgs","repos_url":"https://api.github.com/users/ajafff/repos","events_url":"https://api.github.com/users/ajafff/events{/privacy}","received_events_url":"https://api.github.com/users/ajafff/received_events","type":"User","site_admin":false},"labels":[{"id":119463126,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Revisit","name":"Revisit","color":"006b75","default":false},{"id":113971155,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-01-02T21:31:29Z","updated_at":"2018-03-06T16:30:26Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!-- BUGS: Please use this template. -->\r\n<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\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.0-dev.20171230\r\n\r\n**Code**\r\n\r\n```ts\r\nfunction takeString(p: string) {}\r\n\r\nfunction foo<T extends string | undefined>(param: T) {\r\n  takeString(param!); // error on this line\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nBecause of the constraint the compiler knows the type of `param` can only be `string | undefined`. Asserting the type with a non-null assertion should result in `string` and the code should compile without error.\r\n\r\nIf this is working as intended, I'll write a lint rule to warn about non-null assertions on type parameters.\r\n\r\n**Actual behavior:**\r\n```\r\nArgument of type 'T' is not assignable to parameter of type 'string'.\r\n  Type 'string | undefined' is not assignable to type 'string'.\r\n    Type 'undefined' is not assignable to type 'string'.\r\n```"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/370841174","html_url":"https://github.com/Microsoft/TypeScript/issues/20974#issuecomment-370841174","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/20974","id":370841174,"user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars3.githubusercontent.com/u/2932786?v=4","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T16:30:26Z","updated_at":"2018-03-06T16:30:26Z","author_association":"MEMBER","body":"#22096 should cover it."}}
{"actor":{"display_login":"weswigham"}}