microsoft / microsoft/TypeScript

Middle operand in comma operator list not properly checked for side-effect-freeness

Open
#33,646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

TypeScript Version: master at f304b81fa54285f
Search Terms: comma side effects

Code

declare const obj: any;
console.log(`${JSON.stringify(obj), undefined, 2}`);

Expected behavior: error TS2695: Left side of comma operator is unused and has no side effects.

Actual behavior: No errors

Playground Link: http://www.typescriptlang.org/play/#code/CYUwxgNghgTiAEYD2A7AzgF3kgRgKwC54oUBPAbgChl0kIQA6CJAcwAoADAEgG8ApAMoB5AHINMMAJYoWkgGak2uPAEoANPACuKUHOkhgGgEwBfDiqpA

Related Issues:
#10814

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

Reproduce the TypeScript version of the issue with the provided comma-expression example, then trace the compiler's side-effect checking for the middle operand. Compare the behavior with related issue #10814. Done means the example reports TS2695 for the unused, side-effect-free operand without introducing errors for valid comma expressions.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.