Title: Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · microsoft/TypeScript · GitHub
Open Graph Title: Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · microsoft/TypeScript
X Title: Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · micros...
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · micros...
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic type constraint ignored when applied to interface expecting a different signature.","articleBody":"Not sure if I found a bug or not, so just checking first. The code below should not work, but it compiles fine:\r\n\r\n```\r\ninterface IType\u003cTInstance> {\r\n new (value: boolean, ...args: any[]): TInstance;\r\n}\r\n\r\nclass Test\u003cT extends string> {\r\n constructor(value: T) { }\r\n}\r\n\r\nfunction doSomething(_type: IType\u003cany>) { }\r\n\r\ndoSomething(Test);\r\n\r\n```\r\n([here](https://www.typescriptlang.org/play/index.html#src=interface%20IType%3CTInstance%3E%20%7B%0D%0A%20%20%20%20new%20(value%3A%20boolean%2C%20...args%3A%20any%5B%5D)%3A%20TInstance%3B%0D%0A%7D%0D%0A%0D%0Aclass%20Test%3CT%20extends%20string%3E%20%7B%0D%0A%20%20%20%20constructor(value%3A%20T)%20%7B%20%7D%0D%0A%7D%0D%0A%0D%0Afunction%20doSomething(_type%3A%20IType%3Cany%3E)%20%7B%20%7D%0D%0A%0D%0AdoSomething(Test)%3B%0D%0A))\r\n\r\nIf I change ` constructor(value: T) { }` to ` constructor(value: string) { }` it fails. It should fail anyhow, since T could NEVER be of the expected type. :/\r\n\r\nThis also just seems wrong: \r\n\r\n```\r\ninterface IType\u003cTInstance> {\r\n new (value: boolean, ...args: any[]): TInstance;\r\n}\r\n\r\nclass Test\u003cT extends Object> {\r\n constructor(value: T) { }\r\n}\r\n\r\nfunction doSomething(_type: IType\u003cany>) { }\r\n\r\ndoSomething(Test);\r\n\r\nclass O extends Object { }\r\n\r\nclass TO extends Test\u003cO> { }\r\n\r\ndoSomething(TO);\r\n```\r\nCompiles just fine. :/","author":{"url":"https://github.com/rjamesnw","@type":"Person","name":"rjamesnw"},"datePublished":"2017-04-29T01:55:23Z","url":"https://github.com/microsoft/TypeScript/issues/15458"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:e6e5336a-4989-33dc-892a-8b806b1b615b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EFA:DA744:B20123:F0135F:6B00F750 |
| html-safe-nonce | 0f0170cc24b5d8a19dcf4e683c6eece4f1377b559587bcf47f61d2697d029952 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUZBOkRBNzQ0OkIyMDEyMzpGMDEzNUY6NkIwMEY3NTAiLCJ2aXNpdG9yX2lkIjoiMjAwMzEwMjI4NDM5MzMyNjg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 405b69588786c2f0a397c55ce2d3f481fd3e119e6d8aea17472133fe70d45884 |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/15458 |
| twitter:image | https://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Generic type constraint ignored when applied to interface expecting a different signature. · Issue #15458 · micros... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-cache |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width