Skip to content

Show exact error position in arrays & arrow functions #27030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cevek opened this issue Sep 11, 2018 · 4 comments
Closed

Show exact error position in arrays & arrow functions #27030

cevek opened this issue Sep 11, 2018 · 4 comments
Assignees
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue

Comments

@cevek
Copy link

cevek commented Sep 11, 2018

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

@DanielRosenwasser what do you think?

@DanielRosenwasser DanielRosenwasser added Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements labels Sep 11, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.2 milestone Sep 11, 2018
@DanielRosenwasser
Copy link
Member

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

@DanielRosenwasser
Copy link
Member

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

@weswigham
Copy link
Member

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

@DanielRosenwasser DanielRosenwasser changed the title Error output: show exact error position if it possible Show exact error position in arrays & arrow functions Sep 11, 2018
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Oct 30, 2018
@DanielRosenwasser
Copy link
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
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants