specta: emit Feature.properties as TS unknown instead of recursive Value#7
Closed
johncarmack1984 wants to merge 1 commit into
Closed
specta: emit Feature.properties as TS unknown instead of recursive Value#7johncarmack1984 wants to merge 1 commit into
unknown instead of recursive Value#7johncarmack1984 wants to merge 1 commit into
Conversation
…Value
specta-rc.24's `serde_json::Value` Type impl is `inline: true` and
recursive (`Vec<Value>`, `Map<String, Value>`). When that gets
inlined into a struct field like `Feature.properties: Option<JsonObject>`,
the inlined arms reference an undefined `Value` name in the generated
TS, breaking typecheck downstream:
properties: { [key in string]: ... | { Array: Value[] } & {...} | ... };
// ^^^^^ TS2304: Cannot find name 'Value'
Override the field at the TS layer to `specta_typescript::Unknown`
(renders as TS `unknown`). Wire format and runtime behavior are
unchanged; consumers already have to walk JSON properties opaquely
since they're caller-defined per spec.
Collaborator
Author
|
Superseded by the named-JsonValue-alias approach on branch |
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.
Summary
specta-rc.24's
serde_json::ValueType impl isinline: trueand recursive (Vec<Value>,Map<String, Value>). When inlined into a struct field likeFeature.properties: Option<JsonObject>, the inlined arms reference an undefinedValuename in the generated TS:Valueis never emitted as a top-level alias because its NDT isinline: true, andrequires_referencereturns false for inline types -- so it's filtered out of the export pass. The inlined references are dangling.Override the field at the TS layer to
specta_typescript::Unknown(renders as TSunknown). Wire format and runtime behavior are unchanged; downstream consumers already have to walkpropertiesopaquely since they're caller-defined per the GeoJSON spec.Test plan
cargo build --features spectacleancargo test --features specta(37 passed, 0 failed)