Repository navigation
Conversation
Quest-Claim: 8744fe16662b1e24
…meter A projection a generic type's fields name, such as smallvec's <A as Array>::Item, directly, through a generic type of the crate's they hold, or as a std iterator's item, is a TypeScript type parameter of its own after the type's, named for its associated type, which each instance gives what the projection normalizes to there. A field's Option of one is an rs.OptionOf, checked per instance as a parameter's is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Problem
rust2-ts refused a generic type whose field is typed by an associated type of its parameter, such as smallvec's
Drain<'a, T: Array>holdingslice::Iter<'a, T::Item>, withunsupported type <T as smallvec::Array>::Item. A type's definition is one TypeScript type over its type parameters, and a projection had no TypeScript name. Quest: quest/m3/ts-assoc-type-fields.md.Approach
Batch<S>holdingDrained<S>getsBatch<S, Item>), and a std iterator's item that only itsIteratorimpl names (Peekable<I>'s<I as Iterator>::Item). The parameter is named for the associated type and numbered past any name it would shadow (Ahead<_Item, _I, Item2, Item3>).Drained<[u8; 4]>isDrained<Uint8Array, rs.u8>.field_value's casts use the same arguments (Translator::instance_params).OptionorPollof a projection is anrs.OptionOf/rs.PollOf, the same as one of a parameter.generic_erasurenow normalizes the instance's types and checks the projection as one unit, so it still refuses an instance whose erasure differs (Option<MaybeUninit<u32>>,Option<Option<()>>).Translator::projections) before any field is typed. A projection the walk does not find staysunsupported type, so a gap is reported at compile time rather than producing bad output.Evidence:
generics::projectionsinlang/shapes. It runs a struct, an enum that holds itself, a nested generic type, a stdPeekable, and a projection from a projection, at arrays ofu8,u16,(), andOption<u8>, and at a store that is no array, against native Rust.values::projected_uninitandvalues::projected_nested.ts/moq/model.toml) at the moq pin drops from 52 refusals to 51. The removed one is smallvec'slib.rs:360unsupported type <T as smallvec::Array>::Item. smallvec's remaining 10 are allunsafe(raw pointer behind a reference 6, union 2,Vec::from_raw_parts2).Impact
Choices made without asking
Item), thenItem2,Item3… past any it would shadow. The alternative,S_Item-style names that always spell the parameter out, reads worse for the common single-projection case. Trait objects already name their associated types by bare name (Source<Item>)._Item, as an unused type parameter already is.Alternatives
StoreItem<S>resolving byS): this would need one TypeScript type per trait, mapping every impl's self type. It cannot express impls on types that TypeScript erases alike ([u8; 4]and aUint8Arrayview), and it breaks for blanket impls.Follow-ups
None.
Validation
just ci: lint passes, and 87 of 89 fixture tests pass. The 2 that fail are the TypeId-hash snapshotslang/dyns(ids.ts) andlang/panics/hook(lib.ts), whose hashes depend on the checkout's path. Both fail the same way on bareorigin/main, CI passes them, and moq-dev/rust2#633 fixes them.Models
Size: M
Implementer: Claude Code, claude-opus-5-5, high effort
(Written by Claude Opus 5.5 with high effort)
🤖 Generated with Claude Code