Zerthox / betterdiscord-types

Type definitions for BetterDiscord.
https://docs.betterdiscord.app/api/
MIT License
12 stars 2 forks source link

`ModuleFilter` too many parameters? #6

Closed moeshin closed 1 year ago

moeshin commented 1 year ago

https://github.com/BetterDiscord/BetterDiscord/blob/b62deff1407c52bda5415a2d464de9566a78e4f4/renderer/src/modules/webpackmodules.js#L8-L13

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/39359c8466846541b5b3298165ef79c509f0cd09/types/bandagedbd__bdapi/index.d.ts#L1273

Zerthox commented 1 year ago

Module filter functions take exports, module, id as parameters in that order. See the BetterDiscord docs: https://docs.betterdiscord.app/api/webpack#getmodule. The JSDoc comment in the BetterDiscord source code apparently hasn't been updated (last changed 3 years ago). The BandagedBD BdApi types should not be used as a reference, they have been outdated and lacking for a long time. I am not sure how much the update earlier this year improved.

moeshin commented 1 year ago

exports is required, other params are optional.

https://github.com/BetterDiscord/BetterDiscord/blob/b62deff1407c52bda5415a2d464de9566a78e4f4/renderer/src/modules/webpackmodules.js#L412-L415

export type ModuleFilter = (
    exports: any,
    module?: {
        id: number;
        loaded: true;
        exports: any;
    },
    id?: string,
) => boolean;
Zerthox commented 1 year ago

Good find, it seems waitForModule got left out when the new parameters got introduced.