typescript: Trailing comma error with prop typing
I’m using Typescript with Vue. I want to add typing for my props but lint giving me an error with trailing comma. In this case:
21:6 error Parsing error: Unexpected token, expected ","
9 | type: Object,
10 | required: true
> 11 | } as PropOptions<MenuItem[]>,
| ^
12 | },
13 | data: () => ({}),
14 | })
Code:
<script lang="ts">
import Vue, { PropOptions } from 'vue'
import { MenuItem } from '~/types/data'
export default Vue.extend({
name: 'UiSubmenu',
props: {
submenuProp: {
type: Object,
required: true,
} as PropOptions<MenuItem[]>,
},
data: () => ({}),
})
</script>
I’ve tried to disabled the comma-dangle rule but no results.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (9 by maintainers)
@kevinmarrec @rcheung9 I’ve made a workaround, it was also recommended in few places:
Got the same type of issue with the data object so the solution could look like that:
and
Navigationis a component interface. It works fine for me.Also, I’ve moved to TSLint parser.