diff --git a/packages/react-fs/src/ReactFilesystem.js b/packages/react-fs/src/ReactFilesystem.js index 85a7f3d28d8b1..bb6ebe05567ca 100644 --- a/packages/react-fs/src/ReactFilesystem.js +++ b/packages/react-fs/src/ReactFilesystem.js @@ -91,7 +91,21 @@ export function readFile( if (!options) { return result; } - const encoding = typeof options === 'string' ? options : options.encoding; + let encoding; + if (typeof options === 'string') { + encoding = options; + } else { + const flag = options.flag; + if (flag != null && flag !== 'r') { + throw Error( + 'The flag option is not supported, and always defaults to "r".', + ); + } + if (options.signal) { + throw Error('The signal option is not supported.'); + } + encoding = options.encoding; + } if (typeof encoding !== 'string') { return result; }