Title: Non-void functions can omit return expressions · Issue #162 · microsoft/TypeScript · GitHub
Open Graph Title: Non-void functions can omit return expressions · Issue #162 · microsoft/TypeScript
X Title: Non-void functions can omit return expressions · Issue #162 · microsoft/TypeScript
Description: The old compiler was permissive with both of the following code snippets: function foo(): number { return; } class C { public foo() { return; } } as per the 1.0 spec (6.3): An explicitly typed function whose return type isn't the Void or...
Open Graph Description: The old compiler was permissive with both of the following code snippets: function foo(): number { return; } class C { public foo() { return; } } as per the 1.0 spec (6.3): An explicitly typed func...
X Description: The old compiler was permissive with both of the following code snippets: function foo(): number { return; } class C { public foo() { return; } } as per the 1.0 spec (6.3): An explicitly typed func...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/162
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-void functions can omit return expressions","articleBody":"The old compiler was permissive with both of the following code snippets:\n\n``` TypeScript\nfunction foo(): number {\n return;\n}\n```\n\n``` TypeScript\nclass C {\n public foo() {\n return;\n }\n}\n```\n\nas per the 1.0 spec (6.3):\n\n> An explicitly typed function whose return type isn't the Void or the Any type must have at least one `return` statement somewhere in its body. An exception to this rule is if the function implementation consists of a single `throw` statement.\n\nI believe we should change this to \n\n> An explicitly typed function whose return type isn't the Void or the Any type must have at least one `return` **expression** somewhere in its body. An exception to this rule is if the function implementation consists of a single `throw` statement.\n\nIt seems weird that we allow implicit return of `undefined` through `return` statements with no explicit expression, but we don't allow the implicit return of `undefined` through by omitting `return` statements entirely.\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2014-07-20T17:22:49Z","url":"https://github.com/microsoft/TypeScript/issues/162"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8efdc1f9-31d9-6b17-e8c6-38f3ceea1e68 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 93A2:1E3D3D:4C72C1:69AC40:6B009175 |
| html-safe-nonce | e8e41dcda645611b53e21d549588021ebff68caf23bc28d9edbf4be11f4afaee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0EyOjFFM0QzRDo0QzcyQzE6NjlBQzQwOjZCMDA5MTc1IiwidmlzaXRvcl9pZCI6IjQxMzM4NDI3MjA2NzIyMjM2MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c942fa4f9d25552a67d3b8195a92fe9ad543dc8639da7d6a27f3e97c9ba8a9b9 |
| hovercard-subject-tag | issue:38262195 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/162/issue_layout |
| twitter:image | https://opengraph.githubassets.com/93ba498ed61466e706b4798f134bff5c72f75d66c49324dbd7ecf53aba7968ef/microsoft/TypeScript/issues/162 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/93ba498ed61466e706b4798f134bff5c72f75d66c49324dbd7ecf53aba7968ef/microsoft/TypeScript/issues/162 |
| og:image:alt | The old compiler was permissive with both of the following code snippets: function foo(): number { return; } class C { public foo() { return; } } as per the 1.0 spec (6.3): An explicitly typed func... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width