microsoft / microsoft/TypeScript
ts error should better explain that import is a reserved keyword for a function name
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.1.6
Search Terms:
import
import keyword
keyword
Code
given the following code with a function named import 😞 :
export function import(pad_id: number, config: Config, csvRows: string[][], externalCallback: (err?: Error | null, data?: string[]) => void) {
...

Expected behavior:
A clear error message explaining that import is a reserved keyword
Actual behavior:
A cryptic error message telling that there's a missing semicolumn :

Playground Link:
Related Issues:
didn't found any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied TypeScript snippet containing a function named import and reproduce the current diagnostic. Trace how the compiler parses this reserved keyword in that position, then update the diagnostic so it explains the restriction rather than reporting a missing semicolon. Confirm that the reported error is clearer without changing valid cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100