PokéRogue
    Preparing search index...

    Type Alias RestrictParamNoExtend<Value, Base>Internal

    RestrictParamNoExtend: [Value] extends [Base]
        ? []
        : [MISMATCH: ErrorType<IncompatibleTypeMessage<Base, Value>>]

    Utility type to restrict the type of a function's parameter without using extends. Used to allow a generic parameter to widen to its base type on function call, while still providing helpful error messages for incompatible typing.

    Type Parameters

    • Value
    • Base
    class MyClass<T> {
    constructor(value: T, ...MISMATCH: RestrictParamNoExtend<T, number>) {
    // ...
    }
    }

    const foo = new MyClass(42); // ✅ Allowed, T widens to number and foo is MyClass<number>
    const bar = new MyClass("hello"); // ❌ Error: Expected to receive a number, but got a string instead!