From d3f3e0d717fdbbf531fde0c9e7259f6bb887fa10 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Sun, 7 Apr 2024 15:42:53 +1000 Subject: FUTURE(ext/fs): make `Deno.FsFile` constructor illegal (#23235) I'm unsure whether we're planning to make the `Deno.FsFile` constructor illegal or remove `FsFile` from the `Deno.*` namspace in Deno 2. Either way, this PR works towards the former. I'll create a superceding PR if the latter is planned instead. Towards #23089 --- ext/fs/30_fs.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ext/fs') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index c2fb66528..b6cd2d1f1 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -90,6 +90,7 @@ const { SymbolAsyncIterator, SymbolIterator, SymbolFor, + TypeError, Uint32Array, } = primordials; @@ -673,6 +674,11 @@ class FsFile { new Error().stack, "Use `Deno.open` or `Deno.openSync` instead.", ); + if (internals.future) { + throw new TypeError( + "`Deno.FsFile` cannot be constructed, use `Deno.open()` or `Deno.openSync()` instead.", + ); + } } } -- cgit v1.2.3