I have a vue2 app, and I want to start using TypeScript for some services files (without changing existing js/vue files).
In order to add TypeScript support I've used vue-cli, and it seems to work: I've added a myService.ts file with a TypeScript function - myFunction, and inside this file vue detects properly types issues. I can also import this service to a vue component file - myComponent.vue (a component that contains js code), and use it properly.
myFunction looks like this:
function myFunction (x: number, y: number) : number {
const a: number = 3
const b: number = 2
return a + b + x + y
}
However, when I call myFunction from myComponent.vue with wrong parameters, for example - myFunction("str1", "str2"), vue doesn't detect any issue, even though string parameters should not be allowed.
I can run - npm run serve, and it works without raising any warning/error.
How can I make vue to detect it? is it even possible to detect TS issues from inside js code?