Skip to content

Show exact error position in arrays & arrow functions #27030

Description

@cevek

If it is not assignable error and infered expression type origin comes from inside of ast error boundaries we can show exact position of an error source

interface Foo {
    a: number;
}

function foo1(): () => Foo {
    return () => ({a: ''});
}

function foo2(): Promise<Foo> {
    return Promise.resolve({a: ''});
}

function foo3(): Foo[] {
    return [{a: ''}];
}
var y: Foo[] = [{a: ''}] 
var z: Foo[] = [].map(() => ({a: ''}))

agdagag

Daniel Rosenwasser (@DanielRosenwasser) what do you think?

Activity

  1. DanielRosenwasser commented on Sep 11, 2018

    @DanielRosenwasser
    Member

    This can get arbitrarily complex, but I think that for certain arrays and arrow functions, we can definitely do better here.

  2. DanielRosenwasser commented on Sep 11, 2018

    @DanielRosenwasser
    Member

    Specifically I can see us dealing with foo1, foo3, and y pretty easily. I think that foo2 and z will be harder.

  3. weswigham commented on Sep 11, 2018

    @weswigham
    Member

    Daniel Rosenwasser (@DanielRosenwasser) It should just be a matter of adding more cases to elaborateError to handle diving into more expressions.

  4. changed the title [-]Error output: show exact error position if it possible [/-] [+]Show exact error position in arrays & arrow functions[/+] on Sep 11, 2018
  5. DanielRosenwasser commented on Oct 30, 2018

    @DanielRosenwasser
    Member

    I think that the majority of work done has been done here; the Promise.resolve case is a little harder, but if it's compelling enough for your day-to-day coding I encourage you to open up another issue. Thanks cevek!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: Error MessagesThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions