Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

4.14.0: removal of `Missing`, much stricter typing

Compare
Choose a tag to compare
@fredemmott fredemmott released this 15 Jul 19:38

This release contains several major breaking changes:

  • the Facebook\HHAST\Linters\ and Facebook\HHAST\Migrations\ namespaces have been removed - the contents are now directly in the Facebook\HHAST\ namespace. This may require changes to blacklist/whitelist rules in hhast-lint.json
  • the Missing node type has been removed; fileds that contain SomeSpecifcNode or Missing are now typed as returning ?SomeSpecificNode instead of just Node
  • fields are now consistently typed, including in constructors; for example, it is no longer possible to create an ElseifClause with a keyword that is anything other than an ElseifToken, and Leading/Trailing trivia on tokens is always a NodeList<Trivia>
  • HHAST is now less willing to handle invalid Hack code
  • UnparsedReplacementCodeNode has been removed.
  • Node::insertAfter(), ::insertBefore(), and ::without() have been removed, as they can not be implemented in such a root class with the changes to typing.

These breaking changes seem to have more impact on unit tests than on real code; for example, tests for methods have often included code like class Foo { function bar(): void {} with a missing closing brace for the class, leading to expected nonnull errors; missing semicolons are also common in test cases. These kind of errors do not often occur in real code, as they lead to immediate errors in both the typechecker and runtime.

Non-breaking improvements include:

  • NodeList::insertBefore(), ::insertAfter(), ::withoutChild() and ::withoutItemWithChild() have been added
  • NodeList::isEmpty() and NodeList::getCount() have been added
  • empty namespace bodies are now correctly processed when resolving namespace uses
  • error messages for invalid trees now include code snippets