Skip to content

Commit

Permalink
refactor(mw.Map): use generics
Browse files Browse the repository at this point in the history
Avoid passing types when using `mw.messages.exists<types>()` and `mw.messages.set<types>()` to prevent the error "An_instantiation_expression_cannot_be_followed_by_a_property_access"

Copied from AnYiEE@6df693a by @AnYiEE
  • Loading branch information
Adrien LESÉNÉCHAL committed Jan 30, 2024
1 parent 7e1e831 commit e5a0ff4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mw/Map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare global {
* @returns True if the key exists
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-exists
*/
exists(selection: keyof V): boolean;
exists<S extends keyof V>(selection: S): selection is S;

/**
* Get the value of one or more keys.
Expand All @@ -53,7 +53,7 @@ declare global {
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map-method-set
*/
set<S extends keyof V>(selection: S, value: V[S]): boolean;
set(selection: Partial<V>): boolean;
set<S extends Partial<V>>(selection: S): boolean;
}
}
}
Expand Down

0 comments on commit e5a0ff4

Please sign in to comment.