Skip to content

rule proposal: disallow wider return type annotations #694

@gameroman

Description

@gameroman

Examples

Invalid

// explicit return type is wider than what the function actually returns

function a(): string | number {
  return "some string";
}

declare const v: 1 | 2;

function b(): 1 | 2 | 3 {
  return v;
}

Valid

// explicit return type matches actual return

function a(): string {
  return "some string";
}

declare const v: 1 | 2;

function b(): 1 | 2 {
  return v;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions