Repository: pixijs/pixijs
File: src/rendering/renderers/shared/texture/sources/TextureSource.ts (TypeScript)

Code before:
        else
        {
            this.pixelWidth = this.resource ? (this.resourceWidth ?? 1) : 1;
        }

        if (options.height)
        {
            this.pixelHeight = options.height * this._resolution;
        }
        else
        {
            this.pixelHeight = this.resource ? (this.resourceHeight ?? 1) : 1;
        }

        this.width = this.pixelWidth / this._resolution;
        this.height = this.pixelHeight / this._resolution;

        this.format = options.format;
        this.dimension = options.dimensions;
        this.mipLevelCount = options.mipLevelCount;
        this.autoGenerateMipmaps = options.autoGenerateMipmaps;
        this.sampleCount = options.sampleCount;
        this.antialias = options.antialias;
        this.alphaMode = options.alphaMode;

        const styleOptions: TextureStyleOptions = {};

        // conditionally assign the values so we don't blat default values in TextureStyle constructor
        options.addressMode !== undefined && (styleOptions.addressMode = options.addressMode);
        options.addressModeU !== undefined && (styleOptions.addressModeU = options.addressModeU);
        options.addressModeV !== undefined && (styleOptions.addressModeV = options.addressModeV);
        options.addressModeW !== undefined && (styleOptions.addressModeW = options.addressModeW);
        options.scaleMode !== undefined && (styleOptions.scaleMode = options.scaleMode);
        options.magFilter !== undefined && (styleOptions.magFilter = options.magFilter);
        options.minFilter !== undefined && (styleOptions.minFilter = options.minFilter);
        options.mipmapFilter !== undefined && (styleOptions.mipmapFilter = options.mipmapFilter);
        options.lodMinClamp !== undefined && (styleOptions.lodMinClamp = options.lodMinClamp);
        options.lodMaxClamp !== undefined && (styleOptions.lodMaxClamp = options.lodMaxClamp);
        options.compare !== undefined && (styleOptions.compare = options.compare);
        options.maxAnisotropy !== undefined && (styleOptions.maxAnisotropy = options.maxAnisotropy);

        this.style = new TextureStyle(styleOptions);

        this.destroyed = false;
    }

    /** returns itself */
    get source(): TextureSource
    {
        return this;
    }

Review comment (suggestion):
This is pretty verbose. Can you try something like using a `reduce` instead?
```ts
const styleOptions: TextureStyleOptions = Object.entries(options)
  .filter(([key]) => styleKeys.includes(key))
  .filter(([key, value]) => value !== undefined)
  .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
```

Code after:
        {
            this.pixelWidth = options.width * this._resolution;
        }
        else
        {
            this.pixelWidth = this.resource ? (this.resourceWidth ?? 1) : 1;
        }

        if (options.height)
        {
            this.pixelHeight = options.height * this._resolution;
        }
        else
        {
            this.pixelHeight = this.resource ? (this.resourceHeight ?? 1) : 1;
        }

        this.width = this.pixelWidth / this._resolution;
        this.height = this.pixelHeight / this._resolution;

        this.format = options.format;
        this.dimension = options.dimensions;
        this.mipLevelCount = options.mipLevelCount;
        this.autoGenerateMipmaps = options.autoGenerateMipmaps;
        this.sampleCount = options.sampleCount;
        this.antialias = options.antialias;
        this.alphaMode = options.alphaMode;

        this.style = new TextureStyle(definedProps(options));

        this.destroyed = false;

        this._refreshPOT();
    }

    /** returns itself */
    get source(): TextureSource
    {
        return this;
    }

    /** the style of the texture */
    get style(): TextureStyle
    {
        return this._style;
    }

    set style(value: TextureStyle)
    {
        if (this.style === value) return;