Hi everyone,

 

I’d like to continue the discussion from our last typing summit on explicit type aliases. A quick summary of the current state and the proposal --

 

Current state:

```

from typing import List

 

x = List[int]  # considered a type alias

y : Type[List[int]] = List[int]  # considered an expression

z : Any  # considered a type alias

 

z : x = []  # fine

z : y = []  # invalid type error

```

 

Proposal (with explicit aliases):

```

from typing import List, TypeAlias

 

x = TypeAlias[List[int]]    # considered a type alias

y = List[int]  # considered an expression

z : Any  # considered an expression

z = TypeAlias[Any]  # considered a type alias

 

reveal_type(x)  # Type[List[int]]

reveal_type(y)  # Any  (return type of __getitem__)

 

z : x  = []  # fine

z : y = []  # invalid type error

```

 

Some of the benefits we’re hoping to gain from explicit type aliases:

 

Note: We also considered denoting the alias as an annotation (e.g. `x: TypeAlias = int`) as an alternative to the syntax above.

 

I’m interested to hear your thoughts and suggestions on making type aliasing explicit going forward – we’d like to start implementing a version of this in Pyre soon!

 

Shannon