microsoft / microsoft/TypeScript

Improve errors for potential arrow functions

Open
#25,898 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Error Messages Effort: Moderate Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

There are certain locations where arrow functions don't parse

var x = window.foo || () => {}

In these instances, it would be nice if users could get a better error message as to avoid issues like #25897.

Ideally this should not be an invasive change.

  • The change should be limited in scope.
  • The parser should continue erroring in those locations.
  • The change must not introduce change how existing valid code is parsed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the parser handling for the invalid arrow-function form shown in the issue and reproduce the diagnostic for var x = window.foo || () => {}. Done means the parser still rejects these locations, reports a more useful error, and does not change parsing of existing valid code.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.