简体   繁体   English

用于 VSCode 的自定义 typeScript 片段

[英]Custom typeScript snippets for VSCode

It is possible to create custom user snippets in vs code.可以在 vs 代码中创建自定义用户片段。 But is it possible to create them in detail for ts functions like:但是是否可以为 ts 函数详细创建它们,例如:

someArray.forEach((val: getTypeFromArrayOnTheFly){

}

I did manage to create a basic snippet, but have no clue how to display it after writing an arrayName with dot.我确实设法创建了一个基本片段,但不知道如何在用点编写 arrayName 后显示它。 And also how to get the type from the array i want to use the snippet on.以及如何从我想使用代码片段的数组中获取类型。

Typescript Language Basics already defines the snippet foreach => which expands to Typescript Language Basics 已经定义了代码片段foreach =>扩展为

array.forEach(element => {
  
});

Since the type of array should be known, you don't need to define the type of element .由于应该知道array的类型,因此您无需定义element的类型。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM