mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-13 05:37:13 -05:00
Test to verify external source map range addition
This commit is contained in:
@@ -95,6 +95,39 @@ namespace ts {
|
||||
module: ModuleKind.ES2015,
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true
|
||||
});
|
||||
});
|
||||
|
||||
emitsCorrectly("sourceMapExternalSourceFiles",
|
||||
[
|
||||
{
|
||||
file: "source.ts",
|
||||
// The text of length 'changed' is made to be on two lines so we know the line map change
|
||||
text: `\`multi
|
||||
line\`
|
||||
'change'`
|
||||
},
|
||||
],
|
||||
{
|
||||
before: [
|
||||
context => node => visitNode(node, function visitor(node: Node): Node {
|
||||
if (isStringLiteral(node) && node.text === "change") {
|
||||
const text = "'changed'";
|
||||
const lineMap = computeLineStarts(text);
|
||||
setSourceMapRange(node, {
|
||||
pos: 0, end: text.length, source: {
|
||||
text,
|
||||
fileName: "another.html",
|
||||
lineMap,
|
||||
getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos)
|
||||
}
|
||||
});
|
||||
return node;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
})
|
||||
]
|
||||
},
|
||||
{ sourceMap: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// [source.js.map]
|
||||
{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QACE,CDCM"}
|
||||
|
||||
// [source.js]
|
||||
"multi\n line";
|
||||
'change';
|
||||
//# sourceMappingURL=source.js.map
|
||||
Reference in New Issue
Block a user