我正在使用TypeScript和汇总,如this article中所述。
因此math.ts
export function square(x: number) {
return x ** 2;
}
export function cube(x: number) {
return x ** 3;
}
和main.ts
import { square } from "./math";
console.log(square(3));
在命令后生成
tsc -t ES5 -m es2015 && rollup -f es -o app.js -m -i main.js
文件app.js
function square(x) {
return Math.pow(x, 2);
}
console.log(square(3));
//# sourceMappingURL=app.js.map
但是生成的源映射指向.js
的tsc
输出,而不是原始的.ts
文件。如何获得后者?
以某种方式可以生成app.ts.map
您正在考虑错了。您具有一个生成的.js
文件和一个生成的.js.map
文件包含TS文件代码信息。
[不需要.ts.map
即可查看ts源。