我们有一个问题,at ts 文件没有在所有不同的两台计算机上提供相同的 js 文件。
两台计算机都半全新安装了 Win10 和 VS2015 Enterprise(中等安装)。
我们在 Visual Studio 中打开相同的 ts 文件并保存它而不对文件进行任何更改,但我的输出与同事的输出不同。
我们已经检查了 Typescript 的 procect 设置,它们是相同的。还有什么可以给这个问题?我们是 typescript 的新手,到目前为止,google 或 stackovwerflow 都无法给我们答案。
ts 文件看起来像这样:
export class App {
public router: any;
configureRouter(config, router) {
config.title = 'Start';
config.map([
{ route: 'start/:SBTSystemId', name: 'start', moduleId: './components/Start', title: 'Start', nav: false },
{ route: 'symptom/:SBTSystemId', name: 'symptom', moduleId: './components/symptom', title: 'Symptom', nav: false },
{ route: ['diagnostic/:SBTSystemId/:StepId/:PrevStepId', 'diagnostic/:SBTSystemId/:StepId'], name: 'diagnostic', moduleId: './components/diagnostic', title: 'Diagnostic', nav: false },
{ route: 'conclusion/:SBTSystemId/:ConclusionId/:PrevStepId', name: 'conclusion', moduleId: './components/conclusion', title: 'Conclusion', nav: false }
]);
this.router = router;
}
}
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.globalResources(['assets/custom-elements/TopNavigationCustomElement', 'assets/custom-elements/BottomNavigationCustomElement', 'assets/custom-elements/SbtLinkCustomElement']);
aurelia.start().then(() => aurelia.setRoot('app'));
}
我的输出是:
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var App;
function configure(aurelia) {
"use strict";
aurelia.use
.standardConfiguration()
.developmentLogging()
.globalResources([
"assets/custom-elements/TopNavigationCustomElement",
"assets/custom-elements/BottomNavigationCustomElement",
"assets/custom-elements/SbtLinkCustomElement"]);
aurelia.start().then(function () { return aurelia.setRoot("app"); });
}
exports_1("configure", configure);
return {
setters:[],
execute: function() {
App = (function () {
function App() {
}
App.prototype.configureRouter = function (config, router) {
config.title = "Start";
config.map([
{
route: "start/:SBTSystemId", name: "start",
moduleId: "./components/Start", title: "Start", nav: false
},
{
route: "symptom/:SBTSystemId", name: "symptom",
moduleId: "./components/symptom", title: "Symptom", nav: false
},
{
route: ["diagnostic/:SBTSystemId/:StepId/:PrevStepId", "diagnostic/:SBTSystemId/:StepId"], name: "diagnostic",
moduleId: "./components/diagnostic", title: "Diagnostic", nav: false
},
{
route: "conclusion/:SBTSystemId/:ConclusionId/:PrevStepId", name: "conclusion",
moduleId: "./components/conclusion", title: "Conclusion", nav: false
}
]);
this.router = router;
};
return App;
}());
exports_1("App", App);
}
}
});
//# sourceMappingURL=app.js.map
他的输出是:
"use strict";
var App = (function () {
function App() {
}
App.prototype.configureRouter = function (config, router) {
config.title = 'Start';
config.map([
{ route: 'start/:SBTSystemId', name: 'start', moduleId: './components/Start', title: 'Start', nav: false },
{ route: 'symptom/:SBTSystemId', name: 'symptom', moduleId: './components/symptom', title: 'Symptom', nav: false },
{ route: ['diagnostic/:SBTSystemId/:StepId/:PrevStepId', 'diagnostic/:SBTSystemId/:StepId'], name: 'diagnostic', moduleId: './components/diagnostic', title: 'Diagnostic', nav: false },
{ route: 'conclusion/:SBTSystemId/:ConclusionId/:PrevStepId', name: 'conclusion', moduleId: './components/conclusion', title: 'Conclusion', nav: false }
]);
this.router = router;
};
return App;
}());
exports.App = App;
function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.globalResources(['assets/custom-elements/TopNavigationCustomElement', 'assets/custom-elements/BottomNavigationCustomElement', 'assets/custom-elements/SbtLinkCustomElement']);
aurelia.start().then(function () { return aurelia.setRoot('app'); });
}
exports.configure = configure;
//# sourceMappingURL=app.js.map
最重要的是,我的所有输出都破坏了应用程序(使 aurelia 框架调用配置方法两次,但他的输出工作正常)。
有人知道发生了什么事吗? 如果有任何影响,该项目是在升级到 VS2015 之前大约一个月在 VS2013 中创建的。
Out typescript 项目设置如下:
最佳答案
问题解决了。我的同事 VS 根本没有转译 ts 文件。他的输出是commonJS的,但是改成System后js文件就不再被VS转译了。删除 js 文件的内容并再次保存 ts 文件给了他与我相同的输出。所以好像是 af VS bug
关于javascript - Visual Studio 为不同的 pc 转换 TypeScript 的不同输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37699352/