Repository navigation
fix(metadata): build DataAPIMeta from a DecoratorTarget for interface-core 0.5 - #128
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
ANT-2370. interface-core 0.5 types
GetMetadata's metadata class asClass<T, [DecoratorTarget]>, becauseGetMetadataalso builds metadata for the prototypes it walks above a class.DataAPIMeta's constructor took aClass, so this package stopped compiling against interface-core 0.5. This PR makes it compile and moves the dev dependencies to the released@antelopejs/core1.22.0 and@antelopejs/interface-core0.5.1, with a single interface-core copy in the lockfile.What
DataAPIMeta's constructor takes aDecoratorTarget. It keeps the target when it is a class.targetstays typedClass<object>, now as a getter, and throwsNo controller class.only for the metadataGetMetadatabuilds forFunction.prototypeandObject.prototypeabove the controller classes. Nothing readstargeton those.@antelopejs/core~1.22.0,@antelopejs/interface-core^0.5.1, deduped so the lockfile resolves interface-core at 0.5.1 only. The peer range stays>=0.2.4 <1.0.0, because the runtime works with every version in it. The README's tested-with column reads 0.5.1.src/metadata.tswould have gone 230 bytes over the 20,000-byte ceiling.recomputeAccess's body moved into a new@internalmodule,src/internal/access-lists.ts(rebuildAccess,DEFAULT_ACTION). The method still runs on its own instance and passesrebuildAccessits own records. The access rules stay inmetadata.tsand reach it through a callback, so no import cycle forms.metadata.tsis now 19,182 bytes.Attention
DataAPIMeta's constructor parameter widens fromClasstoDecoratorTarget; everyClassis aDecoratorTarget.readonly target: Class<object>becomesget target(): Class<object>, with the same read type. The class gains a#privatemember, so an object literal can no longer stand in for aDataAPIMeta.targetis an accessor on the prototype, soObject.keys(meta)no longer lists it. Readingtargeton the metadata of a prototype above the controller classes throws instead of returning that prototype. Runtime exports are unchanged.antelopejs-api-diff origin/maincannot build its base:origin/maindoes not compile against the new dependencies, which is what this PR fixes. The declaration and runtime-export comparison againstorigin/mainbuilt with its own lockfile is shown below. The api-diff block proves that the size split and the dependency bump preserve the API.SAFETY comments added
None. The suppression budget is unchanged.
Proof
pnpm run checks: 11 passed, 0 failed.pnpm exec tsc -p docs/tsconfig.jsonpasses.origin/maintypechecked against this PR's lockfile (interface-core 0.5.1):The new
src/tests/index/metadata_target.test.ts, onorigin/main:On this branch both tests pass, inside the 11/11 checks.
Declarations,
origin/mainbuilt with its own lockfile against HEAD. Every other.d.tsis identical, andinternal/access-lists.d.tsis new:Runtime exports of
index,metadataandcomponents(names andtypeof), compared the same way: identical, 27 names.Size split and dependency bump, against the constructor commit
0ad9572(both sides build on interface-core 0.5.1):