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

lib cleanup: fix exported Helper object #16

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

brodybits
Copy link
Owner

@brodybits brodybits commented Nov 3, 2019

This would very likely affect where we use the declared Helper object type proposed in PR #14.

/cc @rbiggs - I would appreciate some feedback on this proposal.

These changes would be moved out of PR #9.

@rbiggs
Copy link

rbiggs commented Nov 3, 2019

I have one big question about this project. I see you have lib/program-helper.js and bin/glob-tsc.js but I'm not seeing any build script. How is the bin version getting generated? Are you directly creating it? If so, why does the lib/program-helper.js exist? I see in your package.json that your pointing to the bin file. I'm confused. Normally the bin version gets produced by a build process. You would be running tests on the source code, not on the bin version, but I see you're running checkjs on the bin version. That's likely to always fail because there'll never be any type information in that.

@brodybits
Copy link
Owner Author

The bin script just imports the lib file, as a CommonJS module, and old Node.js versions are not supported, so no build should be needed here. This project is not meant to be run in a browser.

Does this answer your question?

@rbiggs
Copy link

rbiggs commented Nov 3, 2019

Ah, so it's not getting generated. Just wondering because there's a type error in it, but it wouldn't make sense to fix it if its being generated during a build.

@rbiggs
Copy link

rbiggs commented Nov 3, 2019

OK, a type problem I'm seeing. In program-helper.js you have getOptions. It looks like the way its working its returning a string, not a Command object. But after that, you then have:

// Here commander is a string, so you can't attach 'unknown' to it as a property.
commander.unknown = commander.parseOptions(process.argv).unknown;

So in glob-tsc.js when you have:

options = helper.getOptions(),
commandArgs = options.unknown.concat(helper.resolveTSFiles()),

I get a type error because property unknown doesn't exist on type string.
What type is helper.getOptions supposed to be returning? I don't follow what Commander does in your code. Not familiar with it.

@brodybits
Copy link
Owner Author

// Here commander is a string, so you can't attach 'unknown' to it as a property.

That does not sound right to me.

@brodybits
Copy link
Owner Author

Hi @rbiggs just a heads up that I may switch to a simpler solution for doing checkjs with globs, with help from the globby package. I will keep you posted. I will still maintain this package at least for a little while. I would hate to see you waste time on something that I may not maintain forever if we can avoid it.

@rbiggs
Copy link

rbiggs commented Nov 3, 2019

Here's what I'm finding in VSCode:

Screen Shot 2019-11-03 at 11 50 03 AM

@rbiggs
Copy link

rbiggs commented Nov 3, 2019

By the way, I tried doing type coercion to force options from string to Command, but no dice. As far as TypeScript is concerned that's a string.

@brodybits
Copy link
Owner Author

I will take a look at it later this week. FYI I published https://github.com/brodybits/check-js-types which uses meow for the CLI and globby@7 to resolve glob patterns. Should be much simpler than the implementation in this project.

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.

None yet

2 participants