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.
@xddq Hey, just submitting and updated PR for the Indexed Access Types. Wanted to simplify the accessor resolution and avoid the property collection / depth introspection https://github.com/sinclairzx81/typebox-codegen/pull/2/files#diff-2d6cde5bd1603d51af990557190f42976eba2d85f2a87556bc5535d0e18c3b2cR118-R248
Implementation of Indexed Accessor Types is basically just reduced to the following (where we trust the compiler to produce the correct
objectType
andindexType
. The output just yields aT.properties[key]
. This function is called from theVisit(node)
function.This PR also implements unit tests for the model transformation. To keep dependencies to an absolute minimum (and to avoid babel side dependencies), I'm trialing the new Node test runners https://nodejs.org/api/test.html. These are built into Node nowadays and should be supported on modern versions Node16, 18 and 19 (I'm running 18 LTS this side). These seem to work ok (but the test filtering Node implemented needs work).
I usually use mocha, but depending on how well Node test runners hold up, can swap to Jest as the setup should largely be the same.