feat(expect-type): add guards & asserts getters#231
feat(expect-type): add guards & asserts getters#231mmkal merged 5 commits intommkal:mainfrom GerkinDev:main
guards & asserts getters#231Conversation
…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.
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 --fixThe 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' |
|
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.