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

Add example using TypeScript in webviews #895

Closed
adamerose opened this issue Jul 4, 2023 · 2 comments
Closed

Add example using TypeScript in webviews #895

adamerose opened this issue Jul 4, 2023 · 2 comments
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@adamerose
Copy link

Currently the docs and examples have all webview logic inside a .js IIFE [1] or a raw string [2]. I would prefer to have all my extension code in TypeScript including the webview logic and the message passing between my extension and webview. I think a new example template showing how to properly do this would be very helpful.

I was able to find some unofficial resources on this [3 - 7] but testing and putting everything together isn't trivial and I'd rather not have to roll my own separate config and build process.

Reference

  1. https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/media/main.js
  2. https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension
  3. https://stackoverflow.com/questions/54135313/webview-extension-in-typescript
  4. https://stackoverflow.com/questions/71077130/vscode-extension-custom-editor-with-webview-both-on-typescript
  5. https://stackoverflow.com/questions/56237448/how-to-make-acquirevscodeapi-available-in-vscode-webview-react
  6. https://github.com/rebornix/vscode-webview-react
  7. https://github.com/microsoft/vscode-webview-ui-toolkit/blob/main/docs/getting-started.md#update-esbuild-config
@adamerose
Copy link
Author

Actually now that I've spent more time reading, it seems like this is exactly what I wanted: https://github.com/microsoft/vscode-webview-ui-toolkit-samples

I think this repo should be mentioned in the VS Code webview docs because it seems like this is the 'right' way to develop a webview extension for anyone starting a new project.

@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Oct 2, 2023
@VSCodeTriageBot
Copy link
Collaborator

Please ask your question on StackOverflow. We have a great community over there. They have already answered thousands of questions and are happy to answer yours as well. See also our issue reporting guidelines.

Happy Coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants