Improve TS Type Inference by extending Meteor Check Types #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to #7
Note:
I've run into some hiccups trying to figure out testing.
When I ran
meteor test-packages ./
I got 157/173 tests passing with adefaults - insert - basic
failing and a bunch of other tests "waiting". New to this so not sure what I should do to get those working (if anything. e.g. maybe out of scope).However, these changes mostly affect type inference, which I'm not sure how to test properly yet.
The two changes that affect the runtime are in
lib/attach
where I made both client and server versions ofattachSchema
returnthis
to match the Collection typing trick in the .d.ts file.Three things two consider:
@import
tag, but not sure if it'd affect declaration merging at all)transform
.PatternMatch
that's something like Valibot's InferOutput?My best attempt at fixing the second issue was something like:
which infers U correctly, but it's not that clean. So I didn't implement it for now. I think if someone really wants a typesafe
Collection<T, U>
they might need to use TypeScript and pass in something like:My testing is currently done manually by git cloning my branch into a new Meteor v3 project. I've played around with Collection declarations & the
check
function.Edit: I haven't used
ValidatedMethod
so I'm not sure if there's a risk of breakage.Happy for any feedback or to follow any additional steps - this is my first time contributing to a Meteor package I think.