Skip to content

Suggestion: typedefs #308

Closed
Closed
@ComFreek

Description

@ComFreek

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions