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.

Example usage of importing libdef type

See original GitHub issue

It’s pretty obvious once you figure it out but it took me a quite a while via some pretty obscure Google searches to find out how to actually use a libdef and by “use”, I mean import a type (e.g. moment). A little example in the README would be nice like:

And you can use your new libdefs like:

import type moment from "moment";

type Apple = {
    sellByDate: moment
    weight: number
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:18
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

25reactions
jeffmocommented, Nov 18, 2016

Thanks for the feedback! You can find docs like this over on flowtype.org:

https://flowtype.org/docs/modules.html#import-type

16reactions
gleb-lobastovcommented, Jun 17, 2017

I figured it out by searching for and reading this (closed) issue.

Me also. Finally I come to such solution:

  1. Add folder with libdefs to libs section in your .flowconfig:
[libs]
./flow-typed
  1. Import types with separate statement as shown:
import { reduxForm, Form, FormSection} from 'redux-form';
import type { FormComponentProps } from 'redux-form';  
Read more comments on GitHub >

github_iconTop Results From Across the Web

Flow libdefs for libraries with deeper paths - Stack Overflow
Here's an example where internally-shared-libs has exports as well as deeper paths having ... Usage: // @flow import { hello, bye } from ......
Read more >
LIBDEF—allocate application libraries - IBM
The LIBRARY keyword associates an allocated ddname with an ISPF data element type. The ID parameter specifies the ddname. See libname. For example,...
Read more >
Library Definitions | Flow
A libdef is a special file that informs Flow about the type signature of some specific third-party module or package of modules that...
Read more >
Flow | Checking third-party code
You never need to change library code to use a library definition, but your code will be typechecked against the types declared in...
Read more >
Documentation - Library Structures - TypeScript
Does it use require or import / export statements? Smaller samples for different types of libraries. Modular Libraries. Almost every modern Node.js ...
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