question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ramda declarations, destructuring imports

See original GitHub issue

To grab the interface file I ran: flow-typed install ramda -f 0.26, then added a line to my .flowconfig to produce:

[libs]
decls
flow-typed/npm

I created a trivial test file…

/* @flow weak */
import { identity } from 'ramda'
console.log(identity(3))

And on type checking got…

handlers/scratch.js:3
  3: import { identity } from 'ramda'
              ^^^^^^^^ Named import from module `ramda`. This module has no named export called `identity`.

Looking at the file, it appears that all of the declarations are exported building up one class through mixins, which class is then the sole export. This, it seems, produces the frustrating result above. I can work around this by avoiding destructuring import:

import Ramda from 'ramda'
const { map, add, identity } = Ramda

// map, add, identity now all typed

I’m new to flow, so it’s unclear to me whether this is an issue with the declarations in this repository, a result of some misunderstanding on my part, or a shortcoming of flow itself.

cc @alexeygolev @jeffmo. Thanks for your contributions so far.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
alexeygolevcommented, Jul 9, 2016

Just a quick update. Still working on it. Should be able to submit a PR before Monday. Found a couple of wrong typings along the way:-P

1reaction
jeffmocommented, Jun 30, 2016

Support for both named and default exports inside a declare module will ship in 0.28 (no later than early next week). In the meantime, declare module bodies can only export one or the other:

Named via declare module.exports: {namedExport1: number, namedExport2: string}; Default via declare module.exports: MyDefaultExportHere;

In 0.28 and beyond, it will be possible to do:

declare module "MyModule" {
  declare export var namedExport1: number;
  declare export var namedExport2: string;
  declare export default MyDefaultExportHere;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is using an ES6 import to load specific names faster than ...
"There are definitely a few more ways." - actually, no. There's a default import syntax (which can be used in combination with either...
Read more >
Ramda Documentation
Ramda. A practical functional library for JavaScript programmers. ... Destructuring imports from ramda does not necessarily prevent importing the entire ...
Read more >
ramda
Destructuring imports from ramda does not necessarily prevent importing the entire library. You can manually cherry-pick methods like the ...
Read more >
Ramda: Practical functional Javascript - Morioh
Destructuring imports from ramda does not necessarily prevent importing the entire library. You can manually cherry-pick methods like the following, ...
Read more >
Lodash vs Ramda | What are the differences?
Ramda - A practical functional library for JavaScript programmers. ... where we can import the method names directly, without resorting to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found