Does TypeScript allow type aliases? -


So I want to use a nickname in an ugly way that looks like this:

  core Maybe & lt; Core.Promise & lt; Info.paged & lt; Info.Carrier & gt; Corner. Problem & gt; & Gt; []  

Something like this:

  import pu = core Maybe & lt; Core. Light & lt; Info.paged & lt; Info.Carrier & gt; Core Problem & gt; [];  

Is there a way to type alias in typecript?

supports version 1.4 type alias () from type 1.4.

Type aliases

Now you can define a type of nickname using type keywords:

  Type PrimitiveArray = Array & lt; String | Number | Boolean & gt;; Type MyNumber = number; Type NgScope = ng.IScope; Type callback = () = & gt; Zero;  

Type nicknames are exactly the same as their original type; They are only alternative names.

and Version 1.6 supports Typecape generic type aliases ().

Generic Type Alias ​​

Leading up to TypeScript 1.6, type nicknames were restricted to simple aliases that shorten long names I went. Unfortunately, without being able to make these generic, they had limited use. Now we allow Type Elias to be generic, give them full expression capability.

  type switchro & lt; T, U & gt; = (U: U, T: t) => T; Var f: switchroom & lt; Number, string> F ("Bob", 4);  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -