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

Add a LambdaTypeDeclare command #587

Open
JoshuaKGoldberg opened this issue Nov 24, 2018 · 0 comments
Open

Add a LambdaTypeDeclare command #587

JoshuaKGoldberg opened this issue Nov 24, 2018 · 0 comments

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Nov 24, 2018

What command(s) would you like to add?

lambda type declare

Declares a type for a lambda that can be passed around similar to an interface.

Parameters

  • export (optional): keyword to expose the lambda type declaration publicly
  • typeName: PascalCase name of the type
  • returnType: What type the lambda returns
  • (parameterName, parameterType): Zero or more pairs of parameter names and types

Sample usage

lambda type declare : export FormatInt string value int

Why?

This is different from lambda type inline (#588), which is more akin to declaring a type primitive like null.
Languages need a prettier way than lambda type inline to declare lambda types, especially when many methods take in the same lambda type.

For example, in C#, FormatInt would be:

public delegate string FormatInt(int value);

...while in TypeScript, FormatInt would be:

type FormatInt = (value: number) => string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant