Attributes: Type Checking

The type checker can check user attributes by their listing in the typechecker's .hhconfig file. If you put the following line in your .hhconfig:

user_attributes = UserAttr1 UserAttr2 .....

then the typechecker will verify any use of user attributes against this list in .hhconfig and error if it sees a user attribute in code that is not in the list.

The primary use case for this is misspellings -- without any enforcement of what attributes are valid, misspelled attributes might silently be ignored!

<?hh

namespace Hack\UserDocumentation\Attributes\TypeChecking\Examples\Misspell;

<<UserAttr("Hello")>> // Good
class Foo {}

<<EasyToMispell>>     // Error
class Bar {}

<<CASEISIMPORTANT>>   // Error
class Baz {}

<<NotListed>>         // Error
class Yaz {}
Output

Special Attributes

Special attributes are not typechecked in this way. This is only for custom user attributes.