Closed miguel-nascimento closed 9 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
zipper-run | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jan 31, 2024 6:45pm |
argh, i will clean this later
Merged the branches in wrong order
This PR enable us to import types and use they in the handler function, creating UI using those imported types.
Due to the Issue 1 and a bit of Issue 4, this PR only works with external imports types inside zipper.dev.
How? The parse function now takes a context: the
Project
fromts-morph
With this context, we can navigate around, filling holes with type definition from other files.This context persist after the parser, we're creating the Project once per project
The major issue is the remote imports, we need them in our context too. We're adding those remote modules when we can't find the module in the local context, then, we check if the import is an external one, if so, we fetch the bundle using the
/api/editor/ts/bundle/x?=<specifier>
endpoint. [1] [2]With the remote module in our context, we can proceed to use the compiler to get the definition.
[1] Issue: The import specifier is the raw specifier. The bundle/x endpoint returns specifiers with version, which may be different from the original import specifier, due to the rewrite specifier rules. ❓
[2] Possible issue: We're adding external modules to the Project, but we're not removing the unneeded modules. (not planning to fix it rn)
[3] Issue: External types solving only triggers on the second parse execution, after a keystroke on the editor
[4] Issue: We're not parsing
interface A extends B
. We can do this later, improving the parse type (concrete, resolved typescript type, and not type node)