谁来救救孩子:ts + vue, 定义Vue.prototype.$someFn后,按照官网扩展 vue/types/vue 定义不生效

// shims-vue.d.ts
declare module ‘vue/types/vue’ {
interface Vue {
// …
// 以下是在main.ts中挂载到Vue.prototype上的变量
$someFn: () => void;
}
}

// main.ts
import Vue from ‘vue’
import App from ‘./App.vue’
import ‘./registerServiceWorker’
import router from ‘./router’
import store from ‘./store’

Vue.config.productionTip = false

Vue.prototype.$someFn = function() {
alert(1);
};

new Vue({
router,
store,
render: h => h(App)
}).$mount(’#app’)

// About.vue 组件

This is an about page

如上已经定义了 vue/types/vue 下 Vue 扩展 $someFn,但在组件里面仍然无法使用 this.$someFn
Property ‘$someFn’ does not exist on type ‘About’.