Skip to content

originalPositionFor returns null if sourcemap does not contains the exact line. #261

@yoshiokatsuneo

Description

@yoshiokatsuneo

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.

if (mapping.generatedLine === needle.generatedLine) {

It is much better to return the nearest source map position, instead of just return null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions