【问题标题】:Visual Studio Code extension development problem with typescript打字稿的Visual Studio Code扩展开发问题
【发布时间】: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


【解决方案1】:

最后我发现了这个问题。这是因为我系统的语言环境设置为Persian,打字稿问题匹配器无法识别(波斯数字)。

通过将系统区域设置为英语,问题解决了,现在一切正常。

please see the issue on github

【讨论】:

    猜你喜欢
    • 2019-04-27
    • 2017-11-09
    • 1970-01-01
    • 2017-07-01
    • 2021-11-22
    • 2023-03-24
    • 2015-08-04
    • 2018-05-13
    • 1970-01-01
    相关资源
    最近更新 更多