diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 11780d0110de44..4ecb9a5756a9c6 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -1830,8 +1830,8 @@ declare namespace Deno { * an error occurs. It resolves to the number of bytes copied or rejects with * the first error encountered while copying. * - * @deprecated Use {@linkcode ReadableStream.pipeTo} instead. - * {@linkcode Deno.copy} will be removed in v2.0.0. + * @deprecated Use {@linkcode https://deno.land/std/io/copy.ts?s=copy | copy} + * instead. {@linkcode Deno.copy} will be removed in v2.0.0. * * @category I/O * @@ -1848,8 +1848,8 @@ declare namespace Deno { /** * Turns a Reader, `r`, into an async iterator. * - * @deprecated Use {@linkcode ReadableStream} instead. {@linkcode Deno.iter} - * will be removed in v2.0.0. + * @deprecated Use {@linkcode ReadableStream} instead. + * {@linkcode Deno.iter} will be removed in v2.0.0. * * @category I/O */ @@ -2875,9 +2875,9 @@ declare namespace Deno { /** * A variable-sized buffer of bytes with `read()` and `write()` methods. * - * @deprecated Use the - * [Web Streams API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Streams_API} - * instead. {@linkcode Deno.Buffer} will be removed in v2.0.0. + * @deprecated Use + * {@linkcode https://deno.land/std/io/buffer.ts?s=Buffer | Buffer} instead. + * {@linkcode Deno.Buffer} will be removed in v2.0.0. * * @category I/O */ @@ -2951,8 +2951,8 @@ declare namespace Deno { * Read Reader `r` until EOF (`null`) and resolve to the content as * Uint8Array`. * - * @deprecated Use {@linkcode ReadableStream} and - * [`toArrayBuffer()`](https://deno.land/std/streams/to_array_buffer.ts?s=toArrayBuffer) + * @deprecated Use + * {@linkcode https://deno.land/std/io/read_all.ts?s=readAll | readAll} * instead. {@linkcode Deno.readAll} will be removed in v2.0.0. * * @category I/O @@ -2963,8 +2963,8 @@ declare namespace Deno { * Synchronously reads Reader `r` until EOF (`null`) and returns the content * as `Uint8Array`. * - * @deprecated Use {@linkcode ReadableStream} and - * [`toArrayBuffer()`](https://deno.land/std/streams/to_array_buffer.ts?s=toArrayBuffer) + * @deprecated Use + * {@linkcode https://deno.land/std/io/read_all.ts?s=readAllSync | readAllSync} * instead. {@linkcode Deno.readAllSync} will be removed in v2.0.0. * * @category I/O @@ -2974,9 +2974,9 @@ declare namespace Deno { /** * Write all the content of the array buffer (`arr`) to the writer (`w`). * - * @deprecated Use {@linkcode WritableStream}, {@linkcode ReadableStream.from} - * and {@linkcode ReadableStream.pipeTo} instead. {@linkcode Deno.writeAll} - * will be removed in v2.0.0. + * @deprecated Use + * {@linkcode https://deno.land/std/io/write_all.ts?s=writeAll | writeAll} + * instead. {@linkcode Deno.writeAll} will be removed in v2.0.0. * * @category I/O */ @@ -2986,9 +2986,9 @@ declare namespace Deno { * Synchronously write all the content of the array buffer (`arr`) to the * writer (`w`). * - * @deprecated Use {@linkcode WritableStream}, {@linkcode ReadableStream.from} - * and {@linkcode ReadableStream.pipeTo} instead. - * {@linkcode Deno.writeAllSync} will be removed in v2.0.0. + * @deprecated Use + * {@linkcode https://deno.land/std/io/write_all.ts?s=writeAllSync | writeAllSync} + * instead. {@linkcode Deno.writeAllSync} will be removed in v2.0.0. * * @category I/O */ @@ -4062,7 +4062,7 @@ declare namespace Deno { /** * Stops watching the file system and closes the watcher resource. * - * @deprecated Will be removed in v2.0.0. + * @deprecated {@linkcode Deno.FsWatcher.return} will be removed in v2.0.0. */ return?(value?: any): Promise>; [Symbol.asyncIterator](): AsyncIterableIterator; diff --git a/ext/io/12_io.js b/ext/io/12_io.js index 9f4a3766b714a5..2a0d589a758644 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -3,8 +3,7 @@ // Interfaces 100% copied from Go. // Documentation liberally lifted from them too. // Thank you! We love Go! <3 - -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { op_stdin_set_raw, op_is_terminal, @@ -40,6 +39,11 @@ async function copy( dst, options, ) { + internals.warnOnDeprecatedApi( + "Deno.copy()", + new Error().stack, + "Use `copy()` from `https://deno.land/std/io/copy.ts` instead.", + ); let n = 0; const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); @@ -65,6 +69,11 @@ async function* iter( r, options, ) { + internals.warnOnDeprecatedApi( + "Deno.iter()", + new Error().stack, + "Use `ReadableStream` instead.", + ); const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); while (true) { @@ -81,6 +90,11 @@ function* iterSync( r, options, ) { + internals.warnOnDeprecatedApi( + "Deno.iterSync()", + new Error().stack, + "Use `ReadableStream` instead.", + ); const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); while (true) { diff --git a/runtime/js/13_buffer.js b/runtime/js/13_buffer.js index 36d979e75aadee..cac1a66944b61b 100644 --- a/runtime/js/13_buffer.js +++ b/runtime/js/13_buffer.js @@ -4,7 +4,7 @@ // Copyright 2009 The Go Authors. All rights reserved. BSD license. // https://github.com/golang/go/blob/master/LICENSE -import { primordials } from "ext:core/mod.js"; +import { internals, primordials } from "ext:core/mod.js"; const { ArrayBufferPrototypeGetByteLength, TypedArrayPrototypeSubarray, @@ -45,6 +45,11 @@ class Buffer { #off = 0; // read at buf[off], write at buf[buf.byteLength] constructor(ab) { + internals.warnOnDeprecatedApi( + "new Deno.Buffer()", + new Error().stack, + "Use `Buffer` from `https://deno.land/std/io/buffer.ts` instead.", + ); if (ab == null) { this.#buf = new Uint8Array(0); return; @@ -230,18 +235,33 @@ class Buffer { } async function readAll(r) { + internals.warnOnDeprecatedApi( + "Deno.readAll()", + new Error().stack, + "Use `readAll()` from `https://deno.land/std/io/read_all.ts` instead.", + ); const buf = new Buffer(); await buf.readFrom(r); return buf.bytes(); } function readAllSync(r) { + internals.warnOnDeprecatedApi( + "Deno.readAllSync()", + new Error().stack, + "Use `readAllSync()` from `https://deno.land/std/io/read_all.ts` instead.", + ); const buf = new Buffer(); buf.readFromSync(r); return buf.bytes(); } async function writeAll(w, arr) { + internals.warnOnDeprecatedApi( + "Deno.writeAll()", + new Error().stack, + "Use `writeAll()` from `https://deno.land/std/io/write_all.ts` instead.", + ); let nwritten = 0; while (nwritten < arr.length) { nwritten += await w.write(TypedArrayPrototypeSubarray(arr, nwritten)); @@ -249,6 +269,11 @@ async function writeAll(w, arr) { } function writeAllSync(w, arr) { + internals.warnOnDeprecatedApi( + "Deno.writeAllSync()", + new Error().stack, + "Use `writeAllSync()` from `https://deno.land/std/io/write_all.ts` instead.", + ); let nwritten = 0; while (nwritten < arr.length) { nwritten += w.writeSync(TypedArrayPrototypeSubarray(arr, nwritten)); diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js index 13cacc36be3940..0bc61433532b4a 100644 --- a/runtime/js/40_fs_events.js +++ b/runtime/js/40_fs_events.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype, @@ -49,6 +49,10 @@ class FsWatcher { // TODO(kt3k): This is deprecated. Will be removed in v2.0. // See https://github.com/denoland/deno/issues/10577 for details return(value) { + internals.warnOnDeprecatedApi( + "Deno.FsWatcher.return()", + new Error().stack, + ); core.close(this.rid); return PromiseResolve({ value, done: true }); } diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 5bcc68a57c78c4..bba1f30d78b45a 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -43,7 +43,10 @@ class FsFile extends fs.FsFile { } const denoNs = { - metrics: core.metrics, + metrics: () => { + internals.warnOnDeprecatedApi("Deno.metrics()", new Error().stack); + return core.metrics(); + }, Process: process.Process, run: process.run, isatty: tty.isatty, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 3fee1109b0cc1a..7057f6d6271b48 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -155,6 +155,7 @@ function warnOnDeprecatedApi(apiName, stack, ...suggestions) { "%c\u251c This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.", "color: yellow;", ); + for (let i = 0; i < suggestions.length; i++) { const suggestion = suggestions[i]; console.error("%c\u2502", "color: yellow;");