IssueRaiser

Proposal: Partial Type Argument Inference

After exploring the concept in #23696, we've come to the conclusion that implicitly making type arguments available by name would unnecessarily expose previously unobservable implementation details. As such, I'll be breaking that proposal down into two parts. One is just the partial inference (which is here), which can stand on its own, as discussed in #20122 and #10571. To recap, partial type argument inference is the idea that some number of type arguments in a type argument list may be provided, while others are elided and fulfilled via inference using the rest. Specifically, in #10571 a number of different syntax proposals will brought forward: For the following examples, assume we have a ```ts declare foo<A,B,C>(): [A, B, C]; ``` # Variant 1 - elided entries ```ts foo<,,string>(); // returns [{}, {}, string] ``` This is the most terse option, as simply the lack of inputs implies inference sites. This would almost seem to logically follow from how not providing a list also causes inference to occur at all sites. This does have issues, however: specifying a final parameter as needing inference would require a trailing `,` in the list (something we currently explicitly disallow), and lists could very easily become confusing, as a `,` is very easy to skip over. # Variant 2 - Sigil marker ```ts foo<*, *, string>(); // returns [{}, {}, string] ``` As the second most terse option, this also has appeal; however I think it also fails on a few points. First, `*` is non-obviou

Posted by weswigham on Aug 6, 2018, 9:40 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

reliability (Other)

Proposal: Partial Type Argument Inference

weswighamAug 6, 2018, 9:40 PM

After exploring the concept in #23696, we've come to the conclusion that implicitly making type arguments available by name would unnecessarily expose previously unobservable implementation details. As such, I'll be breaking that proposal down into two parts. One is just the partial inference (which is here), which can stand on its own, as discussed in #20122 and #10571. To recap, partial type argument inference is the idea that some number of type arguments in a type argument list may be provided, while others are elided and fulfilled via inference using the rest. Specifically, in #10571 a number of different syntax proposals will brought forward: For the following examples, assume we have a ```ts declare foo<A,B,C>(): [A, B, C]; ``` # Variant 1 - elided entries ```ts foo<,,string>(); // returns [{}, {}, string] ``` This is the most terse option, as simply the lack of inputs implies inference sites. This would almost seem to logically follow from how not providing a list also causes inference to occur at all sites. This does have issues, however: specifying a final parameter as needing inference would require a trailing `,` in the list (something we currently explicitly disallow), and lists could very easily become confusing, as a `,` is very easy to skip over. # Variant 2 - Sigil marker ```ts foo<*, *, string>(); // returns [{}, {}, string] ``` As the second most terse option, this also has appeal; however I think it also fails on a few points. First, `*` is non-obviou

Comments (0)

No comments yet. Start the discussion.

Comment on this issue