From 5ddb83a4c2a5622d0ea173c0798550ae76e1fd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 3 May 2022 18:44:05 +0200 Subject: [PATCH] BREAKING: Remove unstable Deno.applySourceMap API (#14473) --- cli/diagnostics.rs | 1 - cli/dts/lib.deno.unstable.d.ts | 39 ------------------------------ cli/tests/unit/error_stack_test.ts | 16 +----------- runtime/js/40_error_stack.js | 5 ---- runtime/js/90_deno_ns.js | 1 - 5 files changed, 1 insertion(+), 61 deletions(-) diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 24d7ab0e7c..1538e5d4df 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -39,7 +39,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "UnixConnectOptions", "UnixListenOptions", "addSignalListener", - "applySourceMap", "bench", "connect", "consoleSize", diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 2904c14f32..fbbe165f90 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -895,45 +895,6 @@ declare namespace Deno { options?: EmitOptions, ): Promise; - /** **UNSTABLE**: Should not have same name as `window.location` type. */ - interface Location { - /** The full url for the module, e.g. `file://some/file.ts` or - * `https://some/file.ts`. */ - fileName: string; - /** The line number in the file. It is assumed to be 1-indexed. */ - lineNumber: number; - /** The column number in the file. It is assumed to be 1-indexed. */ - columnNumber: number; - } - - /** **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:** `lineNumber` and `columnNumber` are 1 indexed, which matches display - * expectations, but is not typical of most index numbers in Deno. - * - * An example: - * - * ```ts - * const origin = Deno.applySourceMap({ - * fileName: "file://my/module.ts", - * lineNumber: 5, - * columnNumber: 15 - * }); - * - * console.log(`${origin.fileName}:${origin.lineNumber}:${origin.columnNumber}`); - * ``` - */ - export function applySourceMap(location: Location): Location; - export type SetRawOptions = { cbreak: boolean; }; diff --git a/cli/tests/unit/error_stack_test.ts b/cli/tests/unit/error_stack_test.ts index e8d29569fe..8444972a8d 100644 --- a/cli/tests/unit/error_stack_test.ts +++ b/cli/tests/unit/error_stack_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, assertMatch } from "./test_util.ts"; +import { assertEquals, assertMatch } from "./test_util.ts"; Deno.test(function errorStackMessageLine() { const e1 = new Error(); @@ -52,17 +52,3 @@ Deno.test(function captureStackTrace() { } foo(); }); - -// FIXME(bartlomieju): no longer works after migrating -// to JavaScript runtime code -Deno.test({ ignore: true }, function applySourceMap() { - const result = Deno.applySourceMap({ - fileName: "CLI_SNAPSHOT.js", - lineNumber: 23, - columnNumber: 0, - }); - Deno.core.print(`result: ${result}`, true); - assert(result.fileName.endsWith(".ts")); - assert(result.lineNumber != null); - assert(result.columnNumber != null); -}); diff --git a/runtime/js/40_error_stack.js b/runtime/js/40_error_stack.js index 1ecf0f6bb1..046f4ddf0f 100644 --- a/runtime/js/40_error_stack.js +++ b/runtime/js/40_error_stack.js @@ -12,13 +12,8 @@ return core.opSync("op_format_file_name", location); } - function opApplySourceMap(location) { - return core.applySourceMap(location); - } - window.__bootstrap.errorStack = { opFormatDiagnostics, opFormatFileName, - opApplySourceMap, }; })(this); diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 61e894f8a0..a6f63abe28 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -126,7 +126,6 @@ systemMemoryInfo: __bootstrap.os.systemMemoryInfo, networkInterfaces: __bootstrap.os.networkInterfaces, getUid: __bootstrap.os.getUid, - applySourceMap: __bootstrap.errorStack.opApplySourceMap, formatDiagnostics: __bootstrap.errorStack.opFormatDiagnostics, sleepSync: __bootstrap.timers.sleepSync, listen: __bootstrap.netUnstable.listen,