Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value-level generic type names #15347

Closed
dead-claudia opened this issue Apr 24, 2017 · 4 comments
Closed

Value-level generic type names #15347

dead-claudia opened this issue Apr 24, 2017 · 4 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@dead-claudia
Copy link

dead-claudia commented Apr 24, 2017

This is a supplementing proposal to go with my constraint types proposal: #13257, but it also could be very powerful for working with the typeof proposal in #6606.

In that proposal, there is the ability to dispatch type based on value is Whatever, and it would be useful to also generically pass bindings (not just raw types).

Proposal

// Declaration
interface Foo<expr value> {}
type Foo<expr value> = ...

// Declaration with constraints
interface Foo<expr value is Bar> {}
type Foo<expr value is Bar> = ...

// Usage
const foo: Foo<foo>;
declare function bar(item: any): Foo<item>
interface Bar { self: Foo<this>; }
  • In declarations, you simply prefix expr to make it a value-level binding rather than a type.
  • You may constrain these with the same value is T syntax currently available in return values.
  • Using them is as simple as passing a variable name as a parameter.
  • Any typeof operand supported is also supported here as a generic parameter.
  • this is a valid binding.
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@masaeedu
Copy link
Contributor

Are you sure 6066 is the right issue number here? It appears to be a PR related to the language service.

@dead-claudia
Copy link
Author

@masaeedu Nope. Fixed to the right issue (#6606).

@RyanCavanaugh
Copy link
Member

I don't understand at all what this is proposing. What is a value-level binding? Is value a special name here? What is this for?

@RyanCavanaugh RyanCavanaugh added Needs More Info The issue still hasn't been fully clarified and removed Needs Investigation This issue needs a team member to investigate its status. labels Sep 16, 2019
@dead-claudia
Copy link
Author

I'm not fully sure either at this point, so I'll close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants