Skip to content

[type-annotation-spacing] no distinction between parameters, properties and return types #1489

@chkt

Description

@chkt

[type-annotation-spacing] no distinction between parameters, properties and return types

The type-annotation-spacing rule only distinguishes between colon and arrow rules. The equivalent typedef-whitespace rule in tslint allowed to define different rules for properties, variables, parameters, index signatures and call signatures (which covered both the function() : void as well as the () => void case). While the two rules are supposed to equivalent, their functionality is in practice only vaguely similar.

Can type-annotation-spacing be extended to at least bring a distinction between variables and parameters, properties, and function call return types, so that it would provide roughly the same configurability as typedef-whitespace?

Expected behaviour:

interface Person {
  firstName : string;
  lastName : string;
}

type getFirstName = (person:Person) => string;

function greet(getName:getFirstName) : string {
  return `Hi ${ getName() }`;
}

const person:Person = { firstname : 'John', lastName : 'Doe' };

A setup like this is completely acceptable to tslint; I do think that this issue does in the end comes down to preference, while the lack of configurability of type-annotation-spacing right now means that anybody coming from tslint and having a non-standard setup will have to fix up their whole code base or just disable this test completely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy