Title: Recursive function type is printed using "any" if the function is not in scope · Issue #475 · microsoft/TypeScript · GitHub
Open Graph Title: Recursive function type is printed using "any" if the function is not in scope · Issue #475 · microsoft/TypeScript
X Title: Recursive function type is printed using "any" if the function is not in scope · Issue #475 · microsoft/TypeScript
Description: var x = function f() { return f; }; var x = function () { var y; return y; }; We get the following error message: Subsequent variable declarations must have the same type. Variable 'x' must be of type '() => any', but here has type '() =...
Open Graph Description: var x = function f() { return f; }; var x = function () { var y; return y; }; We get the following error message: Subsequent variable declarations must have the same type. Variable 'x' must be of t...
X Description: var x = function f() { return f; }; var x = function () { var y; return y; }; We get the following error message: Subsequent variable declarations must have the same type. Variable 'x' must...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/475
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recursive function type is printed using \"any\" if the function is not in scope","articleBody":"``` TS\nvar x = function f() { return f; };\nvar x = function () { var y; return y; };\n```\n\nWe get the following error message:\nSubsequent variable declarations must have the same type. Variable 'x' must be of type '() => any', but here has type '() => any'.\n\nThis is essentially the same as #463. The first declaration of x has type `() => typeof f`, but because f is not in the global scope, we say it is any, even though it is clearly not.\n\nWe have a similar problem for function declarations (and likely for module instances and class constructors):\n\n``` TS\nfunction g() {\n return function f() {\n return f;\n };\n}\n\nvar numberFn = \u003c() => number>(g());\n```\n\nWe get the following error on the type assertion:\nNeither type '() => number' nor type '() => any' is assignable to the other.\n\nBut in fact '() => number' _is_ assignable to '() => any'!\n","author":{"url":"https://github.com/JsonFreeman","@type":"Person","name":"JsonFreeman"},"datePublished":"2014-08-18T21:10:50Z","url":"https://github.com/microsoft/TypeScript/issues/475"}
| 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:3eff0273-8cf4-01a1-0301-fe86b63a2282 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3CC:369D8B:17CA0A:1F476E:6B01634F |
| html-safe-nonce | 8fba23766252796c7fe805d9e54d9e4aa6ceae1771aee1744be95846fd5d830b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0NDOjM2OUQ4QjoxN0NBMEE6MUY0NzZFOjZCMDE2MzRGIiwidmlzaXRvcl9pZCI6IjI2Njc4MTY5Mjc2NjA5NTg1NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d2035865fea19682dede003281a8ace9bc4d2888b50d7cd18ee8556e5f99eb25 |
| hovercard-subject-tag | issue:40532496 |
| 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/475/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80753d547c63ac5065c696c8d4cc37be5eb15c12cd445c8bdcb8b619f06eaf6e/microsoft/TypeScript/issues/475 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80753d547c63ac5065c696c8d4cc37be5eb15c12cd445c8bdcb8b619f06eaf6e/microsoft/TypeScript/issues/475 |
| og:image:alt | var x = function f() { return f; }; var x = function () { var y; return y; }; We get the following error message: Subsequent variable declarations must have the same type. Variable 'x' must be of t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JsonFreeman |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width