Repository navigation
feat(database): type the own properties of a schema codec as unknown values - #63
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
Antony's goal is every AntelopeJS
guardrails.ratchet.jsondeleted through verified PRs oncampaign/integration. dms-database cannot lose its ratchet yet: its last contract row isfieldDescriptor.ts:193, whereObject.entries(value)runs overFieldType = StringFieldType | IoTsCodec.IoTsCodecwas aninterfacewithout an index signature, so TypeScript typed the entries as[string, any][]. A codec without a_tagreaches that branch, so no consumer guard can say what its values are.What changed
IoTsCodecinsrc/staged-query/schema.tsis declared as a type alias instead of an interface. The members are the same. A type alias gets an implicit string index signature, soObject.entrieson a codec types its own enumerable properties as[string, unknown].Runtime API: 1 packages, 11 entries unchanged.src/tests/field_type.test.tsfails to compile on the base (Type 'true' is not assignable to type 'false'on the check that the property type is notany), and passes with the alias.Breaking
No for what a consumer can pass: the alias and the interface have the same members, so every value assignable to
FieldTypebefore still is. Only a consumer that read the entries of aFieldTypeand relied onanystops compiling. Measured bytgz-proof.shon each consumer at itscampaign/integrationtip with this tarball (see Verification): only dms-database's one site breaks, anddms-databaseadapts in its own PR. No version change beyond the 0.3.0 that W6-2 already carries; this lands in the same release.Verification
pnpm run checkson the committed head, Node 24:Checks: 8 passed, 0 failed.api-diff-slot.sh origin/campaign/integration): the only change isinterface IoTsCodecbecomingtype IoTsCodec, in the root and/schemadeclarations. Suppressions unchanged (7 lint suppressions, 2@ts-expect-error, 5SAFETY:).antelopejs-interface-database-85eaeeb.tgz, sha25647080aaffc290469fad1c7de6d71af983890fe42c42de358ea0943f7b40b8f5b, recorded in~/.cache/campaign2/tgz/index.tsv.campaign/integrationtip with the tarball applied,pnpm run checkson a tree with nodist. The one reported FAIL per proof is the pin check (integration pins other bytes, which holds for any unlanded producer); the checks line is the signal.fieldDescriptor.ts(193,50): Argument of type 'unknown' is not assignable to parameter of type 'FieldType'dms-database adapts in the follow-up PR: AntelopeJS/dms-database#105 (9 passed, 0 failed with this tarball).
Attention
unknown: a consumer that wants a typed value must narrow it with a guard of its own. dms-database does that in the follow-up PR.