I am making a webview for my vscode extension. All the extension related code is in typescript and for webview , within Script tag of html, can i use typescript instead of javascript? If yes how?
js file, also we can use script. js file in HTML page. For using script file in index. html file, use <script> tag to use script file, same as what we do for javascript file.
The <script> Tag You can place any number of scripts in an HTML document. Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.
You can't use TypeScript directly in a web page the same way you'd be able to use JavaScript -- that is, you can't add a <script> tag and point directly at a TypeScript file as your src, nor can you enter TypeScript between script tags. TypeScript has to be compiled into JavaScript for a web browser to understand it.
In fact you can not do this directly because the browser only understands JavaScript but you can do it but after you install the typescript-compile library.
Typescript needs to be transpiled to javascript and browser only understands JS.
So you can include your Typescript code in html like this here but it needs to be traspiled into JS.
Read more about it here and this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With