```ts
export class LruCache<K, V> {
    // constructor throws Error unless capacity is a positive integer
    private readonly capacity: number;
    private readonly cache: Map<K, V>;
    private readonly usageOrder: K[];

    /**
     * @param {number} capacity - The fixed capacity of the cache.
     */
    constructor(capacity: number) {
        if (typeof capacity !== 'number' || capacity <= 0 || !Number.isInteger(capacity)) {
            throw new Error('Capacity must be a positive integer');
        }
        this.capacity = capacity;
        this.cache = new Map<K, V>();
        this.usageOrder = [];
    }

    /**
     * @param {K} key - The key to retrieve.
     * @returns {V | undefined} The value associated with the key if present, otherwise undefined.
     */
    get(key: K): V | undefined {
        if (this.cache.has(key)) {
            const index = this.usageOrder.findIndex(k => k === key);
            if (index !== -1) {
                this.usageOrder.splice(index, 1);
                this.usageOrder.push(key);
            }
            return this.cache.get(key);
        }
    }

    /**
     * @param {K} key - The key to set.
     * @param {V} value - The value to associate with the key.
     */
    set(key: K, value: V): void {
        if (this.cache.has(key)) {
            const index = this.usageOrder.findIndex(k => k === key);
            if (index !== -1) {
                this.usageOrder.splice(index, 1);
            }
        } else if (this.cache.size >= this.capacity) {
            const oldestKey = this.usageOrder.shift();
            if (oldestKey !== undefined) {
                this.cache.delete(oldestKey);
            }
        }
        this.cache.set(key, value);
        this.usageOrder.push(key);
    }

    /**
     * @returns {number} The current number of entries in the cache.
     */
    get size(): number {
        return this.cache.size;
    }
}
```