-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Create lodash-global for global usage #6112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The build fails when testing the following files:
but these files are unrelated to the changes in this PR. Thoughts? |
@chrootsu - thanks for linking that request. Hopefully it's clearer from this PR what's being proposed (you can actually see the diff) and there are tests per the React model. |
@myitcv Why did you choose the name of the internal module |
@chrootsu - currently the ambient module and variable are both named As far as the naming is concerned, as I understand it this all stems from (understandably) wanting to share code between the 'module' and global definitions. This way the ambient declarations can be exported within the If a name like /// <reference path="../typings/lodash/lodash.d.ts" />
let x: Lodash.MapCache; but the following would not: /// <reference path="../typings/lodash/lodash.d.ts" />
console.log(_.isUndefined(5)); Even though the ambient delcaration is visible via the obfuscated
Agreed. I've raised this issue to discuss what can be done. The same situation arises in the React package, as I mention in that issue. |
I've closed my pull request #6088 in favor of this one, as it applies the same fix but with a better pattern (and consistently with React). |
Updated to fix some of the failing tests. |
Ok, now that I've actually figured out why the tests were failing before (hadn't appreciated the obvious point that type definitions/tests that reference |
@myitcv I am a little confused by the name of the module begins with __. =) Can be used, LoDashTypes instead? |
@chrootsu I believe that's for consistency with React. The So |
@ander-nz Ok, I understood, thank you ) |
Related discussion: #6148 |
Is there any progress? |
@Strate from my perspective:
Hence it might make more sense for someone else to pick up this PR if it is still needed |
Hello and thank you for your contribution! Due to an excessively long queue of pull requests that have become stale, we are "declaring bankruptcy" and closing all PRs opened before May 1, 2016. If you'd still like to merge this code in, please open a new PR that has been merged and rebased with the Going forward, we are committing to review or merge all PRs on a regular basis so this bankruptcy will not occur again. We apologize for the incovenience and hope you will continue to contribute to DefinitelyTyped in the future. Thanks |
Following the pattern of React, this PR creates a
lodash-global.d.ts
type definition.Why is this necessary?
The following code compiles using the current type definition:
but fails at runtime unless you have loaded
lodash
elsewhere. For those, like me, who use SystemJS (or other modules loaders) to load modules, we need to declare dependencies via imports, and generally rely on the compiler to tell us when we have missed one (as is the case here).This PR creates two (linked) versions of the type definition:
lodash
elsewhere and want to therefore take advantage of the global definitions, they should referencelodash-global.d.ts
lodash
, they should uselodash.d.ts
So if instead I reference the
lodash.d.ts
in this PR, the above code would give a compile error:This forces me to import:
The transpiled output then includes the relevant module loading code to ensure
lodash
has been loaded before use (in my case I'm using SystemJS):