mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
b79a5289fc21647b444eca397b5a02d5b64f5d2b
The goal of this PR is to move towards a uniform representation for all type declarations, whether they are named type aliases, function declarations, or inline annotations. We now assign every non-primitive type declaration (named or anonymous) a unique DeclarationId. In the next PR, we'll also re-map inline annotations back to this declaration id when encountering them. This PR is extremely gross and my intent is to refactor a bunch of things in the HIR to allow this to be less gross. Challenges: * Babel name resolution requires using scopes but i really want to just work with plain nodes, since NodePath and TypeScript do _not_ get along. So here, i find all identifiers and store a mapping of identifier -> scope, so that i can later look them up if necessary. * HIR doesn't have a notion of a declaration id, and in general we don't want to extend HIR. So i end up with a whole bunch of side table information and indirection. For example, a function doesn't know it's own declaration id. So we have to look it up. Function params don't track their Forest type, so we have to look them up on the function declaration. Etc.
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%