diff --git a/lib/internal/file.js b/lib/internal/file.js index 8ef858d67e2d9c..4c6ca4f61fa4d8 100644 --- a/lib/internal/file.js +++ b/lib/internal/file.js @@ -21,7 +21,6 @@ const { const { codes: { - ERR_INVALID_THIS, ERR_MISSING_ARGS, }, } = require('internal/errors'); @@ -64,18 +63,10 @@ class File extends Blob { } get name() { - if (!this || !(#name in this)) { - throw new ERR_INVALID_THIS('File'); - } - return this.#name; } get lastModified() { - if (!this || !(#name in this)) { - throw new ERR_INVALID_THIS('File'); - } - return this.#lastModified; } diff --git a/test/parallel/test-file.js b/test/parallel/test-file.js index 64a83f77ef919d..bfc4548421be23 100644 --- a/test/parallel/test-file.js +++ b/test/parallel/test-file.js @@ -146,10 +146,15 @@ const { inspect } = require('util'); { const getter = Object.getOwnPropertyDescriptor(File.prototype, 'name').get; - assert.throws( - () => getter.call(undefined), // eslint-disable-line no-useless-call - { - code: 'ERR_INVALID_THIS', - } - ); + + [ + undefined, + null, + true, + ].forEach((invalidThis) => { + assert.throws( + () => getter.call(invalidThis), + TypeError + ); + }); }