Victor
Victor

Reputation: 173

How do I enable JavaScript type checking in Vue files on Visual Studio Code?

I have found the settings in Visual Studio Code to enable type checking for JavaScript in JS files. Such that: Bad code is highlighted and it also shows the reason why it's bad code

This behavior does not occur for JavaScript code in Vue files. I have searched through all the settings in Visual Studio Code. I have scoured the internet for any extension that can do this for me to no avail.

How can I make my Vue files type-check the JavaScript in them?

Upvotes: 2

Views: 1609

Answers (2)

Victor
Victor

Reputation: 173

LOL. I found the answer. All I had to do was add //@ts-check directly underneath the script tag and type checking was enabled. So HAPPY!!! Thank you, everyone, for your input

Upvotes: 1

Noah Stahl
Noah Stahl

Reputation: 7553

For best results I'd suggest starting a new project using vue-cli and selecting the options for TypeScript and ESLint. You'll also need the ESLint extension for VS Code.

Here's a helpful blog post showing the parts of this process.

Once you have a nicely working setup with the clean project, then move the code over. I suggest this because getting all the config right can be a mess with an existing project.

Upvotes: 0

Related Questions