Repository: microsoft/TypeScript
File: src/harness/vfsUtil.ts (TypeScript)

Code before:
        if (existingNode) throw createIOError("EEXIST");

        const time = this.time();
        const node = this._mknod(parent.dev, S_IFLNK, /*mode*/ 0o666, time);
        node.symlink = vpath.validate(target, vpath.ValidationFlags.RelativeOrAbsolute);
        this._addLink(parent, links, basename, node, time);
    }

    /**
     * Resolve a pathname.
     *
     * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public realpathSync(path: string): string {
        const { realpath } = this._walk(this._resolve(path));
        return realpath;
    }

    /**
     * Read from a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public readFileSync(path: string, encoding: BufferEncoding): string;
    /**
     * Read from a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer; // eslint-disable-line no-restricted-syntax
    public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-restricted-syntax
        const { node } = this._walk(this._resolve(path));
        if (!node) throw createIOError("ENOENT");
        if (isDirectory(node)) throw createIOError("EISDIR");
        if (!isFile(node)) throw createIOError("EBADF");

        const fileBuffer = this._getBuffer(node, encoding ?? undefined);
        return !fileBuffer.encoding ? fileBuffer.data.slice() : fileBuffer.data;
    }

    /**
     * Write to a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    // eslint-disable-next-line no-restricted-syntax
    public writeFileSync(path: string, data: string | Buffer, encoding: string | null = null): void {
        if (this.isReadonly) throw createIOError("EROFS");


Review comment (bug):
I deleted this type because CI failed (self-check), but it might be better to revert it.

Code after:
        if (existingNode) throw createIOError("EEXIST");

        const time = this.time();
        const node = this._mknod(parent.dev, S_IFLNK, /*mode*/ 0o666, time);
        node.symlink = vpath.validate(target, vpath.ValidationFlags.RelativeOrAbsolute);
        this._addLink(parent, links, basename, node, time);
    }

    /**
     * Resolve a pathname.
     *
     * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public realpathSync(path: string): string {
        const { realpath } = this._walk(this._resolve(path));
        return realpath;
    }

    /**
     * Read from a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public readFileSync(path: string, encoding?: null): Buffer<ArrayBuffer>; // eslint-disable-line no-restricted-syntax
    /**
     * Read from a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public readFileSync(path: string, encoding: BufferEncoding): string;
    /**
     * Read from a file.
     *
     * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
     */
    public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer<ArrayBuffer>; // eslint-disable-line no-restricted-syntax
    public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-restricted-syntax
        const { node } = this._walk(this._resolve(path));
        if (!node) throw createIOError("ENOENT");
        if (isDirectory(node)) throw createIOError("EISDIR");
        if (!isFile(node)) throw createIOError("EBADF");

        const fileBuffer = this._getBuffer(node, encoding ?? undefined);
        return !fileBuffer.encoding ? fileBuffer.data.slice() : fileBuffer.data;
    }

    /**
     * Write to a file.
     *