Title: Interfaces with all members optional is almost the same as 'any' · Issue #9841 · microsoft/TypeScript · GitHub
Open Graph Title: Interfaces with all members optional is almost the same as 'any' · Issue #9841 · microsoft/TypeScript
X Title: Interfaces with all members optional is almost the same as 'any' · Issue #9841 · microsoft/TypeScript
Description: TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx) Code interface AllMembersOptional { first?: string; second?: number; } let a: AllMembersOptional = 7; let b: AllMembersOptional = () => 7; Expected behavior: compiler error '7' is ...
Open Graph Description: TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx) Code interface AllMembersOptional { first?: string; second?: number; } let a: AllMembersOptional = 7; let b: AllMembersOptional = () => 7; E...
X Description: TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx) Code interface AllMembersOptional { first?: string; second?: number; } let a: AllMembersOptional = 7; let b: AllMembersOptional = () => 7...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9841
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Interfaces with all members optional is almost the same as 'any'","articleBody":"**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx)\n\n**Code**\n\n``` ts\ninterface AllMembersOptional {\n first?: string;\n second?: number;\n}\n\nlet a: AllMembersOptional = 7;\nlet b: AllMembersOptional = () => 7;\n```\n\n**Expected behavior:**\ncompiler error '7' is not type AllMembersOptional -- let a: AllMembersOptional = 7;\ncompiler error 'function: number' is not type AllMembersOptional -- let b: AllMembersOptional = () => 7;\n\n**Actual behavior:** \nno compiler errors or warnings and the following javascript is generated:\n\n``` js\nvar a = 7;\nvar b = function () { return 7; };\n```\n\n**Actual example**\nReferencing angular.d.ts and converting an angular directive \n\n``` ts\nangular.module('test').directive('custom', function () {\n return {\n controller: 'testCtrl',\n template: '\u003cdiv>\u003c/div>,\n //...\n };\n});\n```\n\ncarelessly into a component\n\n``` ts\nangular.module('test').component('custom', function () {\n return {\n controller: 'testCtrl',\n template: '\u003cdiv>\u003c/div>,\n //...\n };\n});\n```\n\ngenerates no typescript compiler error messages and will fail at run-time because the options parameter needs to be an object \n\n``` ts\nangular.module('test').component('custom', {\n controller: 'testCtrl',\n template: '\u003cdiv>\u003c/div>,\n //...\n }\n);\n```\n\noptions parameter cannot a function (or number or string etc). \nJust about anything passed in for a parameter of an interface type with all optional parameters will be allowed by typescript\n","author":{"url":"https://github.com/bman61","@type":"Person","name":"bman61"},"datePublished":"2016-07-20T15:47:05Z","url":"https://github.com/microsoft/TypeScript/issues/9841"}
| 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:11941c01-c15f-6dd8-235e-fd6764e993c4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A6A:13CF23:2B0351:399972:6B009DC9 |
| html-safe-nonce | 671aa104aa40b564d6e5c2a1f2e5cf5e5238515cb4264c1e2d5327aba7e9102c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTZBOjEzQ0YyMzoyQjAzNTE6Mzk5OTcyOjZCMDA5REM5IiwidmlzaXRvcl9pZCI6IjQwNDg4NTMyOTM2Mzg2NTU0MzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b637f161afcf2b6ea456d246f735b242a2714b0c0391eb7ce030f588bcb27899 |
| hovercard-subject-tag | issue:166615112 |
| 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/9841/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1db3376fcaae3bb6335df87570afa69bb2359637cddc296f92f4a6afe95655b6/microsoft/TypeScript/issues/9841 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1db3376fcaae3bb6335df87570afa69bb2359637cddc296f92f4a6afe95655b6/microsoft/TypeScript/issues/9841 |
| og:image:alt | TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx) Code interface AllMembersOptional { first?: string; second?: number; } let a: AllMembersOptional = 7; let b: AllMembersOptional = () => 7; E... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bman61 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 52c95ce7e48016ae14399656b4ee812462b6f1fa28c5008c8394da64794c00b8 |
| 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 | 1c9ddec8215f9a94e295c8310c3579b9c54ba31a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width