microsoft / microsoft/TypeScript
Consecutive function declaration problems in JS files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Bug Report
🔎 Search Terms
function declaration, method declaration, consecutive, comma
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about jsdoc problems
Tested with typescript@4.4.0-dev.20210602
⏯ Playground Link
💻 Code
/**
* @param {number} num
* @returns {number}
*/
const numb = (num) => num,
/**
* @param {string} str
* @returns {string}
*/
str = (str) => str
console.log(numb(2), str(4))
🙁 Actual behavior
Because of the consecutive declaration the real error is not catched. This only happens in js files
🙂 Expected behavior
Method declaration style shouldn't matter in js files either, so the error should be: ""Argument of type 'number' is not assignable to parameter of type 'string'."
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
Run the linked Playground reproduction with the supplied JavaScript code and confirm that the consecutive comma-separated declarations suppress the intended argument-type diagnostic. Find the JavaScript type-checking path and add a regression test for the example; done when it reports that number is not assignable to string, matching the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100