Title: `typeof` on a well-known symbol in a computed property name has a poor error · Issue #42523 · microsoft/TypeScript · GitHub
Open Graph Title: `typeof` on a well-known symbol in a computed property name has a poor error · Issue #42523 · microsoft/TypeScript
X Title: `typeof` on a well-known symbol in a computed property name has a poor error · Issue #42523 · microsoft/TypeScript
Description: Found talking to Ben Lesh (@benlesh) If you try to write the following interface SymbolConstructor { observable: symbol; } declare function from
Open Graph Description: Found talking to Ben Lesh (@benlesh) If you try to write the following interface SymbolConstructor { observable: symbol; } declare function from X Description: Found talking to Ben Lesh (@benlesh) If you try to write the following interface SymbolConstructor { observable: symbol; } declare function from<T>(obj: { [typeof Symbol.observable](): Observ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42523
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`typeof` on a well-known symbol in a computed property name has a poor error","articleBody":"Found talking to @benlesh\r\n\r\nIf you try to write the following\r\n\r\n```ts\r\ninterface SymbolConstructor {\r\n observable: symbol;\r\n}\r\n\r\ndeclare function from\u003cT>(obj: { [typeof Symbol.observable](): Observable\u003cT> }): Observable\u003cT>;\r\n// ^^^^^^ Look at this use of 'typeof'.\r\n\r\ntype Observer\u003cT> = (x: T) => void;\r\n\r\ninterface Observable\u003cT> {\r\n subscribe(observer: Observer\u003cT>): { unsubscribe(): void }\r\n}\r\n```\r\n\r\nYou'll get an error like\r\n\r\n```\r\nA computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.\r\n```\r\n\r\nThis is pretty confusing, because we *do* support well-known symbols that are declared with `symbol` instead of unique symbol if you use the following syntax:\r\n\r\n```\r\ndeclare function from\u003cT>(obj: { [Symbol.observable](): Observable\u003cT> }): Observable\u003cT>;\r\n// ^ No 'typeof'.\r\n```\r\n\r\nIt would be great if we could detect this case and specialize the error message with something like\r\n\r\n```\r\nComputed property names can only be named with well-known symbols without the 'typeof' operator. Try replacing `typeof {0}` with `{0}`.\r\n```","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2021-01-27T22:17:58Z","url":"https://github.com/microsoft/TypeScript/issues/42523"}
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:98ddc9a0-a5c8-34d0-aea3-2d0805386594 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id 80EA:2FF40E:24FB95:344600:6B046965 html-safe-nonce 0d77c0f1ed7369340d51eeea63d5fd6966ba4201f7f6ad168f1cad5f535640ff visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEVBOjJGRjQwRToyNEZCOTU6MzQ0NjAwOjZCMDQ2OTY1IiwidmlzaXRvcl9pZCI6IjU1OTAzNTk5Mjg1MzY4NTI4MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== visitor-hmac b295ad61239a207073dd931689258f93f4b04423542e6eb2eba3e820f183804a hovercard-subject-tag issue:795488952 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/42523/issue_layout twitter:image https://opengraph.githubassets.com/fa4d5b9b3578d4decf1545e7def9ba1b8cc1f507041fa741e9390019c3f76d67/microsoft/TypeScript/issues/42523 twitter:card summary_large_image og:image https://opengraph.githubassets.com/fa4d5b9b3578d4decf1545e7def9ba1b8cc1f507041fa741e9390019c3f76d67/microsoft/TypeScript/issues/42523 og:image:alt Found talking to Ben Lesh (@benlesh) If you try to write the following interface SymbolConstructor { observable: symbol; } declare function from og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username DanielRosenwasser hostname github.com expected-hostname github.com None 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f 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 ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 ui-target full theme-color #1e2327 color-scheme light dark react-app-name issues
Response headers:
Server github.com Content-Type text/html; charset=utf-8 Cache-Control max-age=0, private, must-revalidate
URLs of crawlers that visited me.