-
Notifications
You must be signed in to change notification settings - Fork 995
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
Conversation
There was a problem hiding this 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.
test/types/check-output-result.ts
Outdated
@@ -0,0 +1,7 @@ | |||
export interface CheckOutputResult<T> { | |||
errors: any[] | |||
logs: any[] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
As parseCommand() is used by argsert, completion, etc.
checkOutputResult's console stubs now format strings as real console methods do (using util.format).
Follow up of the 2nd step of #1586: this PR tsifies the
lib/argsert
module.To do so, it also:
test/helpers/utils
parseCommand()
fromlib/command
, into an independentlib/parse-command
module, to break the dependency cycle betweenlib/argsert
,lib/middleware
andlib/command
parseCommand()
is called with at least a one word command string (thanks typescript again)arguments
intest/argsert
by an...args
named argument, easier to read and type, and not needing an explicit conversion to array