{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11095","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11095/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11095/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11095/events","html_url":"https://github.com/Microsoft/TypeScript/issues/11095","id":178907520,"number":11095,"title":"--strictNullChecks enforcing unnecessary tests","user":{"login":"jice-nospam","id":7805711,"avatar_url":"https://avatars.githubusercontent.com/u/7805711?v=3","gravatar_id":"","url":"https://api.github.com/users/jice-nospam","html_url":"https://github.com/jice-nospam","followers_url":"https://api.github.com/users/jice-nospam/followers","following_url":"https://api.github.com/users/jice-nospam/following{/other_user}","gists_url":"https://api.github.com/users/jice-nospam/gists{/gist_id}","starred_url":"https://api.github.com/users/jice-nospam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jice-nospam/subscriptions","organizations_url":"https://api.github.com/users/jice-nospam/orgs","repos_url":"https://api.github.com/users/jice-nospam/repos","events_url":"https://api.github.com/users/jice-nospam/events{/privacy}","received_events_url":"https://api.github.com/users/jice-nospam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-23T15:32:47Z","updated_at":"2016-09-23T21:49:52Z","closed_at":null,"body":"**TypeScript Version:**  2.0.3\r\n\r\n**Code**\r\nMore a suggestion than a bug. I found out that there are a few situations where enabling strictNullChecks results in unnecessary complexity in the code. For example : \r\n\r\n```\r\nif ( myArray.length > 0 ) {\r\n    let o: Object = myArray.pop();\r\n    o.method();\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nshould compile\r\n\r\n**Actual behavior:** \r\nrequires a Object | undefined type and an additional safety test\r\n\r\n```\r\nif ( myArray.length > 0) {\r\n    let o: Object | undefined = myArray.pop();\r\n    if (o) {\r\n        o.method();\r\n    }\r\n}\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/249310916","html_url":"https://github.com/Microsoft/TypeScript/issues/11095#issuecomment-249310916","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11095","id":249310916,"user":{"login":"Bobris","id":284414,"avatar_url":"https://avatars.githubusercontent.com/u/284414?v=3","gravatar_id":"","url":"https://api.github.com/users/Bobris","html_url":"https://github.com/Bobris","followers_url":"https://api.github.com/users/Bobris/followers","following_url":"https://api.github.com/users/Bobris/following{/other_user}","gists_url":"https://api.github.com/users/Bobris/gists{/gist_id}","starred_url":"https://api.github.com/users/Bobris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bobris/subscriptions","organizations_url":"https://api.github.com/users/Bobris/orgs","repos_url":"https://api.github.com/users/Bobris/repos","events_url":"https://api.github.com/users/Bobris/events{/privacy}","received_events_url":"https://api.github.com/users/Bobris/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T21:49:52Z","updated_at":"2016-09-23T21:49:52Z","body":"Workaround I am using is to help TS with bang:\r\n\r\n```\r\nif ( myArray.length > 0 ) {\r\n    let o: Object = myArray.pop()!;\r\n    o.method();\r\n}\r\n```"}}
{"actor":{"display_login":"Bobris"}}