originalPositionFor returns null if sourcemap does not contains the exact line.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Description
originalPositionFor returns null if sourcemap does not contains the exact line.
It cause the issue with typescript(ts-node) that may not create source map for all the lines,
especially when the source contains multi-line chained function call like below.
let obj:any = null;
obj
.map();
In this case, the error happens on the last line. But, sourcemap does not have information on the line. So, the following code assume the mapping does not found and return null.
It is much better to return the nearest source map position, instead of just return null.
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 in lib/source-map-consumer.js around line 616 and reproduce the multiline chained-call example from the issue with a sourcemap that lacks the exact line. Check how originalPositionFor handles missing mappings; done means it returns the nearest source-map position instead of null for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100