Title: [Errors] Shorter: Neither type X nor type Y is assignable to the other · Issue #97 · microsoft/TypeScript · GitHub
Open Graph Title: [Errors] Shorter: Neither type X nor type Y is assignable to the other · Issue #97 · microsoft/TypeScript
X Title: [Errors] Shorter: Neither type X nor type Y is assignable to the other · Issue #97 · microsoft/TypeScript
Description: // Function call whose argument is a 1 arg generic function call with explicit type arguments function fn1
Open Graph Description: // Function call whose argument is a 1 arg generic function call with explicit type arguments function fn1
X Description: // Function call whose argument is a 1 arg generic function call with explicit type arguments function fn1<T>(t: T) { } function fn2(t: any) { } fn1(fn2<string>(4)); // Error var a: any...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/97
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Errors] Shorter: Neither type X nor type Y is assignable to the other","articleBody":"``` TypeScript\n// Function call whose argument is a 1 arg generic function call with explicit type arguments\nfunction fn1\u003cT>(t: T) { }\nfunction fn2(t: any) { }\n\nfn1(fn2\u003cstring>(4)); // Error\n\nvar a: any;\nvar s: string;\n\n// Type assertion of non - unary expression\nvar a = \u003cany>\"\" + 4;\nvar s = \"\" + \u003cany>4;\n\nclass SomeBase {\n private p;\n}\nclass SomeDerived extends SomeBase {\n private x;\n}\nclass SomeOther {\n private q;\n}\n\n// Type assertion should check for assignability in either direction\nvar someBase = new SomeBase();\nvar someDerived = new SomeDerived();\nvar someOther = new SomeOther();\n\nsomeBase = \u003cSomeBase>someDerived;\nsomeBase = \u003cSomeBase>someBase;\nsomeBase = \u003cSomeBase>someOther; // Error\n\nsomeDerived = \u003cSomeDerived>someDerived;\nsomeDerived = \u003cSomeDerived>someBase;\nsomeDerived = \u003cSomeDerived>someOther; // Error\n\nsomeOther = \u003cSomeOther>someDerived; // Error\nsomeOther = \u003cSomeOther>someBase; // Error\nsomeOther = \u003cSomeOther>someOther;\n```\n\nExpected: \n\n// Function call whose argument is a 1 arg generic function call with explicit type arguments\n function fn1\u003cT>(t: T) { }\n function fn2(t: any) { }\n\n```\nfn1(fn2\u003cstring>(4)); // Error\n```\n\n!!! Could not select overload for 'call' expression.\n\n```\nvar a: any;\nvar s: string;\n\n// Type assertion of non - unary expression\nvar a = \u003cany>\"\" + 4;\nvar s = \"\" + \u003cany>4;\n\nclass SomeBase {\n private p;\n}\nclass SomeDerived extends SomeBase {\n private x;\n}\nclass SomeOther {\n private q;\n}\n\n// Type assertion should check for assignability in either direction\nvar someBase = new SomeBase();\nvar someDerived = new SomeDerived();\nvar someOther = new SomeOther();\n\nsomeBase = \u003cSomeBase>someDerived;\nsomeBase = \u003cSomeBase>someBase;\nsomeBase = \u003cSomeBase>someOther; // Error\n```\n\n!!! Neither type 'SomeOther' nor type 'SomeBase' is assignable to the other:\n!!! Type 'SomeOther' is missing property 'p' from type 'SomeBase'.\n!!! Type 'SomeBase' is missing property 'q' from type 'SomeOther'.\n\n```\nsomeDerived = \u003cSomeDerived>someDerived;\nsomeDerived = \u003cSomeDerived>someBase;\nsomeDerived = \u003cSomeDerived>someOther; // Error\n```\n\n!!! Neither type 'SomeOther' nor type 'SomeDerived' is assignable to the other:\n!!! Type 'SomeOther' is missing property 'x' from type 'SomeDerived'.\n!!! Type 'SomeDerived' is missing property 'q' from type 'SomeOther'.\n\n```\nsomeOther = \u003cSomeOther>someDerived; // Error\n```\n\n!!! Neither type 'SomeDerived' nor type 'SomeOther' is assignable to the other:\n!!! Type 'SomeDerived' is missing property 'q' from type 'SomeOther'.\n!!! Type 'SomeOther' is missing property 'x' from type 'SomeDerived'.\n someOther = \u003cSomeOther>someBase; // Error\n!!! Neither type 'SomeBase' nor type 'SomeOther' is assignable to the other:\n!!! Type 'SomeBase' is missing property 'q' from type 'SomeOther'.\n!!! Type 'SomeOther' is missing property 'p' from type 'SomeBase'.\n someOther = \u003cSomeOther>someOther;\n\nActual: \n\n // Function call whose argument is a 1 arg generic function call with explicit type arguments\n function fn1\u003cT>(t: T) { }\n function fn2(t: any) { }\n\n```\nfn1(fn2\u003cstring>(4)); // Error\n```\n\n!!! Supplied parameters do not match any signature of call target.\n!!! Supplied parameters do not match any signature of call target.\n\n```\nvar a: any;\nvar s: string;\n\n// Type assertion of non - unary expression\nvar a = \u003cany>\"\" + 4;\nvar s = \"\" + \u003cany>4;\n\nclass SomeBase {\n private p;\n}\nclass SomeDerived extends SomeBase {\n private x;\n}\nclass SomeOther {\n private q;\n}\n\n// Type assertion should check for assignability in either direction\nvar someBase = new SomeBase();\nvar someDerived = new SomeDerived();\nvar someOther = new SomeOther();\n\nsomeBase = \u003cSomeBase>someDerived;\nsomeBase = \u003cSomeBase>someBase;\nsomeBase = \u003cSomeBase>someOther; // Error\n```\n\n!!! Neither type 'SomeBase' nor type 'SomeOther' is assignable to the other.\n\n```\nsomeDerived = \u003cSomeDerived>someDerived;\nsomeDerived = \u003cSomeDerived>someBase;\nsomeDerived = \u003cSomeDerived>someOther; // Error\n```\n\n!!! Neither type 'SomeDerived' nor type 'SomeOther' is assignable to the other.\n\n```\nsomeOther = \u003cSomeOther>someDerived; // Error\n```\n\n!!! Neither type 'SomeOther' nor type 'SomeDerived' is assignable to the other.\n someOther = \u003cSomeOther>someBase; // Error\n!!! Neither type 'SomeOther' nor type 'SomeBase' is assignable to the other.\n someOther = \u003cSomeOther>someOther;\n","author":{"url":"https://github.com/mhegazy","@type":"Person","name":"mhegazy"},"datePublished":"2014-07-17T19:57:39Z","url":"https://github.com/microsoft/TypeScript/issues/97"}
| 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:58405b06-bac2-39d2-19bb-0a5442e0a292 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D8C:20AA01:87DE87:B01908:6B00DA7A |
| html-safe-nonce | a930482233fe7ae537702f46955125eba49dd41db5a2e71537986e66172ba018 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDhDOjIwQUEwMTo4N0RFODc6QjAxOTA4OjZCMDBEQTdBIiwidmlzaXRvcl9pZCI6Ijg3Mzc5MDgzMzc1NDAxMjczNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2c4c1da319f762b24d25d29b471f91eaa61176af8c07f3dcc55befaca3f98882 |
| hovercard-subject-tag | issue:38119448 |
| 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/97/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d84d356821dfbaa8fb27310bb5477a1a6c90d6ea6baab5bd7f342236ad93cb6c/microsoft/TypeScript/issues/97 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d84d356821dfbaa8fb27310bb5477a1a6c90d6ea6baab5bd7f342236ad93cb6c/microsoft/TypeScript/issues/97 |
| og:image:alt | // Function call whose argument is a 1 arg generic function call with explicit type arguments function fn1 |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mhegazy |
| hostname | github.com |
| expected-hostname | github.com |
| None | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width