Title: Meta-issue: `this` disambiguator · Issue #513 · microsoft/TypeScript · GitHub
Open Graph Title: Meta-issue: `this` disambiguator · Issue #513 · microsoft/TypeScript
X Title: Meta-issue: `this` disambiguator · Issue #513 · microsoft/TypeScript
Description: Do not discuss the details of these in this bug! Go to the appropriate linked issue to discuss them This issue is to track all the various this proposals floating around and to distinguish them. Any comments here should be clarifying com...
Open Graph Description: Do not discuss the details of these in this bug! Go to the appropriate linked issue to discuss them This issue is to track all the various this proposals floating around and to distinguish them. An...
X Description: Do not discuss the details of these in this bug! Go to the appropriate linked issue to discuss them This issue is to track all the various this proposals floating around and to distinguish them. An...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/513
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Meta-issue: `this` disambiguator","articleBody":"# Do not discuss the details of these in this bug! Go to the appropriate linked issue to discuss them\n\nThis issue is to track all the various `this` proposals floating around and to distinguish them. Any comments here should be clarifying comments/questions.\n\n---\n### Specify `this` as a function return value\n#285\n\nLet type definitions specify that the type of a field (or maybe just function return values) is the same as the type that contains the property.\n\nExample:\n\n``` ts\ninterface Animal {\n clone(): this; // Today: clone(): Animal;\n self: this;\n}\ninterface Dog extends Animal { woof(); }\ninterface Cat extends Animal { meow(); }\nvar c: Cat;\nvar cc = c.clone(); // Desired: cc: Cat\ncc.meow(); // Desired: OK. Today: Fails\nvar ccc = cc.self; // Desired: ccc: Cat\n```\n\n---\n### Specify, as part of a function, the type of `this` inside the function body\n#229\n\nAllow a syntax to specify the type of `this` as part of a function expression.\n\nExample:\n\n``` ts\nfunction fn(this: HTMLElement) {\n this.focus(); // OK\n}\nfn(); // 'this' argument not visible externally. May or may not be error\n```\n\n---\n### Specify, as part of a function _type_, the type of `this` inside a function body\n\n(no issue yet, please leave a comment if you create one)\nAllow a syntax to specify that when a function is invoked, `this` will be of a certain type\n\nExample:\n\n``` ts\n// http://api.jquery.com/jquery.each/\nfunction jquery_each\u003cT>(items: T[], callback: (this: T, index: number, value: T) { /* ... */ }\njquery_each(['foo', 'bar'], () => console.log(this.substr(1));\n```\n\n---\n### Specify the what valid `this` values are during function invocation\n#15\n\nAdd type system logic to detect when a method is being invoked without a proper `this` context\n\n``` ts\nclass Foo {\n bar = 5;\n printBar() { console.log(this.bar); }\n}\nvar f = new Foo();\n// prints 'undefined', not '5'\nwindow.setImmediate(f.printBar); // Flag this as an error\n```\n","author":{"url":"https://github.com/RyanCavanaugh","@type":"Person","name":"RyanCavanaugh"},"datePublished":"2014-08-22T18:13:08Z","url":"https://github.com/microsoft/TypeScript/issues/513"}
| 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:ee652d86-a2e5-dcc9-4862-7d2d15ff5e4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BF2:60624:1ABB47:262FCF:6AFBFDB1 |
| html-safe-nonce | 7fd2924530707abcfc306de3ee776bff1a451399c9ff2474cc7c379cb9b79049 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkYyOjYwNjI0OjFBQkI0NzoyNjJGQ0Y6NkFGQkZEQjEiLCJ2aXNpdG9yX2lkIjoiNDYzNzM5NjI2OTk4MTc2MDk0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 22ba7860d7b19b1d4239a8687a6cf4b27c71e0b789511d4c55937f4d9256a2bb |
| hovercard-subject-tag | issue:40935256 |
| 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/513/issue_layout |
| twitter:image | https://opengraph.githubassets.com/97911ac322c4ffeeb7a9df3396df980c6287bfa7bd59088c89459ff53acb49c3/microsoft/TypeScript/issues/513 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/97911ac322c4ffeeb7a9df3396df980c6287bfa7bd59088c89459ff53acb49c3/microsoft/TypeScript/issues/513 |
| og:image:alt | Do not discuss the details of these in this bug! Go to the appropriate linked issue to discuss them This issue is to track all the various this proposals floating around and to distinguish them. An... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RyanCavanaugh |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width