Title: Excess properties are not checked e.g. in callbacks · Issue #7547 · microsoft/TypeScript · GitHub
Open Graph Title: Excess properties are not checked e.g. in callbacks · Issue #7547 · microsoft/TypeScript
X Title: Excess properties are not checked e.g. in callbacks · Issue #7547 · microsoft/TypeScript
Description: This might be a feature, but it sure is odd. The excess property check is not working on callbacks, e.g.: interface Test { name?: string; } function myMutator(fn: () => Test) { return fn(); } /* Not an error */ let a: Test = myMutator(()...
Open Graph Description: This might be a feature, but it sure is odd. The excess property check is not working on callbacks, e.g.: interface Test { name?: string; } function myMutator(fn: () => Test) { return fn(); } /* No...
X Description: This might be a feature, but it sure is odd. The excess property check is not working on callbacks, e.g.: interface Test { name?: string; } function myMutator(fn: () => Test) { return fn(); } /*...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7547
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Excess properties are not checked e.g. in callbacks","articleBody":"This might be a feature, but it sure is odd. The excess property check is not working on callbacks, e.g.:\n\n``` typescript\ninterface Test {\n name?: string;\n}\n\nfunction myMutator(fn: () => Test) {\n return fn();\n}\n\n/* Not an error */\nlet a: Test = myMutator(() => ({\n notAProperty : \"woot?\"\n}));\n\n/* This gives error */\nfunction test(): Test {\n return {\n notAProperty : \"what\"\n }\n}\n\n/* This gives error */\nlet b: Test = {\n notAProperty : \"huh\"\n};\n```\n\nIs there a trick to enforce the excess property check in situations like the one above?\n\n[Here is a link to playground.](http://www.typescriptlang.org/Playground#src=interface%20Test%20%7B%0A%09name%3F%3A%20string%3B%0A%7D%0A%0Afunction%20myMutator%28fn%3A%20%28%29%20%3D%3E%20Test%29%20%7B%0A%09return%20fn%28%29%3B%0A%7D%0A%0A%2F*%20Not%20an%20error%20*%2F%0Alet%20a%3A%20Test%20%3D%20myMutator%28%28%29%20%3D%3E%20%28%7B%0A%09notAProperty%20%3A%20%22woot%3F%22%0A%7D%29%29%3B%0A%0A%2F*%20This%20gives%20error%20*%2F%0Afunction%20test%28%29%3A%20Test%20%7B%0A%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20notAProperty%20%3A%20%22what%22%0A%20%20%20%20%7D%0A%7D%0A%0A%2F*%20This%20gives%20error%20*%2F%0Alet%20b%3A%20Test%20%3D%20%7B%0A%09notAProperty%20%3A%20%22huh%22%0A%7D%3B%0A)\n","author":{"url":"https://github.com/Ciantic","@type":"Person","name":"Ciantic"},"datePublished":"2016-03-16T19:04:11Z","url":"https://github.com/microsoft/TypeScript/issues/7547"}
| 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:2bcb6438-da7a-ebcc-71aa-66bd8388dd27 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFA4:24ACB9:2BD84B:3AE029:6B00C280 |
| html-safe-nonce | 311c15c2a8013e59603ca827051439d3136142bf034d796786950e0063cfb0ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkE0OjI0QUNCOToyQkQ4NEI6M0FFMDI5OjZCMDBDMjgwIiwidmlzaXRvcl9pZCI6IjcxNDEyMzc5ODg4MDA5MDU4NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d7ff16095ab1a773d72da50a1e3952b996ff10472a0711efafa0211c1694abad |
| hovercard-subject-tag | issue:141371336 |
| 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/7547/issue_layout |
| twitter:image | https://opengraph.githubassets.com/234a70d1265c3a28d07c596eacada70a728e87ffb369193da66dc46d4ee0daa2/microsoft/TypeScript/issues/7547 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/234a70d1265c3a28d07c596eacada70a728e87ffb369193da66dc46d4ee0daa2/microsoft/TypeScript/issues/7547 |
| og:image:alt | This might be a feature, but it sure is odd. The excess property check is not working on callbacks, e.g.: interface Test { name?: string; } function myMutator(fn: () => Test) { return fn(); } /* No... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Ciantic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| 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 | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width