简体   繁体   English

是否有 VSCode 扩展添加快速修复以将显式类型添加到 Typescript 的字段?

[英]Is there a VSCode extension that adds a Quick Fix for adding the explicit type to a field for Typescript?

I want to have a Quick Fix action ( cmd +. ) that adds the explicit type to a field, parameter, or function return (where it is otherwise inferred).我想要一个快速修复操作( cmd +. ),它将显式类型添加到字段、参数或 function 返回(否则会推断)。

To turn

const specificQuesiton = await Question.query().findById(1)

into进入

const specificQuesiton: Question = await Question.query().findById(1)

Found one!找到一个!

https://marketplace.visualstudio.com/items?itemName=nick-lvov-dev.typescript-explicit-types https://marketplace.visualstudio.com/items?itemName=nick-lvov-dev.typescript-explicit-types

Here's an example of it in action:这是它的一个例子: 在此处输入图像描述

I also found this one which just does return type (the one above does everything).我还发现这个只是返回类型(上面的那个什么都做)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VSCode/TypeScript 中是否有“使用显式类型重构”? - Is there a “use explicit type refactoring” in VSCode/TypeScript? 如何更改VSCode快速修复生成的TypeScript导入以使用相对路径? - How to change VSCode quick fix generated imports for TypeScript to use relative paths? VSCode 中的 typescript 扩展 - typescript extension in VSCode VSCode 如何修复 typescript 突出显示错误 {} 类型的参数不可分配给 - VSCode how to fix typescript highlight error Argument of type {} is not assignable to parameter of 修复TypeScript文件的快速查找 - Fix Quick Look for TypeScript files VSCode prettier 为 TypeScript React 中的导入添加了“价值” - VSCode prettier adds `value` to imports in TypeScript React Typescript 导出推断类型而不是显式类型 - Typescript export inferred type instead of explicit type VSCode 和 Typescript:“没有找到……的类型定义” - VSCode and Typescript: “No type definitions found for …” 如何修复 VSCode 中的“Property XX does not exist on type 'CombinedVueInstance”错误? (Vue 与打字稿) - How to fix "Property XX does not exist on type 'CombinedVueInstance" errors in VSCode? (Vue with Typescript) VSCode TypeScript intellisense 不是类型缩小 - VSCode TypeScript intellisense is not type narrowing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM