Reputation: 51
Using typescript 2.8.3, ts-loader 3.5.0 (due to usage of webpack 2) and vue 2.5.16 I'm getting an error when trying to define components in a SFC like the following:
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'TestComponent',
props: {
options: {
type: Array,
default: () => [],
}
},
computed: {
getOptions() {
return this.options
},
}
})
</script>
Here's the error:
TS2339: Property 'options' does not exist on type 'ComponentOptions, DefaultMethods, DefaultComputed, PropsDefinition
Here's the tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noImplicitAny": false,
"baseUrl": ".",
"allowJs": true,
"paths": {
"test/*": ["test/*"]
},
"lib": ["dom", "es2016"],
"types": ["node", "jest"]
},
"include": ["resources/assets/js/**/*.ts", "resources/assets/js/**/*.vue"],
"exclude": ["node_modules"]
}
Any ideas? Works ok if I set "noImplicityThis": false but autocomplete on VSCode is not correct.
Upvotes: 2
Views: 533
Reputation: 51
Somehow started working. Changed tsconfig.json to the following:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": false,
"jsx": "preserve",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"allowJs": true,
"lib": ["dom", "esnext"],
"types": ["node", "jest"]
},
"include": ["resources/assets/js/**/*.ts", "resources/assets/js/**/*.vue"],
"exclude": ["node_modules"]
}
And vue.d.ts to:
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
Maybe it's useful for someone.
Upvotes: 1