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

Syntax proposal: TypeParameters with arguments #4236

Closed
teintinu opened this issue Aug 8, 2015 · 7 comments
Closed

Syntax proposal: TypeParameters with arguments #4236

teintinu opened this issue Aug 8, 2015 · 7 comments
Labels
Duplicate An existing issue was already created

Comments

@teintinu
Copy link

teintinu commented Aug 8, 2015

I propose extend generics to support arguments in type parameters. Something like that:

  TypeParameter:
   BindingIdentifierTypeParametersoptConstraintopt

This is useful for complex API's, like factories and proxies, that need receice too many data types.

interface Data<K, V> { find(key: K): V }
function createProxy<T<K,V> extends Data<K,V>> (
   return <T<K,V>> {
      find: function(key: T.K): T.V { ... }
   }
}
interface PatientData extends Data<number,{name: string, age: number}>{ }
var pacientProxy = createProxy<PatientData>();
var {name, age} = pacientProxy.find(1);
@mhegazy mhegazy added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Aug 10, 2015
@zpdDG4gta8XKpMCd
Copy link

Also see: #1213

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Aug 11, 2015
@DanielRosenwasser DanielRosenwasser removed the Duplicate An existing issue was already created label Aug 11, 2015
@DanielRosenwasser
Copy link
Member

I notice that you have a function extending a type - can you explain what you mean by this?

@teintinu
Copy link
Author

@DanielRosenwasser isn't function createProxy extending but the type T is extending the type Data . And how type Data needs K,V arguments, my suggestion is typescript support use that arguments in type T.

@Aleksey-Bykov I don't know if #1213 solves my problem. It's new to me, looks complex. I'll study and later answer here.

Thanks guys

@DanielRosenwasser
Copy link
Member

Whoops, misread that, sorry.

@ghost
Copy link

ghost commented Nov 14, 2015

Would #214 solve this?

@steffansluis
Copy link

👍 For generic generics

@sandersn sandersn added Duplicate An existing issue was already created and removed Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript labels Dec 4, 2015
@sandersn
Copy link
Member

sandersn commented Dec 4, 2015

I'm pretty sure this is the same as higher-kinded types in #1213. I'll close this as a duplicate.

@sandersn sandersn closed this as completed Dec 4, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

6 participants