<p dir="auto">It might be better in the long term to allow this function to run from anywhere within the deno directory. Something like this would work but depend on there being one parent being named deno:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pub fn ts_version() -&gt; String {
  let mut manifest_dir =
    PathBuf::from(std::env::var_os(&quot;CARGO_MANIFEST_DIR&quot;).unwrap());
  let deno_root = Some(OsStr::new(&quot;deno&quot;));
  while manifest_dir.file_name() != deno_root &amp;&amp; manifest_dir.pop() {}
  manifest_dir.push(&quot;cli/tsc/00_typescript.js&quot;);
  std::fs::read_to_string(manifest_dir.into_os_string().to_str().unwrap())
    .unwrap()
    .lines()
    .find(|l| l.contains(&quot;ts.version = &quot;))
    .expect(
      &quot;Failed to find the pattern `ts.version = ` in typescript source code&quot;,
    )
    .chars()
    .skip_while(|c| !char::is_numeric(*c))
    .take_while(|c| *c != '&quot;')
    .collect::&lt;String&gt;()
}"><pre class="notranslate"><code class="notranslate">pub fn ts_version() -&gt; String {
  let mut manifest_dir =
    PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
  let deno_root = Some(OsStr::new("deno"));
  while manifest_dir.file_name() != deno_root &amp;&amp; manifest_dir.pop() {}
  manifest_dir.push("cli/tsc/00_typescript.js");
  std::fs::read_to_string(manifest_dir.into_os_string().to_str().unwrap())
    .unwrap()
    .lines()
    .find(|l| l.contains("ts.version = "))
    .expect(
      "Failed to find the pattern `ts.version = ` in typescript source code",
    )
    .chars()
    .skip_while(|c| !char::is_numeric(*c))
    .take_while(|c| *c != '"')
    .collect::&lt;String&gt;()
}
</code></pre></div>
<p dir="auto">Hey community,</p>
<p dir="auto">I presume it would be nice to have an option flag to <code class="notranslate">deno run</code> to tell that one wants to parse the file as TypeScript even though it doesn't have a <code class="notranslate">.ts</code> extension.</p>
<p dir="auto">Consider this CLI shebang executable script, named <code class="notranslate">hello.ts</code> and <code class="notranslate">hello</code>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#!/usr/bin/env -S deno run

let s: string = &quot;Hello world&quot;
console.log(s)"><pre class="notranslate">#!/usr/bin/env -S deno run

<span class="pl-k">let</span> <span class="pl-s1">s</span>: <span class="pl-smi">string</span> <span class="pl-c1">=</span> <span class="pl-s">"Hello world"</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">s</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Trying to run it produces the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ./hello.ts
Check file:///tmp/deno-run/hello.ts
Hello world

$ ./hello
error: Uncaught SyntaxError: Unexpected token ':'
let s: string = &quot;Hello world&quot;
     ^
    at &lt;anonymous&gt; (file:///tmp/deno-run/hello:3:6)"><pre class="notranslate"><code class="notranslate">$ ./hello.ts
Check file:///tmp/deno-run/hello.ts
Hello world

$ ./hello
error: Uncaught SyntaxError: Unexpected token ':'
let s: string = "Hello world"
     ^
    at &lt;anonymous&gt; (file:///tmp/deno-run/hello:3:6)
</code></pre></div>
<p dir="auto">As there could be multiple reasons to have a CLI executable named without the <code class="notranslate">.ts</code> extension, I think it would be great to have something like <code class="notranslate">deno run --ts</code> or <code class="notranslate">deno run --language=ts</code> in order to force TypeScript processing of the specified script.</p>