Title: Update documentation to mention that --strictNullChecks flag is necessary for --strictPropertyInitialization to have an effect · Issue #23659 · microsoft/TypeScript · GitHub
Open Graph Title: Update documentation to mention that --strictNullChecks flag is necessary for --strictPropertyInitialization to have an effect · Issue #23659 · microsoft/TypeScript
X Title: Update documentation to mention that --strictNullChecks flag is necessary for --strictPropertyInitialization to have an effect · Issue #23659 · microsoft/TypeScript
Description: TypeScript Version: 2.7.0 and above. Search Terms: strictNullChecks strictPropertyInitialization Code class C { foo: number; bar = "hello"; baz: boolean; constructor() { this.foo = 42; } } Expected behavior: TS documentation should menti...
Open Graph Description: TypeScript Version: 2.7.0 and above. Search Terms: strictNullChecks strictPropertyInitialization Code class C { foo: number; bar = "hello"; baz: boolean; constructor() { this.foo = 42; } } Expected...
X Description: TypeScript Version: 2.7.0 and above. Search Terms: strictNullChecks strictPropertyInitialization Code class C { foo: number; bar = "hello"; baz: boolean; constructor() { this.foo = 42; } ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23659
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Update documentation to mention that --strictNullChecks flag is necessary for --strictPropertyInitialization to have an effect ","articleBody":"**TypeScript Version:**\r\n2.7.0 and above.\r\n\r\n**Search Terms:** \r\nstrictNullChecks strictPropertyInitialization\r\n\r\n**Code**\r\n```ts\r\nclass C {\r\n foo: number;\r\n bar = \"hello\";\r\n baz: boolean;\r\n\r\n constructor() {\r\n this.foo = 42;\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nTS documentation should mention that `--strictNullChecks` flag is needed for `--strictPropertyInitialization` one to actually have an effect.\r\nThis would properly document the actual code change in this [commit](https://github.com/Microsoft/TypeScript/commit/8cbff0159df1792e7d3bd87946b99a4eed042e4c#diff-c3ed224e4daa84352f7f1abcd23e8cca) : \r\n\r\nThis was clearly mentionned in the [corresponding PR](https://github.com/Microsoft/TypeScript/pull/20075) description.\r\nAlso @mihailik [suggested that a warning could also be emitted](https://github.com/Microsoft/TypeScript/pull/20075#issuecomment-346058031). Has this been done?\r\n\r\n**Actual behavior:**\r\nThis is mentioned nowhere in the documentation.\r\nDocumentation for `--strictPropertyInitialization` is _Ensure non-undefined class properties are initialized in the constructor._.\r\nTo determine if a class property is _non-undefined_, `--strictNullChecks` flag must be turned on.\r\n\r\n**Playground Link:**\r\nhttp://www.typescriptlang.org/play/#src=class%20C%20%7B%0D%0A%20%20%20%20foo%3A%20number%3B%0D%0A%20%20%20%20bar%20%3D%20%22hello%22%3B%0D%0A%20%20%20%20baz%3A%20boolean%20%7C%20undefined%3B%0D%0A%0D%0A%20%20%20%20constructor()%20%7B%0D%0A%20%20%20%20%20%20%20%20this.foo%20%3D%2042%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Aconst%20foo%3A%20string%20%3D%20%22fdsf%22%3B\r\n\r\n**Related Issues:**\r\nI found no existing issue for updating the documentation about this.","author":{"url":"https://github.com/loicraux","@type":"Person","name":"loicraux"},"datePublished":"2018-04-24T16:38:46Z","url":"https://github.com/microsoft/TypeScript/issues/23659"}
| 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:92b1823a-07f1-ef18-4511-4a4c66476d5d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8ACE:21AC3F:9F375B:CD6A1F:6B00DF60 |
| html-safe-nonce | b99c85f2baa399204b0bb93becfaada4c31658953fa0198de86e7bd1a2640495 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUNFOjIxQUMzRjo5RjM3NUI6Q0Q2QTFGOjZCMDBERjYwIiwidmlzaXRvcl9pZCI6IjczNDE2Njk1MDEwMjY0OTIyNTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2b2d00e4833d835997894c23880586ce5b8c1408b3b298f9627c7bc3cf3395e7 |
| hovercard-subject-tag | issue:317306807 |
| 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/23659/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb14979249f26bacbad7808345e63abf0359ec18e8e6ec28e64e27e23d14b23e/microsoft/TypeScript/issues/23659 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb14979249f26bacbad7808345e63abf0359ec18e8e6ec28e64e27e23d14b23e/microsoft/TypeScript/issues/23659 |
| og:image:alt | TypeScript Version: 2.7.0 and above. Search Terms: strictNullChecks strictPropertyInitialization Code class C { foo: number; bar = "hello"; baz: boolean; constructor() { this.foo = 42; } } Expected... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | loicraux |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width