Title: `instanceof Object` does not work with the `in` operator · Issue #51007 · microsoft/TypeScript · GitHub
Open Graph Title: `instanceof Object` does not work with the `in` operator · Issue #51007 · microsoft/TypeScript
X Title: `instanceof Object` does not work with the `in` operator · Issue #51007 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms instanceof Object in 🕗 Version & Regression Information This changed between versions 4.9.0-dev.20220919 and 4.9.0-dev.20220920 ⏯ Playground Link Playground Link 💻 Code export function isHTMLTable(table: unknown...
Open Graph Description: Bug Report 🔎 Search Terms instanceof Object in 🕗 Version & Regression Information This changed between versions 4.9.0-dev.20220919 and 4.9.0-dev.20220920 ⏯ Playground Link Playground Link 💻 Code ex...
X Description: Bug Report 🔎 Search Terms instanceof Object in 🕗 Version & Regression Information This changed between versions 4.9.0-dev.20220919 and 4.9.0-dev.20220920 ⏯ Playground Link Playground Link 💻 Cod...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/51007
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`instanceof Object` does not work with the `in` operator","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\n`instanceof Object` `in`\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed between versions 4.9.0-dev.20220919 and 4.9.0-dev.20220920\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground Link](https://www.typescriptlang.org/play?ts=4.9.0-dev.20220920#code/FAUwHgDg9gTgLgAgGYFcB2BjOBLKaHYDOAEgCoCyAMqQIYBGANiABRz1MBcC6A1mlAHc0ASi50oUJjXwBvYAgUIYIOChj4AhBraMQCAGT6EOpgTSE2mEFCQIA8nQBWILAaMByABZwAtg3dmxuwgANzAAL5AA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\n\r\nexport function isHTMLTable(table: unknown): boolean {\r\n return !!table && table instanceof Object && 'html' in table;\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nError: Type '{}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator\r\n\r\n### 🙂 Expected behavior\r\n\r\nShould type check \r\n\r\n### Notes\r\n\r\nSeems to be introduced by https://github.com/microsoft/TypeScript/pull/50666 which correctly introduces an error if `in` is used on non objects. The issue is that it does not handle testing for objects with `instanceof Object`\r\n\r\n","author":{"url":"https://github.com/dragomirtitian","@type":"Person","name":"dragomirtitian"},"datePublished":"2022-09-30T11:09:56Z","url":"https://github.com/microsoft/TypeScript/issues/51007"}
| 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:29daca31-c6e9-96c1-3f4c-e11720391b6b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AB00:157C65:28EAD80:3693B3E:6B01BB21 |
| html-safe-nonce | 36a682e9dc035a3f4642fef423a4dba3a8404feb2dbf1921c8e98e5e85a04f3a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjAwOjE1N0M2NToyOEVBRDgwOjM2OTNCM0U6NkIwMUJCMjEiLCJ2aXNpdG9yX2lkIjoiODkzMDk2NjYxMDY4OTI0MzkzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 30967e74f56a18ee0282e66766ecc9dc7fba83f8f93b158220fc2be9a2d9ef37 |
| hovercard-subject-tag | issue:1392274769 |
| 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/51007/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1592a7b9eb2acab84df6809cc97f32eaf981ee6e1a5c5f27ca8cc267d84fe469/microsoft/TypeScript/issues/51007 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1592a7b9eb2acab84df6809cc97f32eaf981ee6e1a5c5f27ca8cc267d84fe469/microsoft/TypeScript/issues/51007 |
| og:image:alt | Bug Report 🔎 Search Terms instanceof Object in 🕗 Version & Regression Information This changed between versions 4.9.0-dev.20220919 and 4.9.0-dev.20220920 ⏯ Playground Link Playground Link 💻 Code ex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dragomirtitian |
| 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