Title: Stack overflow while type checking generic, mutually-defined function interfaces · Issue #18277 · microsoft/TypeScript · GitHub
Open Graph Title: Stack overflow while type checking generic, mutually-defined function interfaces · Issue #18277 · microsoft/TypeScript
X Title: Stack overflow while type checking generic, mutually-defined function interfaces · Issue #18277 · microsoft/TypeScript
Description: TypeScript Version: 2.4.0 onwards Code export interface Foo
Open Graph Description: TypeScript Version: 2.4.0 onwards Code export interface Foo
X Description: TypeScript Version: 2.4.0 onwards Code export interface Foo<T> { (bar: Bar<T>): void; } export interface Bar<T> { (foo: Foo<T>): Foo<T>; } function createBar<T>(...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18277
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stack overflow while type checking generic, mutually-defined function interfaces","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:** `2.4.0` onwards\r\n\r\n**Code**\r\n```ts\r\nexport interface Foo\u003cT> {\r\n (bar: Bar\u003cT>): void;\r\n}\r\n\r\nexport interface Bar\u003cT> {\r\n (foo: Foo\u003cT>): Foo\u003cT>;\r\n}\r\n\r\nfunction createBar\u003cT>(): Bar\u003cT> {\r\n return (f) => f;\r\n}\r\n\r\nfunction foo\u003cT>(\r\n bar: Bar\u003cT>,\r\n): void {}\r\n\r\n// Stack overflow\r\ncreateBar()(foo) === foo;\r\n```\r\nSimplified down from a real code-base.\r\n\r\n**Expected behavior:**\r\n\r\nCompiles fine, as per \u003c `2.3.4`\r\n\r\n**Actual behavior:**\r\n\r\nWith `2.4.0` (same behaviour with `2.5.2`):\r\n\r\n```shell\r\n$ ./node_modules/.bin/tsc example.ts\r\n./node_modules/typescript/lib/tsc.js:55708\r\n throw e;\r\n ^\r\n\r\nRangeError: Maximum call stack size exceeded\r\n at getErasedSignature (.../node_modules/typescript/lib/tsc.js:27019:36)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28517:22)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n at compareSignaturesRelated (.../node_modules/typescript/lib/tsc.js:28548:21)\r\n```","author":{"url":"https://github.com/willfrew","@type":"Person","name":"willfrew"},"datePublished":"2017-09-06T16:23:49Z","url":"https://github.com/microsoft/TypeScript/issues/18277"}
| 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:e4e140ef-d0d2-e255-9c6a-d1a581629f5c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E802:2564D8:E272F6:12C4332:6B00FEEA |
| html-safe-nonce | 561fdc365bacee65e7f1dc80d7c393f2110dd2ca84090d124128094111df4bee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODAyOjI1NjREODpFMjcyRjY6MTJDNDMzMjo2QjAwRkVFQSIsInZpc2l0b3JfaWQiOiIxMTEwMjg3MDQ5NjgxODYyMzc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b0673b9e55da51300d6c9d88f459640f53d6dfd70af5ce8f050ef2b98e637c40 |
| hovercard-subject-tag | issue:255664724 |
| 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/18277/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebcc295f6c1b11f89458e93a6e2e05e37262db1b103c698effe89eadf542cc92/microsoft/TypeScript/issues/18277 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebcc295f6c1b11f89458e93a6e2e05e37262db1b103c698effe89eadf542cc92/microsoft/TypeScript/issues/18277 |
| og:image:alt | TypeScript Version: 2.4.0 onwards Code export interface Foo |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | willfrew |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width