Title: Indexed Accesses Checking Allow Unsafe Assignments · Issue #26274 · microsoft/TypeScript · GitHub
Open Graph Title: Indexed Accesses Checking Allow Unsafe Assignments · Issue #26274 · microsoft/TypeScript
X Title: Indexed Accesses Checking Allow Unsafe Assignments · Issue #26274 · microsoft/TypeScript
Description: Code class Component Open Graph Description: Code class Component X Description: Code class Component<S> { state!: S; // assume a default state is provided in some way setState<K extends keyof S>(state: Pick<S, K>) { /*react-like setState*/ } } export interfac...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/26274
X: @github
Domain: github.com
Links:
Viewport: width=device-width
{ state!: S; // assume a default state is provided in some way setState) { /*react-like setState*/ } } export interface State { state!: S; // assume a default state is provided in some way setState
) { /*react-like setState*/ } } export interface State
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Indexed Accesses Checking Allow Unsafe Assignments","articleBody":"**Code**\r\n\r\n```ts\r\nclass Component\u003cS> {\r\n state!: S; // assume a default state is provided in some way\r\n setState\u003cK extends keyof S>(state: Pick\u003cS, K>) { /*react-like setState*/ }\r\n}\r\n \r\nexport interface State\u003cT> {\r\n a: T;\r\n}\r\n \r\nclass Foo {}\r\n \r\nclass Comp\u003cT extends Foo, S> extends Component\u003cS & State\u003cT>>\r\n{\r\n foo(a: T) {\r\n this.setState({ a: a });\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nError on `setState` - a `T` is not inherently comparable with a `S[\"a\"]` - since `S` is unconstrained, so too is `S[\"a\"]`.\r\nFor a concrete subtype which exposes the issue, consider:\r\n```ts\r\nclass BrokenComponent extends Comp\u003cFoo, { a: { x: number } }> {\r\n main() {\r\n const f = new Foo();\r\n this.foo(f); // allowed\r\n this.state.a.x; // According to the typesystem, this should exist, but it won't!\r\n }\r\n}\r\n```\r\n\r\n**Actual behavior:**\r\nNo error.\r\n","author":{"url":"https://github.com/weswigham","@type":"Person","name":"weswigham"},"datePublished":"2018-08-07T20:32:24Z","url":"https://github.com/microsoft/TypeScript/issues/26274"}
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:83d003cb-2620-5fac-7aa1-934bb13d6a1c current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id DA24:1EC9BC:26E056F:3190088:6B019BB6 html-safe-nonce 763d9d047dbd44393e029f3652b1ab5072e3849708a8222e50ffa6d402850517 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTI0OjFFQzlCQzoyNkUwNTZGOjMxOTAwODg6NkIwMTlCQjYiLCJ2aXNpdG9yX2lkIjoiNTA5ODYwNDA2NTk3ODQyNDI0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 visitor-hmac c7da23e93c24c61742f0bb7c8464734874a3c65b2dfbf19e7513e6ba485e7be8 hovercard-subject-tag issue:348476348 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/26274/issue_layout twitter:image https://opengraph.githubassets.com/e6c385b91056350b2f706ada02c58c31fe462c2b6a8246166be0fb12d879545e/microsoft/TypeScript/issues/26274 twitter:card summary_large_image og:image https://opengraph.githubassets.com/e6c385b91056350b2f706ada02c58c31fe462c2b6a8246166be0fb12d879545e/microsoft/TypeScript/issues/26274 og:image:alt Code class Component { state!: S; // assume a default state is provided in some way setState) { /*react-like setState*/ } } export interface Stateog:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username weswigham 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
URLs of crawlers that visited me.