Skip to content

feat: let a resource declare its type parameters - #78

Draft
moetemp wants to merge 1 commit into
moe/up/dotnet-client-targetfrom
moe/up/resource-type-parameters
Draft

moetemp wants to merge 1 commit into
moe/up/dotnet-client-targetfrom
moe/up/resource-type-parameters

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR lets a resource declare its type parameters, in Python, TypeScript and .NET. With @nexus.type-parameter "<alias>", the resource class is generic.

  • An operation that returns the resource takes a runtime type for each parameter. So the stream sample's Python create_stream(Turn, id=...) returns a Stream[Turn].
  • A method takes a runtime type only for a parameter that only its output uses. So the read takes one, and the append takes none. Each language decodes generic response values with the handle's runtime types.
  • Go and Java refuse a generic resource. nexgen also refuses one as a record field, or as the result of an operation with no @nexus.proto message, since neither gives the type arguments.

Why?

The proposal's Stream API is generic in its value type, as in Stream[Turn], so a read must decode the body as the handle's type, not as a raw payload. A resource couldn't use a type parameter at all.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

The Python, TypeScript and .NET tests read typed values. A parser unit test covers a type parameter alias that use brings in from another interface.

A resource with `@nexus.type-parameter "<alias>"` is generic in Python, TypeScript and .NET. An
operation that returns it, or that its method binds, takes a runtime type for each type parameter
of its output, so a response decodes its generic values.
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 9791e30 to 5f8ad4f Compare October 31, 2026 13:08
@moetemp
moetemp changed the base branch from moe/up/python-poll to moe/up/dotnet-client-target October 31, 2026 13:09
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.

1 participant