-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(expect-type): add guards
& asserts
getters
#231
Conversation
…uarded by the tested type
Codecov Report
@@ Coverage Diff @@
## main #231 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 721 721
Branches 121 121
=========================================
Hits 721 721
Continue to review full report at Codecov.
|
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.
Hi @GerkinDev, thanks for the PR!
I like this and would be happy to accept. I'm not so sure about lumping is T
together with asserts is T
though. What about two helpers:
expectTypeOf(myFunc).guard.toBeString()
expectTypeOf(myOtherFunc).assertion.toBeString()
That way we wouldn't need the GuardedType
either. What do you think?
One other thing - if you run npm run lint -- --fix
in the project folder, it'll automatically update the docs to include your new test. Worth giving the test a readme-appropriate name too.
Well, in that case, and to stay consistent with your already existing getters, I'd name those functions |
Another thing: when running |
Hmm yes I suppose you're right re While I have a (quick) think about that one, the lint problem: you're absolutely right, this repo is quite cryptic for OSS contributors. To get the various dev dependencies depends on npm install --global @microsoft/rush
rush install # install all repo dependencies
rush build --to expect-type # build the repo
rush lint --to expect-type --fix The first time you run these it might take a little while. I'll add to the docs of each package in this monorepo soon. |
guards
& asserts
getters
} | ||
expectTypeOf(assertNumber).asserts.toBeNumber() | ||
|
||
const isError = (v: any): v is string => typeof v === 'string' |
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.
Shouldn't this be named isString
?
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.
Dammit.
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.
Fixed in 30b3c4e
Hey there, Any news on this ? |
@GerkinDev sorry for the long delay. I'll merge and publish this in the next few days. |
No problem, I was off myself for a while ;) |
Just wanted to offer a drive-by "thank you!" for this as a user of the library. These are nice additions! |
Test the type asserted or guarded by the subject function.