My vuejs application is being built using vue-cli-service.
After a successful build, I encountered TS2339 errors in my webstorm IDE:
Test.vue:
<template>
<div>{{method()}}</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class Test extends Vue {
public method(): string {
return 'hello';
}
}
</script>
Test.spec.ts:
import 'jest';
import {mount} from '@vue/test-utils';
import Test from '@/views/common/Test.vue';
describe('Test.vue', () => {
let wrapper: any;
beforeEach(() => {
wrapper = mount(Test);
});
test('test method call', () => {
const test = wrapper.find(Test).vm as Test;
expect(test.method()).toEqual('hello');
});
});
The error message in Test.spec.ts reads as follows, appearing in both the editor and typescript window:
Error:(14, 21) TS2339: Property 'method' does not exist on type 'Vue'.
Despite the error message, the test runs successfully at runtime when calling test.method()
.