jcayzac
jcayzac3mo ago

shebang and no file extension: how do I turn Typescript on?

I have scripts with a #!/usr/bin/env deno run shebang, but they execute as javascript —adding types lead to parsing errors. Can I enable typescript with a command line parameter to deno run?
2 Replies
jcayzac
jcayzac3mo ago
--ext ts, damn how did I miss it!
Deno AI Helper
Deno AI Helper3mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, it seems like you're encountering parsing errors when adding TypeScript types to your scripts. Deno should be able to execute TypeScript files without any additional command line parameters, even if they don't have a .ts file extension. The shebang line you're using is correct for Deno scripts. If you're adding TypeScript types and getting parsing errors, it could be due to a syntax issue within your script. Please ensure that your TypeScript code is syntactically correct. Remember that TypeScript is a superset of JavaScript, so all JavaScript code is valid TypeScript, but not all TypeScript is valid JavaScript. If you're using TypeScript-specific features, make sure they are correctly implemented. Since this advice is not based on the Deno documentation, I recommend double-checking the accuracy of the advice given and ensuring that your TypeScript code is valid. If the issue persists, you might want to reach out to the Deno community for further assistance.