Title: Strange error involving evolving array type and Array#sort callback · Issue #31728 · microsoft/TypeScript · GitHub
Open Graph Title: Strange error involving evolving array type and Array#sort callback · Issue #31728 · microsoft/TypeScript
X Title: Strange error involving evolving array type and Array#sort callback · Issue #31728 · microsoft/TypeScript
Description: TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601) Search Terms: Code // @noImplicitAny: true interface I { a: string; b: string; } declare function compare(a: I, b: I): number; function test() { const result = []; resu...
Open Graph Description: TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601) Search Terms: Code // @noImplicitAny: true interface I { a: string; b: string; } declare function compare(a: I, b: I): number; f...
X Description: TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601) Search Terms: Code // @noImplicitAny: true interface I { a: string; b: string; } declare function compare(a: I, b: I): number; f...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31728
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Strange error involving evolving array type and Array#sort callback","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.6.0-dev.20190602 (seems to work with 20190601)\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n\r\n**Code**\r\n\r\n```ts\r\n// @noImplicitAny: true\r\ninterface I {\r\n a: string;\r\n b: string;\r\n}\r\n\r\ndeclare function compare(a: I, b: I): number;\r\n\r\nfunction test() {\r\n const result = [];\r\n result.push({foo: true, a: 'a', b: 'b'});\r\n // ~~~~~~~~~ error here\r\n result.sort(compare); // commenting out this line makes the error disappear\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nNo error\r\n\r\n**Actual behavior:**\r\n\r\n```\r\nArgument of type '(a: I, b: I) => number' is not assignable to parameter of type '(a: { foo: boolean; a: string; b: string; }, b: { foo: boolean; a: string; b: string; }) => number'.\r\n Types of parameters 'a' and 'a' are incompatible.\r\n Type '{ foo: boolean; a: string; b: string; }' is not assignable to type 'I'.\r\n Object literal may only specify known properties, and 'foo' does not exist in type 'I'.\r\n```\r\n\r\nMaybe the error makes sense with `strictNullChecks` enabled (which is off in the above example), but then the location is completely off\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\n\r\n**Related Issues:**\r\nThe only two changes in that version are #31711 and #31687. /cc @ahejlsberg \r\n","author":{"url":"https://github.com/ajafff","@type":"Person","name":"ajafff"},"datePublished":"2019-06-02T16:33:42Z","url":"https://github.com/microsoft/TypeScript/issues/31728"}
| 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:48669db6-f829-5924-133f-d0956e0e8364 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84F0:4279A:9051AB:C3AC59:6B00EA98 |
| html-safe-nonce | 01c23600cc7c54b00a5239dd7e419997045423aed0658ebf57fdc2d52ecd3419 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEYwOjQyNzlBOjkwNTFBQjpDM0FDNTk6NkIwMEVBOTgiLCJ2aXNpdG9yX2lkIjoiMzc0NjExMzgwNDk5NjUwNDIxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d1779d57ee355cc4631b0b9505f1ce90b79da396ab1fb58a72bfeebaf6b90bf3 |
| hovercard-subject-tag | issue:451209975 |
| 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/31728/issue_layout |
| twitter:image | https://opengraph.githubassets.com/745be35e178a20f1157f732d7f963ccc0dc2e95a62c8c57b56cd5bd54ba8145a/microsoft/TypeScript/issues/31728 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/745be35e178a20f1157f732d7f963ccc0dc2e95a62c8c57b56cd5bd54ba8145a/microsoft/TypeScript/issues/31728 |
| og:image:alt | TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601) Search Terms: Code // @noImplicitAny: true interface I { a: string; b: string; } declare function compare(a: I, b: I): number; f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ajafff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width