启用 Visual Studio Code 以从 Typescript 类生成构造函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41408197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:08:04  来源:igfitidea点击:

Enable Visual Studio Code to generate constructor from Typescript class

typescriptvisual-studio-code

提问by Emdee

I use Visual Studio Code to develop Angular 2 apps in Typescript. Is there any means to save the effort of writing constructors with its parameter list myself?

我使用 Visual Studio Code 在 Typescript 中开发 Angular 2 应用程序。有没有什么办法可以节省自己编写带有参数列表的构造函数的工作量?

Would be great if the IDE could generate the constructor based on the class members like e.g. Eclipse can do it for Java.

如果 IDE 可以生成基于类成员的构造函数,例如 Eclipse 可以为 Java 做到这一点,那就太好了。

回答by Charlie Rabiller

Just install TypeScript Toolbox :

只需安装 TypeScript 工具箱:

https://marketplace.visualstudio.com/items?itemName=DSKWRK.vscode-generate-getter-setter

https://marketplace.visualstudio.com/items?itemName=DSKWRK.vscode-generate-getter-setter

You can generate Constructor, Getter and setters ....

您可以生成 Constructor、Getter 和 setter ....