Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/cli/js/lib.deno.unstable.d.ts>Deno.transpileOnly

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.transpileOnly
import { Deno } from "https://deno.land/x/deno@v1.0.0/cli/js/lib.deno.unstable.d.ts";
const { transpileOnly } = Deno;

UNSTABLE: new API, yet to be vetted.

Takes a set of TypeScript sources and resolves to a map where the key was the original file name provided in sources and the result contains the source and optionally the map from the transpile operation. This does no type checking and validation, it effectively "strips" the types from the file.

 const results =  await Deno.transpileOnly({
   "foo.ts": `const foo: string = "foo";`
 });

Parameters

sources: Record<string, string>

A map where the key is the filename and the value is the text to transpile. The filename is only used in the transpile and not resolved, for example to fill in the source name in the source map.

optional
options: CompilerOptions

An option object of options to send to the compiler. This is a subset of ts.CompilerOptions which can be supported by Deno. Many of the options related to type checking and emitting type declaration files will have no impact on the output.

Returns

Promise<Record<string, TranspileOnlyResult>>