This Facebook example shows, how Hack transpiler removes Transformable
type hint from both transform()
and wonderland()
functions. Why? Is Transformable
some built-in Hack interface or class?
Asked
Active
Viewed 77 times
1

Vladislav Rastrusny
- 29,378
- 23
- 95
- 156
1 Answers
2
It's not anything special at all. It's just an example of an arbitrary type annotation. One of the things that the tool does is remove type annotations, such as Transformable
(assuming you had a class called Transformable
yourself), or Foo
, or Blah
, or any other class you define. There's nothing special about Transformable
at all.

Josh Watzman
- 7,060
- 1
- 18
- 26
-
And why Hack removes type hints (they are not type `@annotation`s btw, but type hints, they are the part of php)? They do runtime type checking and they make code more readable. – Vladislav Rastrusny Nov 17 '14 at 07:38
-
1The annotations Hack has are not quite like those of PHP. For example, Hack has primitive type annotations such as `int` and `string`. PHP does have class/interface annotations, but a couple work differently in Hack -- for example, an array passes a `Traversable` annotation in Hack. It would be possible to leave the intersection of what Hack and PHP support in place, but actually figuring out if a given annotation lives in that intersection can be surprisingly tricky -- so, for simplicity, we removed them all in the initial release. This is a definite area for future improvement though! – Josh Watzman Nov 17 '14 at 08:10