microsoft / microsoft/TypeScript
unused local not detected on recursive functions
Open
Nobody has claimed this yet.
Bug
Domain: Something Else
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Bug Report
🔎 Search Terms
unused local recursive function
🕗 Version & Regression Information
v4.5.0-dev.20210807
⏯ Playground Link
Playground link with relevant code
💻 Code
export {}
//no error even though foo is never read
const foo = () => {
foo()
}
//error: 'bar' is declared but its value is never read.(6133)
const bar = () => {}
🙁 Actual behavior
no error even though foo is never read
🙂 Expected behavior
'foo' is declared but its value is never read.(6133)
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 linked TypeScript Playground and reproduce the difference between the recursive foo function and the unused bar function with noUnusedLocals enabled. The payload names no source file or test, so trace the compiler's unused-local analysis from this reproduction. Done means the recursive declaration reports diagnostic 6133 without incorrectly changing the bar behavior.
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