Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

no-function-expression and generic functions in TSX #518

@astorije

Description

@astorije

While the following is supported by the language:

function foo<T>(x: T): T { return x; }

The following is not:

const foo = <T>(x: T) => x; // ERROR : unclosed `T` tag

no-function-expression encourages to use arrow functions, which can lead to the following to make the linter pass (or disable the linter on a case-by-case basis):

const foo = <T extends {}>(x: T) => x;

Which isn't great. See https://stackoverflow.com/questions/32308370/what-is-the-syntax-for-typescript-arrow-functions-with-generics

Similarly to the fact that function expressions that contain a this reference are allowed and will not create a failure, it would be nice if function expressions that have a generic type were allowed.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: EasySomeone with little to no experience in TSLint should be able to send a pull request for this issue.Status: Accepting PRsType: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions