text/typescript
1 min readJan 5, 2024
You can now use TypeScript directly in HTML Script tags.
<script type="text/typescript">
// Your TypeScript code here
</script>
And to make it work, also load the dependencies.
<script src="https://cdn.jsdelivr.net/npm/typescript@5.3.3"></script>
<script defer src="https://cdn.jsdelivr.net/npm/text-typescript@1.3.0"></script>
It uses the text/typescript library which was written specifically for the purpose.
Here is a complete working HTML containing TypeScript that you can copy.