feat(compiler): add type spread operator (...) for composite types#645
Open
wilmveel wants to merge 2 commits into
Open
feat(compiler): add type spread operator (...) for composite types#645wilmveel wants to merge 2 commits into
wilmveel wants to merge 2 commits into
Conversation
Allow splicing the fields of one composite type into another using the
`...Type` notation, e.g. `type SomeQuery { ...Pagination, query: String? }`.
This avoids duplicating shared fields when Wirespec has no generics.
The tokenizer recognizes a new `...` token, the type parser collects spread
targets per type definition (preserving field order via the spread position),
and the validator flattens spreads into the field list recursively. Spreads of
non-record types and cyclic spreads are reported as validation errors. Because
resolution happens before any downstream consumer runs, emitters and converters
see an ordinary field list and need no changes.
https://claude.ai/code/session_01Km8Nsu5nkJi2BJYS8x2zai
The IntelliJ plugin reuses the core tokenizer, so it now produces `Spread` (`...`) tokens. Without a class-to-IElementType mapping the lexer's getTokenType() returns null on `...`, which IntelliJ interprets as end-of-stream and silently drops the rest of the file. Add a SPREAD element type, map it in the lexer, and give it dot highlighting. The lenient PSI parser already treats the spread target as a custom type reference. https://claude.ai/code/session_01Km8Nsu5nkJi2BJYS8x2zai
|
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.



Allow splicing the fields of one composite type into another using the
...Typenotation, e.g.type SomeQuery { ...Pagination, query: String? }.This avoids duplicating shared fields when Wirespec has no generics.
The tokenizer recognizes a new
...token, the type parser collects spreadtargets per type definition (preserving field order via the spread position),
and the validator flattens spreads into the field list recursively. Spreads of
non-record types and cyclic spreads are reported as validation errors. Because
resolution happens before any downstream consumer runs, emitters and converters
see an ordinary field list and need no changes.
https://claude.ai/code/session_01Km8Nsu5nkJi2BJYS8x2zai