Skip to content

TS Errors on different lines - return with ternary #984

Closed
@lukpsaxo

Description

@lukpsaxo

I've seen a few instances where errors are on different lines, which with suppressions causes tsgo errors on code that compiles with tsc.

Maybe this is an accepted breaking change?

One example is this:

type Y = {
  a: number;
  b: number;
};

function fetchA() {
  return { a: 1, b: 2 };
}

function getA() {
  return { a: 1, c: "123" };
}

async function X(d?: string): Promise<Y> {
  const z = getA();

  return d && d !== z.c
    ? fetchA()
    : // @ts-expect-error
      z;
}

in tsc the error is on z - in tsgo the error is on the return line.

In other cases I've seen errors on every property in a object where in tsc it errors on the top of the whole object so its not always "up" a node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Type CheckingRelated to type checking, grammar checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions