MuriloKunze
MuriloKunze

Reputation: 15583

Why javascript accept types in VS code?

I would like to know why this javascript file works in visual studio code.

enter image description here

Upvotes: 2

Views: 605

Answers (2)

Johannes Rieken
Johannes Rieken

Reputation: 3611

Code uses the TypeScript brain to understand JavaScript code: https://code.visualstudio.com/Docs/languages#_javascript. It exposes a configuration setting which controls if TypeScript specifics should be ignore, a warning, or an error. In you user settings do this:

{
    "javascript.validate.lint.typeScriptSpecifics": "error"
}

Upvotes: 4

AJ Morris
AJ Morris

Reputation: 1109

That's TypeScript. That parameters are decorated with data types. But, your function accepts two parameters, and you're only passing one. The second parameter needs to be optional, like this:

function(a: string, b?:any) {
}

Upvotes: 1

Related Questions