microsoft / microsoft/TypeScript
Disallow newline after `as` after function instantiation
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
as newline ASI function type parameters spec difference
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
let x = foo < 2 > as
F.getter
🙁 Actual behavior
It is parsed as
let x = foo<2> as F.getter;
🙂 Expected behavior
It should be parsed as
let x = (foo < 2) > as;
F.getter;
Additional information about the issue
The linked code is valid JavaScript code, and it would be great if tsc could parse as such.
I know that TS is not in general a syntactic superset of JavaScript, but both Babel and SWC already parse this example (when in TS mode) according to JS semantics. We could change our parsers, but it would be better if this ambiguity could be solved in tsc.
cc @kdy1
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
Reproduce the parsing difference using the linked TypeScript Playground and the provided code sample, then trace how the TypeScript parser handles as across a newline after function instantiation. Done means the sample follows the expected JavaScript/ASI parse while existing TypeScript parsing behavior remains covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100