的Visual Studio编译没有打字稿
我有像这样的结构的Visual Studio项目:的Visual Studio编译没有打字稿
我tsconfig.json
样子:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "../wwwroot/"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
然而,VS是不是编译app.ts
进入wwwroot
文件夹。
我错过了什么?
从的Visual Studio内,项目>属性>构建>确保 “编译打字稿上构建” 被选中:
而且,在你tsconfig.json
你应指定一个rootDir
,以便TypeScript知道在哪里寻找*.ts
文件它sh乌尔德编译:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "../wwwroot/",
"rootDir": "../wwwroot/"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
不要忘了实际构建它。这不是文件观察器场景。
Cheers David的“保存时编译”。事实证明,我的谜题缺失的原因是我没有意识到它是在构建时触发的,我认为它不断地观看这些文件。 – BanksySan
Visual Studio实际使用tsconfig.json中的设置吗? –
@VernJensen绝对,如果他们被省略,那么他们依靠默认值。 –
尝试增加"compileOnSave": true
您tsconfig.json
:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "../wwwroot/"
},
"exclude": [
"node_modules",
"wwwroot"
],
"compileOnSave": true
}
应该编译每次你现在节省时间。
这是为我做的。 –
您是否在项目属性 - >构建中选中了“编译生成脚本”? –
这是...我没有建立!我认为这是连续的而不是建立。感谢指针。 – BanksySan
@BanksySan您可能正在寻找属性> TypeScript Build –