Skip to content

Add a LambdaTypeDeclare command #587

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions