Title: Suggestion: typedefs · Issue #308 · microsoft/TypeScript · GitHub
Open Graph Title: Suggestion: typedefs · Issue #308 · microsoft/TypeScript
X Title: Suggestion: typedefs · Issue #308 · microsoft/TypeScript
Description: Suggestion: Allow typedefs for aliasing types, class names and interface names Use case: // 1. Use case overlaps with interface functions types and is even uglier typedef (number) => number MyCallback; // 2. With generics typedef Vector<...
Open Graph Description: Suggestion: Allow typedefs for aliasing types, class names and interface names Use case: // 1. Use case overlaps with interface functions types and is even uglier typedef (number) => number MyCallb...
X Description: Suggestion: Allow typedefs for aliasing types, class names and interface names Use case: // 1. Use case overlaps with interface functions types and is even uglier typedef (number) => number MyCa...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/308
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: typedefs","articleBody":"**Suggestion: Allow typedefs for aliasing types, class names and interface names**\n\nUse case:\n\n``` javascript\n// 1. Use case overlaps with interface functions types and is even uglier\ntypedef (number) =\u003e number MyCallback;\n\n// 2. With generics\ntypedef Vector\u003cSomeDataType\u003e MyVector;\n\n// 3. With primitive data types\ntypedef string MyData;\n\n// 4. Aliasing classes and interfaces\ntypedef ReallyLongClassName ShortName;\ntypedef otherModule.subModule.subModule.Runnable Runnable;\n```\n\n**Question: Do we need them?**\n1. Assigning a name to function types is already possible using [interface function types](http://www.typescriptlang.org/Handbook#interfaces-function-types). In my opinion, their syntax is nicer and we should not introduce another syntax for the same feature.\n2. This can help minimzing the amount of typing.\n3. According to the last comment of the [original CodePlex issue](http://typescript.codeplex.com/workitem/119), this can help commenting the code. It does however introduce another layer of name aliasing for names which are already short (`number, string, boolean`).\n4. This can also help minimzing the amount of typing, especially for accessing external classes and interfaces inside deeply nested modules. Aliasing modules themselves would also be imaginable.\n\n---\n\nThe original CodePlex issue: http://typescript.codeplex.com/workitem/119\nNote that many of the given code examples are already covered by #14 (union types).\n","author":{"url":"https://github.com/ComFreek","@type":"Person","name":"ComFreek"},"datePublished":"2014-07-30T10:56:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/308/TypeScript/issues/308"}
| 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:4ae1c678-be11-d83d-0cc9-cf1cd966fd8b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 837C:1B3B59:2033F9F:2C176BF:6A6305AC |
| html-safe-nonce | 12ed782cd4b6db4086cc922204a9aa1e75596124722832c790dae4c7ccb7577b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzdDOjFCM0I1OToyMDMzRjlGOjJDMTc2QkY6NkE2MzA1QUMiLCJ2aXNpdG9yX2lkIjoiODE4MjUzMTAyOTkyNjYxMDM0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 31636badc4b21f9904326842193ecffa049333bfc4ca2b58b003321e7257f8b3 |
| hovercard-subject-tag | issue:39081024 |
| 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/308/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f5cacf29bfd6b179d91b0ed1ceb8b4d90d9698b90f3c19ac811c4a7c253f9517/microsoft/TypeScript/issues/308 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f5cacf29bfd6b179d91b0ed1ceb8b4d90d9698b90f3c19ac811c4a7c253f9517/microsoft/TypeScript/issues/308 |
| og:image:alt | Suggestion: Allow typedefs for aliasing types, class names and interface names Use case: // 1. Use case overlaps with interface functions types and is even uglier typedef (number) => number MyCallb... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ComFreek |
| hostname | github.com |
| expected-hostname | github.com |
| None | b48e7bf0b1945d51f303503b057abf666ce74c3efbe107b413db2bb921c3f012 |
| 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 | 9370f37042c29822d6ba7e3f670f0036a0155b21 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width