Title: JSDoc optional property · Issue #39111 · microsoft/TypeScript · GitHub
Open Graph Title: JSDoc optional property · Issue #39111 · microsoft/TypeScript
X Title: JSDoc optional property · Issue #39111 · microsoft/TypeScript
Description: The JSDoc optional property syntax described on https://jsdoc.app/tags-property.html behaves unexpectedly. TypeScript Version: 3.9.5, Version 4.0.0-dev.20200615 Search Terms: jsdoc, optional Code /** * User type definition * @typedef {Ob...
Open Graph Description: The JSDoc optional property syntax described on https://jsdoc.app/tags-property.html behaves unexpectedly. TypeScript Version: 3.9.5, Version 4.0.0-dev.20200615 Search Terms: jsdoc, optional Code /...
X Description: The JSDoc optional property syntax described on https://jsdoc.app/tags-property.html behaves unexpectedly. TypeScript Version: 3.9.5, Version 4.0.0-dev.20200615 Search Terms: jsdoc, optional Code /...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/39111
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSDoc optional property","articleBody":"The JSDoc optional property syntax described on https://jsdoc.app/tags-property.html behaves unexpectedly.\r\n\r\n**TypeScript Version:** 3.9.5, Version 4.0.0-dev.20200615\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** jsdoc, optional\r\n\r\n**Code**\r\n\r\n```javascript\r\n/**\r\n * User type definition\r\n * @typedef {Object} User\r\n * @property {string} email\r\n * @property {string} [nickName]\r\n */\r\n\r\n/** @type {User} */\r\nconst user = {email: \"\"}; // as expected email is required, but nickName is not\r\nconst nickName = user.nickName; // expected type string|undefined, but type is string\r\n\r\n// expected error TS2532: Object is possibly 'undefined'.\r\nconsole.log(nickName.length)\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`nickName` has type `string|undefined`, and the `console.log` line should be an error with `strict` enabled\r\n\r\n**Actual behavior:**\r\n\r\n`nickName` has type `string`, no error reported even with `strict` enabled.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/lieser","@type":"Person","name":"lieser"},"datePublished":"2020-06-17T16:06:31Z","url":"https://github.com/microsoft/TypeScript/issues/39111"}
| 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:1593d512-e33e-b7d1-9481-24ff0b023529 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BFA:1EC9BC:AB8D34:DBFAC6:6B00F6EE |
| html-safe-nonce | 0abf5b6375ea3d935e6efeb77f7e1f33f4b1968bdf68be239b7b447366348c58 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkZBOjFFQzlCQzpBQjhEMzQ6REJGQUM2OjZCMDBGNkVFIiwidmlzaXRvcl9pZCI6IjMyMzMxNzE1ODYwMjY2MzI5NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d9e5a8d4934bf1d6a41960aca73e43e435e1b241bb9f2750335f5b18419b7f7b |
| hovercard-subject-tag | issue:640563913 |
| 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/39111/issue_layout |
| twitter:image | https://opengraph.githubassets.com/09d5a05aff7de540f00804f0e06f361b401f853b9992b39e8b4a597274e1ffe5/microsoft/TypeScript/issues/39111 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/09d5a05aff7de540f00804f0e06f361b401f853b9992b39e8b4a597274e1ffe5/microsoft/TypeScript/issues/39111 |
| og:image:alt | The JSDoc optional property syntax described on https://jsdoc.app/tags-property.html behaves unexpectedly. TypeScript Version: 3.9.5, Version 4.0.0-dev.20200615 Search Terms: jsdoc, optional Code /... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lieser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width