Skip to content

feat(compiler): add type spread operator (...) for composite types#645

Open
wilmveel wants to merge 2 commits into
masterfrom
claude/wire-spec-type-spread-TiHPA
Open

feat(compiler): add type spread operator (...) for composite types#645
wilmveel wants to merge 2 commits into
masterfrom
claude/wire-spec-type-spread-TiHPA

Conversation

@wilmveel

Copy link
Copy Markdown
Contributor

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

claude added 2 commits May 23, 2026 13:12
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
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants