I want my IIS to correctly display .ts files, is there any MIME-Type for TypeScript? text/javascript or similar may also work, but are there specifications for that?
I already looked up the language specification but I didn't find any clue.
Multipurpose Internet Mail Extension or MIME is an internet standard, encoded file format used by email programs. The mime format contains 8-bit encoded data instead of commonly used 7-bit encoding for sending email. Thus, MIME files can contain file attachments and richer character sets other than ASCII.
For detecting MIME-types, use the aptly named "mimetype" command. It has a number of options for formatting the output, it even has an option for backward compatibility to "file". But most of all, it accepts input not only as file, but also via stdin/pipe, so you can avoid temporary files when processing streams.
Whereas file extensions are commonly used for your OS to decide what program to open a file with, Mime types are used by your browser to decide how to present some data (or the server on how to interpret received data). Both are optional but it's a good practice to have an agreement.
It would be good to know why you want to serve TypeScript files.
As far as I understand, TypeScript is used to compile to Javascript, which is then executed in a browser. Currently, there is no native support for TypeScript (correct me if I'm wrong).
If you still want to serve .ts files via IIS, you can still add a custom mime-type in IIS Admin associated with .ts. The standard defines the prefixes x.
, vnd.
and prs.
, and the vnd. prefix is also listed in the standardized mime types text/ and application/.
So, depending on your usage, you might choose text/x.typescript
or text/prs.typescript
.
Stick this in your web.config;
<configuration>
...
<system.webServer>
<staticContent>
<mimeMap fileExtension=".ts" mimeType="application/x-typescript" />
</staticContent>
</system.webServer>
</configuration>
Deno uses application/typescript
to serve TypeScript files, allowing you to run them with:
deno run "https://example.com/file.ts"
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