microsoft / microsoft/TypeScript

fixUnusedIdentifier may remove a used side-effect

Open
#23,970 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Quick Fixes Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 2.9.0-dev.20180506

Code

{ const x = launchMissiles(); }

Expected behavior:

const x = removed, and missiles still launched.

Actual behavior:

Missiles unlaunched.

Unfortunately we have no way of knowing whether a function call does have side effects (#17181), so doing this in general might be annoying as users have to manually delete function calls with unused results.

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 by locating the fixUnusedIdentifier entry point and reproduce the issue with the provided { const x = launchMissiles(); } example. Determine how unused identifiers are removed while preserving the function call's possible side effect, and verify that the compiled output still launches the missiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.