Title: Declare a type with a JSON file instead of an interface · Issue #23898 · microsoft/TypeScript · GitHub
Open Graph Title: Declare a type with a JSON file instead of an interface · Issue #23898 · microsoft/TypeScript
X Title: Declare a type with a JSON file instead of an interface · Issue #23898 · microsoft/TypeScript
Description: Search Terms typescript json interface file Suggestion I have this question on SO: https://stackoverflow.com/questions/50181254/static-typing-with-json-and-typescript?noredirect=1#comment87380729_50181254 Why can't we declare a TS type b...
Open Graph Description: Search Terms typescript json interface file Suggestion I have this question on SO: https://stackoverflow.com/questions/50181254/static-typing-with-json-and-typescript?noredirect=1#comment87380729_5...
X Description: Search Terms typescript json interface file Suggestion I have this question on SO: https://stackoverflow.com/questions/50181254/static-typing-with-json-and-typescript?noredirect=1#comment87380729_5...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23898
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Declare a type with a JSON file instead of an interface","articleBody":"\r\n## Search Terms\r\n\r\ntypescript json interface file\r\n\r\n## Suggestion\r\n\r\nI have this question on SO:\r\nhttps://stackoverflow.com/questions/50181254/static-typing-with-json-and-typescript?noredirect=1#comment87380729_50181254\r\n\r\nWhy can't we declare a TS type based on a .json file? Something like this:\r\n\r\n```js\r\nexport type MyInterface = typeof 'path/to/json/file.json'\r\n```\r\n\r\nit seems like a no-brainer to me, but maybe I am stupid.\r\n\r\n## Use Cases\r\n\r\nKeep things DRY. Use JSON files as interfaces.\r\n\r\n## Examples\r\n\r\nDone did.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n [x] This wouldn't be a breaking change in existing TypeScript / JavaScript code\r\n [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n [x] This could be implemented without emitting different JS based on the types of the expressions\r\n [x] This isn't a runtime feature (e.g. new expression-level syntax)\r\n\r\n","author":{"url":"https://github.com/ORESoftware","@type":"Person","name":"ORESoftware"},"datePublished":"2018-05-04T19:52:19Z","url":"https://github.com/microsoft/TypeScript/issues/23898"}
| 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:0903b20e-07a5-ec94-130c-cee3d340f9b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A668:19F84C:2D14A93:39518DE:6B01A2B1 |
| html-safe-nonce | 9cfcd761d08cc168166f5b7499a8b27f7a65c88fad70304dad5e4c822fef3e63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjY4OjE5Rjg0QzoyRDE0QTkzOjM5NTE4REU6NkIwMUEyQjEiLCJ2aXNpdG9yX2lkIjoiMzY4NDU1ODk1MjE4NTU2OTk2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e754afab7216f2ae7a794d2b3cc49ec94eef23c8d97c198a34c47da4a2c3dd2a |
| hovercard-subject-tag | issue:320406006 |
| 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/23898/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0dc47fd5a9c21e41f0de83e4fe2d0b881b170a70f8b2ad32d0c020ce121d4ae0/microsoft/TypeScript/issues/23898 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0dc47fd5a9c21e41f0de83e4fe2d0b881b170a70f8b2ad32d0c020ce121d4ae0/microsoft/TypeScript/issues/23898 |
| og:image:alt | Search Terms typescript json interface file Suggestion I have this question on SO: https://stackoverflow.com/questions/50181254/static-typing-with-json-and-typescript?noredirect=1#comment87380729_5... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ORESoftware |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width