Handle synthetic tslib and JSX factory imports by jakebailey · Pull Request #780 · microsoft/typescript-go (original) (raw)

Fixes #765
Fixes #767

This implements import helper and JSX factory import node synthesis and resolution. Since the AST node is immutable, we cannot modify SourceFile.Imports. This info is now stored on the Program rather than at special fixed offsets in imports that's mutated after parse.

This could allow us to reuse ASTs more often, and means we stop having to work around these synthesized imports in other parts of the code (LS features, mainly).

This PR isn't perfect; it turns out we're missing implementations of moduleDetection and externalModuleIndicator, so we're not correctly determining that JSX files are modules because the jsx setting plays a part in determining if a file is a module (yay).

Fixing that will have to be a follow-up PR but that's going to be a lot more invasive. This PR fixes most stuff as it is now.