也许这是显而易见的,但我到处检查(除了正确的地方),谷歌它。什么都没有。
当前回答
首先,确保在环境变量路径中有以下地址
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0
然后打开命令提示符,输入以下命令:
tsc -v
其他回答
如果你想知道在一个特定的项目中使用了什么版本的Typescript,去你的package-lock。json文件。你会发现这样的东西:
"typescript": {
"version": "3.5.3"
}
如果你只为Visual Studio安装了TypeScript,那么:
启动Visual Studio命令提示符 输入tsc -v并按Enter
Visual Studio 2017版本15.3及以上将TypeScript版本绑定到单个项目,正如这个答案所指出的:
右键单击解决方案资源管理器中的项目节点 单击“属性” 进入TypeScript Build选项卡
从Visual Studio 2022开始,Angular/React/Vue有了新的TypeScript/JavaScript项目类型,TypeScript SDK已弃用(但仍然可以通过VS安装程序安装,并带有警告),Visual Studio应该根据你的项目使用的TypeScript版本提供智能感知和语言支持(npm是通过包指定你正在使用的TypeScript版本的首选方式)。json文件)。
不过,根据这个答案,仍然有关于如何控制/辨别Visual Studio 2022在任何给定时刻支持哪种特定的TypeScript语言版本的问题。
对于非命令行方法,你可以打开扩展和更新窗口(工具->扩展和更新),并在安装下搜索Typescript For Microsoft Visual Studio扩展
As far as I understand VS has nothing to do with TS installed by NPM. (You may notice after you install TS using NPM, there is no tsc.exe file). VS targets only tsc.exe installed by TS for VS extension, which installes TS to c:\Program Files (x86)\Microsoft SDKs\TypeScript\X.Y. You may have multiple folders under c:\Program Files (x86)\Microsoft SDKs\TypeScript. Set TypeScriptToolsVersion to the highest version installed. In my case I had folders "1.0", "1.7", "1.8", so I set TypeScriptToolsVersion = 1.8, and if you run tsc - v inside that folder you will get 1.8.3 or something, however, when u run tsc outside that folder, it will use PATH variable pointing to TS version installed by NPM, which is in my case 1.8.10. I believe TS for VS will always be a little behind the latest version of TS you install using NPM. But as far as I understand, VS doesnt know anything about TS installed by NPM, it only targets whateve versions installed by TS for VS extensions, and the version specified in TypeScriptToolsVersion in your project file.
推荐文章
- React组件中使用TypeScript的默认属性值
- Angular 5 -复制到剪贴板
- TypeScript枚举对象数组
- csproj文件中的“Service Include”是干什么用的?
- 如何在Visual Studio中找到堆栈跟踪?
- 使用不同的Web。在开发和生产环境中进行配置
- Angular 2显示和隐藏一个元素
- 具有构造签名的接口如何工作?
- 是否有一种方法可以在Visual Studio中删除一行而不剪切它?
- Microsoft Visual Studio的推荐插件
- 'React'指的是一个UMD全局,但当前文件是一个模块
- Angular 2中的“component”不是一个已知的元素
- Visual Studio: ContextSwitchDeadlock
- Visual Studio:如何打破处理异常?
- TypeScript错误:属性“X”在类型“Window”上不存在