#Typing issue

4 messages · Page 1 of 1 (latest)

woven zinc
vestal aspen
#

@woven zinc The tricky thing there is that the combination of options and your default values could result in an invalid combination of options.

#

Specifically new Queue({ driver: 'database' }) is a valid thing to do according to the typings, but the result would be invalid: as the driver options would be for redis, but the driver itself says it's a database driver.

#

I think the easiest fix here is probably to move the driver-related options into a sub-object of the overall config:

type Driver =
    | {
        kind: 'database';
        options?: DataSourceOptions;
        prefix: never;
    }
    | {
        kind: 'redis';
        options?: RedisClientOptions;
        prefix?: string;
    };

export type QueueOptions = {
    driver?: Driver,
    appName?: string;
    queue?: string;
};