我有一个WinJS应用程序,其中我使用TypeScript 2.5。我刚从VS2015升级到VS2017。当我想调试我的WinJS应用程序时,我的..ts文件中的断点不会被注意到,因为SourceMap没有正确读取。我没有改变项目的任何配置。
在输出中,我得到以下消息:
ms-appx://8d7814f6-7286-4475-8ed8-be1c489c2253/js/main.js.map SourceMap读取失败: URI前缀未被识别。我的CompilerOptions是:
"compilerOptions": {
"target": "es5",
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
}应用程序的最小和目标版本是:10.0.14393.0
我需要在VS2017中设置其他东西吗?
编辑:
复制步骤:
10.0.14393.0
/// <reference path="../tslib/winjs.d.ts"/>
WinJS.UI.processAll().then(() => {
let div: HTMLDivElement = document.createElement("div");
let label: HTMLLabelElement = document.createElement("label");
label.textContent = "Hello from the TypeScript-Side";
div.appendChild(label);
document.body.appendChild(div);
});
预期结果:在应用程序中,您可以看到文本:
内容就在这里! 你好啊,从打字稿这边来的
在输出中,您可以看到以下两条消息:
“WWAHost.exe”(脚本):加载了“脚本代码(MSAppHost/3.0)”。 ms-appx://32fb2864-03cf-4387-8a05-6c65a66c5a48/js/main.js.map SourceMap读取失败: URI前缀未被识别。
编辑2: main.js.map的内容:
{
"version": 3,
"file": "main.js",
"sourceRoot": "",
"sources": [ "main.ts" ],
"names": [],
"mappings": "AAAA,2CAA2C;AAE3C,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC;IACvB,IAAI,GAAG,GAAmB,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,KAAK,GAAqB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9D,KAAK,CAAC,WAAW,GAAG,gCAAgC,CAAC;IACrD,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"
}
EDIT3:
TypescriptBuild-设置:
TypeScript version: 2.5
Compile on save: Yes
Allow implicit 'any' types: Yes
Keep comments in JavaScript output: Yes
Generate declaration files: No
Generate source maps: Yes
Specify root directory of source maps: $(MSBuildProjectDirectory)
Specify root directory of TypeScript files: $(MSBuildProjectDirectory)
Emit on error: No如果删除tsconfig.json,源映射将正确创建。但是我需要一些其他选项的tsconfig.json,所以删除它不是一个选项!
发布于 2017-11-02 12:02:23
我找到了一个暂时解决问题的办法。我不知道这是为什么,但如果你加上这句话:
"mapRoot": "js/"它工作正常。
这只适用于默认目录设置!
https://stackoverflow.com/questions/46889515
复制相似问题