Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: [js] This constructor function may be converted to a class declaration

I have updated to Visual Studio Code version 1.23.0 recently and I am starting to see this code hint:

[js] This constructor function may be converted to a class declaration.
var _myFunctionName: () => void

How can I turn this hint off? I have not found the right setting so far.

like image 540
Arnaud Leyder Avatar asked May 09 '18 16:05

Arnaud Leyder


People also ask

How do you generate a constructor code in Visual Studio?

Generate constructor with properties (C# only) Place your cursor on the instance. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Generate constructor in <QualifiedName> (with properties).

How do you define a constructor in JavaScript?

A constructor is a special function that creates and initializes an object instance of a class. In JavaScript, a constructor gets called when an object is created using the new keyword. The purpose of a constructor is to create a new object and set values for any existing object properties.

How do we invoke a constructor function?

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.

Do JavaScript classes need constructors?

You can define a class without a constructor in JavaScript. If you do not specify a constructor method a default constructor is used. By default, the constructor is defined as: The body of a class is the part that is in curly brackets {} .


1 Answers

From the March 2018 release notes: suggested code actions

Suggestion Code Actions are enabled by default in JavaScript and TypeScript. You can disable them by setting: "typescript.suggestionActions.enabled": false or "javascript.suggestionActions.enabled": false

like image 130
Mark Avatar answered Nov 14 '22 22:11

Mark