Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Suggestion: typedefs #308

Copy link
Copy link
@ComFreek

Description

@ComFreek
Issue body actions

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<SomeDataType> MyVector;

// 3. With primitive data types
typedef string MyData;

// 4. Aliasing classes and interfaces
typedef ReallyLongClassName ShortName;
typedef otherModule.subModule.subModule.Runnable Runnable;

Question: Do we need them?

  1. Assigning a name to function types is already possible using interface function types. In my opinion, their syntax is nicer and we should not introduce another syntax for the same feature.
  2. This can help minimzing the amount of typing.
  3. According to the last comment of the original CodePlex issue, this can help commenting the code. It does however introduce another layer of name aliasing for names which are already short (number, string, boolean).
  4. 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.

The original CodePlex issue: http://typescript.codeplex.com/workitem/119
Note that many of the given code examples are already covered by #14 (union types).

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.