Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Re)load decorators and functions directly from TypeScript #533

Open
nguerrera opened this issue May 12, 2022 · 7 comments
Open

(Re)load decorators and functions directly from TypeScript #533

nguerrera opened this issue May 12, 2022 · 7 comments
Milestone

Comments

@nguerrera
Copy link
Contributor

See also proposal linked from #528.

We have the idea (option 1 there) to host the TypeScript compiler and consume TypeScript on the fly without a user build step. This hosting of the compiler could then be used to get the documentation and typing for decorators or Cadl-callable functions. We also have a desire to make it possible to change decorator and function definitions and immediately see the results in the IDE. Today, you have to restart the language server to observe any change to the JavaScript.

To keep work split, this issue tracks the experience of being able to write in TypeScript, save and see the results in Cadl immediately. It does not track doing anything with the JSDoc or TS typing yet. That will be left for other issues that will require further design. When we do this, though, we should have in mind that we intend to consume this data eventually, so it would be worth structuring the code for this eventuality and at least proving that we can get to the information even if we don't use it yet.

@ghost ghost added the Needs Triage label May 12, 2022
@markcowl markcowl added this to the Backlog milestone May 17, 2022
@tjprescott
Copy link
Member

+1 for being able to reload the decorators without reloading the IDE since I just wasted an hour troubleshooting this 😛

@nguerrera
Copy link
Contributor Author

Just a note that there is now Ctrl+P -> Restart Cadl Server option that should be faster than restarting the whole IDE. Still not great but perhaps a better workaround.

@tjprescott
Copy link
Member

Could we give that a keyboard shortcut? It will become part of my standard CADL troubleshooting ritual...
rush clean > update > rebuild > Restart Cadl Server

@nguerrera
Copy link
Contributor Author

You can assign one yourself. Search for cadl in File -> Preferences -> Keyboard Shortcuts.

@tjprescott
Copy link
Member

Is there not a way to set one as a repo setting? I'm thinking of how Ctrl+Shift+B starts up the three watch processes, but maybe that's a VS Code built-in thing...

@markcowl markcowl added the 📌 label Jul 5, 2022
@nguerrera
Copy link
Contributor Author

We are no longer depending on this for decorator and function typing so the priority was lowered and this is now on the backlog.

@timotheeguerin
Copy link
Member

A problem with this is the same as with --watch. We can detect which JS files are modified and force them to be reloaded but only for the ones we load directly. For any JS file that is loaded from another JS file we don't control that and it will always load the cache.
This used to be easy to clear before es modules but now we can't really do that.

Some option is to run the js code of typescript inside nodejs VM but that is still experimental as of node 20 for es modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants