-
Notifications
You must be signed in to change notification settings - Fork 148
[Lodash] static var not working anymore #367
Comments
|
@andy-ms no it won't declare it as global outside of the module. At least not for me. But it might be the right way to go by not declaring _ in global and instead expect
As you can see it also shows how to extend lodash definitions. I won't close it until you decide if it's a normal behavior now for lodash not to extend global scope. |
Can you provide an example project that reproduces the error? |
@andy-ms I think a default project with lodash package installed but not imported would suffise. |
No, that works just fine for me. |
can you try with that tsconfig.json
Just change the "include" |
That works for me if I |
Ok this is really weird. By moving things i got the same result as you. Thanks |
I think that issue is microsoft/TypeScript#17736. |
@andy-ms thanks. Can we keep this open until there is a solution? |
OK |
OK so after seeing the discussion in the issue you referenced i found a way to go it to work all the time for me. First let me explain why it worked for you and not for me. Now what i did to get declare module "mod" {
module "lodash" {
interface LoDashStatic {
remove<T, K extends keyof T>(
object: T,
key?: K,
defaultValue?: T[K]
): T[K]
getKeyByValue(object, value)
mapIfDefined(array, func)
mod(n, m)
move(array, oldIndex, newIndex)
pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>
}
}
}
declare var _: _.LoDashStatic; Now i get global |
With the latest typings for lodash i can't use the static declare of
_
My project do not "import" lodash anywhere but it is available still.
For me the typings were working before thanks to:
But now there is some
export
so the declare is only in the scope of the module.Is that on purpose?
An easy way to fix it if not on purpose is to replace:
with
The text was updated successfully, but these errors were encountered: