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

Is there a way to approach Type Lamdas? #20269

Closed
Brooooooklyn opened this issue Nov 26, 2017 · 8 comments
Closed

Is there a way to approach Type Lamdas? #20269

Brooooooklyn opened this issue Nov 26, 2017 · 8 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@Brooooooklyn
Copy link

I have a function with Generic types and I want transfer it into another function with the same Generic types:

class Module {
  foo<T>(action$: Observable<T>): Observable<R>
  bar<T>(action$: Observable<T>): Observable<R>
}

interface ModuleActionProps<M extends Module> {
  [key in keyof M]: (payload T): R // need something here transform <T>(action$: Observable<T>): Observable<R> to (payload: T): R to ensure T and R is same here
}
@gcnew
Copy link
Contributor

gcnew commented Nov 26, 2017

Do you mean the same generic container type? If that's the case #1213 is tracking adding Higher Kinded Types.

E.g. someting like

interface ModuleActionProps<M extends Module, C> {
  [key in keyof M]: <T, R>(payload: C<T>): C<R> // `C` is the collection type
}

@Brooooooklyn
Copy link
Author

uh... I don't know how to describe what I want in terms.

I think this approach could describe what I need:

type GetGenericType1<F extends <T, R>(action$: Observable<T>): Observable<R>> = T
type GetGenericType2<F extends <_, R>(action$: Observable<T>): Observable<R>> = R
interface ModuleActionProps<M extends Module, C> {
  [key in keyof M]: (payload: GetGenericType1<M[key]>):  GetGenericType2<M[key]> 
}

@Brooooooklyn Brooooooklyn changed the title Is there a way to get Generic param ? Is there a way to approach Type Lamdas? Nov 27, 2017
@Brooooooklyn
Copy link
Author

maybe this question could be describe as Type Lambdas

@gcnew
Copy link
Contributor

gcnew commented Nov 27, 2017

Take a look at #14400 and #6606. These suggestions propose type-first and expression-first type level application.

@HerringtonDarkholme
Copy link
Contributor

Related #12342

@mhegazy
Copy link
Contributor

mhegazy commented Jan 31, 2018

I think this should be covered by #21316

@KiaraGrouwstra
Copy link
Contributor

6606 version: express type lambda T => T as <T>(v: T) => T.

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Apr 20, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

6 participants