【发布时间】:2021-07-12 10:24:21
【问题描述】:
正如您在上面看到的,构建过程永远不会完成,并且不会出现扩展主机窗口。
所有扩展全部禁用时也存在问题
但是使用javascript创建项目时不存在此问题(问题仅与typescript有关)
我遵循的步骤来自this tutorial 我还尝试了来自github 的hello world 示例。 但它们都不起作用。
编辑:
我尝试通过code --extensionDevelopmentPath="path/to/my/project"手动打开扩展开发主机窗口,它成功了。
- 我认为问题出在 vscode 的某些配置上
可能的解决方法:我应该检查诸如npm: watch 之类的配置。但我不知道它们在哪里,我该怎么处理它们??
有什么想法吗?
编辑 2:
task.json
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
- 然后我注意到,如果我在
launch.json文件中注释掉"preLaunchTask": "${defaultBuildTask}",问题就解决了。
【问题讨论】:
-
typescript 需要转译成 Javascript,所以扩展总是运行 JavaScript
-
@rioV8 好的,我知道,typescript 应该编译成 javascript。在我的项目中打字稿编译成功但扩展开发主机没有出现。
-
你说一个Javascript项目可以工作,Typescript编译后没有区别,如果你把它变成一个Javascript项目,编译后的文件是什么
-
@rioV8 generator code 创建了这个项目,我想我不需要做任何额外的事情。但我会试试你说的:)
-
@rioV8 请查看编辑
标签: javascript typescript visual-studio-code vscode-extensions tsc