Skip to content
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

Add support for flow type imports #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ganemone
Copy link

@ganemone ganemone commented Feb 11, 2019

This adds support for automatically importing flow types

Fixes #12

@wangtao0101
Copy link
Owner

@ganemone The code seems has been formatted in this commit by prettier

@ganemone
Copy link
Author

@wangtao0101 Ok - I updated the PR to remove the formatting changes

if (!packageJson.hasOwnProperty('main'))
return;
let mainFilePath = path.join(modulePath, packageJson.main);
let mainFilePath = path.join(modulePath, 'src/index.js');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there maybe no src/index.js in node_modules in most of case, src directory will ignore in npmignore .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually a common pattern with flow types to include the src directory when publishing to npm. This is how flow will resolve types in node_modules.

@ganemone
Copy link
Author

@wangtao0101 thoughts on getting this merged? Happy to make any more updates you ask for

@wangtao0101
Copy link
Owner

@ganemone I think we should not check 'src/index' for main entry, maybe you can scan both mainfile in packagejson and 'src/index'

@ganemone
Copy link
Author

@wangtao0101 I do check both src/index.js and package.json main. This is actually the way node.js will handle module resolution. See https://nodejs.org/api/modules.html#modules_all_together

@albertywu
Copy link

Curious what the status is of this PR? I was hunting for a vscode plugin that does auto imports of flow types and ran into this!

@Skurkify
Copy link

I'm also looking for auto import of flow types. This plugin is already great and having the ability to import Flow types would really help me out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support importing flow types
4 participants