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

chore(ts): tsify lib/argsert #1610

Merged
merged 8 commits into from
Apr 8, 2020
Merged

chore(ts): tsify lib/argsert #1610

merged 8 commits into from
Apr 8, 2020

Conversation

mleguen
Copy link
Member

@mleguen mleguen commented Apr 3, 2020

Follow up of the 2nd step of #1586: this PR tsifies the lib/argsert module.

To do so, it also:

  • tsifies test/helpers/utils
  • extracts parseCommand() from lib/command, into an independent lib/parse-command module, to break the dependency cycle between lib/argsert, lib/middleware and lib/command
  • add a test to ensure parseCommand() is called with at least a one word command string (thanks typescript again)
  • removes some unused or no longer used function parameters
  • replaces uses of arguments in test/argsert by an ...args named argument, easier to read and type, and not needing an explicit conversion to array

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

My one nit is that it might be worth trying to get rid of the any types in CheckOutputResult.

This is looking good.

lib/argsert.ts Show resolved Hide resolved
lib/parse-command.ts Show resolved Hide resolved
@@ -0,0 +1,7 @@
export interface CheckOutputResult<T> {
errors: any[]
logs: any[]
Copy link
Member

Choose a reason for hiding this comment

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

could we be more specific with this type, I think these are string arrays?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, we use them as string[], but their true type for now is any[], as we get their contents directly from console.{error,log,warn} first parameter message, which is any.

So if we want to have real string[] (and we should, as we always test them again string[] afterwards), we should explicitly transform message to string, using util.format for example.

Although this has nothing to do with tsification, I will add a commit to fix that.

checkOutputResult's console stubs now format strings
as real console methods do (using util.format).
@mleguen mleguen merged commit ff7a092 into master Apr 8, 2020
@mleguen mleguen deleted the 1586-ts-argsert branch April 8, 2020 09:15
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