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

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

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

UNSTABLE: new API, yet to be vetted.

Given a current location in a module, lookup the source location and return it.

When Deno transpiles code, it keep source maps of the transpiled code. This function can be used to lookup the original location. This is automatically done when accessing the .stack of an error, or when an uncaught error is logged. This function can be used to perform the lookup for creating better error handling.

Note: line and column are 1 indexed, which matches display expectations, but is not typical of most index numbers in Deno.

An example:

  const orig = Deno.applySourceMap({
    fileName: "file://my/module.ts",
    lineNumber: 5,
    columnNumber: 15
  });
  console.log(`${orig.filename}:${orig.line}:${orig.column}`);