typescript - 如何在 Visual Studio 代码中使用最新版本的 tsc?
问题描述
如何在 Visual Studio 代码中使用最新版本的 tsc?
我在网上搜索并尝试了很多我在网上找到的东西,但是我没有成功使用最新版本的tsc进行内部代码检查。
我有 tsc 3.7.3 附带的 VSC 1.41.1 为了编译,我安装了 tsc 3.7.5,它给了我一些更有趣的错误提示(如 TS7053),所以我也想用它进行内部检查。我的期望:版本 3.7.5 的结果显示在终端的“问题”选项卡中 - 在自动检查中,因此我可以单击它们来更正错误
但是无论我尝试了什么,“问题”选项卡一直告诉我“没有问题..”,问题仅显示在“终端”选项卡中(并且不可点击)
我已经尝试过:在多次尝试在本地和全局调用“npm install typescript”后,我成功在右下角已安装版本的上下文菜单中获得了 3.7.5 版本,但选择它并没有给出所需的行为.
首先我尝试不定义项目,现在我有一个 - 没有成功
我的项目的布局(项目名称 ZAnim)(子文件夹/文件用“--”表示):
.vscode/
--settings.json
node_modules/(tsc installation...)
ZAnim.code-workspace
ZAnim/
--.vscode/
----tasks.json
----tsconfig.json
--*.ts
--package-lock.json
--built/...
--node_modules/(tsc installation...)
文件 settings.json:(VSCode 是项目的包含文件夹)
{
"typescript.tsdk": "c:\\d\\VSCode\\node_modules\\typescript\\lib"
}
文件tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": ".vscode/tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
文件 tsconfig.json
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "ES2017",
"outFile": "../built/local/tsc.js",
"sourceMap": true
},
"include": [
"../*.ts"
]
}
你看,除了全局 tsc 安装之外,我这里还有 2 个本地安装(都是 3.7.5),因为绝望。我在项目子文件夹中也有文件settings.json,但是在这里我总是在“typescript.tsdk”设置中出现错误:(此设置无法在此工作区中应用。打开包含的工作区文件夹时将应用它直接地。)
这是一些代码的简单示例,它在 typescript 3.7.5 中被正确标记为错误,但在 VSC 的内部检查中没有(尽管它声称使用的是 3.7.5):
function errorTS7053(angleList: Array<number>)
{
var member = angleList[0];
var nonsense = member[0];
}
所以我的问题:
有可能实现我想要的吗?
实现这一目标的可能方法是什么?
或者内部 tsc 是否有可能只是错误/其他配置?
解决方案
推荐阅读
- javascript - 在greasemonkey/tampermonkey 中缺少coinbase 的要求?
- php - 如果数组的值存在于先前的键中,则删除数组的键
- amazon-web-services - ECS 服务发现 - 如何实现 Ribbon 或等效功能
- php - SQL/PHP 如何编写返回所有内容的 WHERE
- fish - 如何使用两个参数将制表符完成添加到命令(并且制表符完成两者)?
- php - API 调用限制为 500 个结果 - 如何迭代以获得所有结果?
- android - 为什么通知不适用于所有设备?
- html - 为什么我的文本与 display flex 堆叠在一起?
- python-3.x - 如果文件不存在,则改为创建数据框
- google-cloud-storage - 使用谷歌云 API 上传文件,并在服务器根目录放置 PUT?