Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue-tsc with vue-property-decorator results in TS2749 error #189

Closed
ChristianBirkl opened this issue May 18, 2021 · 1 comment
Closed

vue-tsc with vue-property-decorator results in TS2749 error #189

ChristianBirkl opened this issue May 18, 2021 · 1 comment
Labels
question Further information is requested

Comments

@ChristianBirkl
Copy link

I'm using vue-property-decorator for my .vue files:

components/HelloWorld.vue

<script lang="ts">
import { Vue, Options } from "vue-property-decorator";
@Options({})
export default class HelloWorld extends Vue {
  count = 0;
}
</script>

App.vue

<script lang="ts">
import { Vue, Options, Ref } from "vue-property-decorator";
import HelloWorld from "./components/HelloWorld.vue";
@Options({
  components: {
    HelloWorld
  }
})
export default class App extends Vue {
  @Ref()
  test!: HelloWorld;
  mounted() {
    console.log(this.test.count);
  }
}
</script>

vue-tsc

src/App.vue:20:10 - error TS2749: 'HelloWorld' refers to a value, but is being used as a type here. Did you mean 'typeof HelloWorld'?

Although VS Code (if volar is not active) successfully auto completed this.test.count. If I change it to typeof HelloWorld i get:

src/App.vue:20:27 - error TS2339: Property 'count' does not exist on type 'typeof HelloWorld & { __VLS_raw: typeof HelloWorld; __VLS_options: {}; __VLS_slots: {}; }'.

Any chance to get this kind of type safety somehow working?

package.json

  "dependencies": {
    "vue": "^3.0.5",
    "vue-class-component": "^8.0.0-0",
    "vue-property-decorator": "^10.0.0-rc.3"
  }
@johnsoncodehk
Copy link
Member

johnsoncodehk commented May 18, 2021

This is design limitation, you need to use typeof HelloWorld['__VLS_raw'] for now, see #94.

@johnsoncodehk johnsoncodehk added the question Further information is requested label May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants