I have a Vue component which makes use of vue-boostrap Modal component, with a definition that looks something like this:
<template>
<div>
<b-modal ref="NewProjectDialog" id="NewProjectDialog" centered>
</b-modal>
</div>
</template>
<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'
import {BModal} from 'bootstrap-vue'
@Component()
export default class Projects extends Vue {
save_project() {
(this.$refs['NewProjectDialog'] as BModal).hide()
}
}
The above code works correctly, however there appears to be a mistake in the way I have cast $ref['NewProjectDialog']
, because it appears that the compiler picks up the preceding line as part of the expression, e.g. the following code generates a "Cannot invoke an expression whose type lacks a call signature."
error:
save_project() {
console.log('any code line without a semicolon fails')
(this.$refs['NewProjectDialog'] as BModal).hide()
}
but the following code compiles fine:
save_project() {
console.log('any code line without a semicolon fails');
(this.$refs['NewProjectDialog'] as BModal).hide()
}
Can anyone explain why I need the line separator for the code to work correctly?