Skip to content

Improve error messages for method chains #31365

@ulrichb

Description

@ulrichb

Search Terms

error call chain fluent api

Suggestion

In call chains some errors like TS2554 ("Expected x arguments, but got y") are reported for the whole call chain.

Example:

image

In this case the error is reported (starting) at line 5 where the actual error is in line 14.

Suggestion: Just highlight the concerned (last) method invocation in this case.

Use Cases

  • Fluent APIs: These sub-optimal error reporting is misguiding in fluent APIs because the start line number can be off hundreds of lines. Further, way too much is highlighted in red squiggles (for a single missing argument as in the example above).

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions