`wg` variables are not autocompleted
Closed this issue · 4 comments
A proposed solution to this issue is implemented in commit e47e9ae, from MR #36.
This fix involves using an additional ExtensibleMap<V, TX>
interface, which simulates both a Map<V>
for known keys and a Map<{ [k: string]: TX; }>
for unknown keys.
There may be a simpler way to do it, Basically we could define mw.config
as Map<V> & Map<{ [k: string]: TX; }>
, but this would manage the 2 method implementations as overloads, so when writing
mw.config.get(["skin", "someUnknownKey", "stylepath"])
we would get autocompletion when writing "skin"
, but not when writing "stylepath"
since after having written "someUnknownKey"
, the linter will switch from the Map<V>
definition of the get
method to the Map<{ [k: string]: TX; }>
definition of this same method. After inlining type variables this 2nd signature simplifies to
get<S extends string[]>(selection: S, fallback?: any): { [P in S]: TX; };
so we no longer get autocompletion, but worse: properties of the result object will all have type TX
, instead of string
for skin
and stylepath
.
PR #36 got merged, so the fix mentioned above has been applied (for the next npm release).
In v1.6.0, this works for TypeScript files. It still doesn't work for JavaScript files though. Unlike TS autocompletion which is powered by typescript-language-server, JS autocompletion is IDE-dependent. So don't think there's much we can do about that.
It still doesn't work for JavaScript files though. ... JS autocompletion is IDE-dependent
It wasn't working in WebStorm, but it does work in VS Code. @jwbth you're in luck!