Title: Can we define a ReadOnly interface directly? · Issue #17769 · microsoft/TypeScript · GitHub
Open Graph Title: Can we define a ReadOnly interface directly? · Issue #17769 · microsoft/TypeScript
X Title: Can we define a ReadOnly interface directly? · Issue #17769 · microsoft/TypeScript
Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code There three ways we can define a readonly type or interface. // First type ReadonlyState = Readonly<{ foo: string, bar: string, }> // Second interface ReadonlyState2 { readonl...
Open Graph Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code There three ways we can define a readonly type or interface. // First type ReadonlyState = Readonly<{ foo: string, bar: string, }> // S...
X Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code There three ways we can define a readonly type or interface. // First type ReadonlyState = Readonly<{ foo: string, bar: string, }>...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17769
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can we define a ReadOnly interface directly?","articleBody":"**TypeScript Version:** 2.4.0 / nightly (2.5.0-dev.201xxxxx)\r\n\r\n**Code**\r\nThere three ways we can define a readonly type or interface.\r\n\r\n```ts\r\n// First\r\ntype ReadonlyState = Readonly\u003c{\r\n foo: string,\r\n bar: string,\r\n}>\r\n\r\n// Second\r\ninterface ReadonlyState2 {\r\n readonly foo: string,\r\n readonly bar: string,\r\n}\r\n\r\n// Third\r\ninterface State3 {\r\n foo: string,\r\n bar: string,\r\n}\r\n\r\ntype ReadonlyState3 = Readonly\u003cState3>\r\n```\r\n\r\nThe first one we can get the readonly type directly and it's easy to writing.\r\nThe second one, we can get the readonly interface, but if there are more properties we have to repeatedly declare its readonly modifier.\r\nThe third one, we can get the readonly interface directly, it assign a non-readonly interface to a type. And the State3 seems should be eliminated.\r\n\r\n**Whether we have a way to define a readonly interface just like the first way does?**\r\n\r\nI expect to define a React State interface directly which is readonly.","author":{"url":"https://github.com/zheeeng","@type":"Person","name":"zheeeng"},"datePublished":"2017-08-14T01:25:26Z","url":"https://github.com/microsoft/TypeScript/issues/17769"}
| 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:e34b11cd-8627-0e1e-f0cd-9ac2b4a343ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E714:96DDF:A8A466:D6A281:6B00F24E |
| html-safe-nonce | 0a2a1c3b7e6f5f86ec20fa7e84e7a14b760dd0299687d03c0070f261f14c90b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzE0Ojk2RERGOkE4QTQ2NjpENkEyODE6NkIwMEYyNEUiLCJ2aXNpdG9yX2lkIjoiMjE0Mzc5MDA3OTk3NzAyNzM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a42761bd88b0109b19f858000f060fc069db564a6bd6fdd74a3ec3d2b3a9bd4c |
| hovercard-subject-tag | issue:249912984 |
| 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/17769/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d605f14aee3951458ca1ada8f32761184cb6712a6864e91c38986ea2ad64f8ac/microsoft/TypeScript/issues/17769 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d605f14aee3951458ca1ada8f32761184cb6712a6864e91c38986ea2ad64f8ac/microsoft/TypeScript/issues/17769 |
| og:image:alt | TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code There three ways we can define a readonly type or interface. // First type ReadonlyState = Readonly<{ foo: string, bar: string, }> // S... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zheeeng |
| 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