Problem using typescript

UI Components for Vue
Post Reply
icg
Posts: 5
Joined: 27 Jul 2021, 10:04

27 Jul 2021, 16:36

Hi,

i bought the ultima template and have problems with typscript.

Following error appears:

TypeError: this.$primevue is undefined

I read that it happens if you dont include this import:

`import PrimeVue from "primevue/config";`

But I did.

What could be the Problem?

thanks

tugce.kucukoglu
Posts: 560
Joined: 23 Oct 2020, 09:28

28 Jul 2021, 08:33

Hi,

You need to add

Code: Select all

import PrimeVue from "primevue/config";


because it's a necessity for the core configuration.

Thanks,

icg
Posts: 5
Joined: 27 Jul 2021, 10:04

28 Jul 2021, 20:47

I read that it happens if you dont include this import:

`import PrimeVue from "primevue/config";`

But I did.
i did that, as i pointed out.

icg
Posts: 5
Joined: 27 Jul 2021, 10:04

29 Jul 2021, 13:16

I also should mention that I use vue-class-component to build my components.

example:

Code: Select all

<template>
  ...
</template>

<script lang="ts">
import { Vue, Prop } from "vue-property-decorator";

export default class AppFooter extends Vue {
  @Prop({ default: "light" })
  layoutMode!: string;

  get isRTL(): boolean {
    //return this.$appState.RTL;
    return false;
  }
}
</script>

<style scoped></style>
same error for $appState and $primevue

icg
Posts: 5
Joined: 27 Jul 2021, 10:04

29 Jul 2021, 23:43

I found a solution for this.

anyone having the same problem could add:

Code: Select all

declare module "@vue/runtime-core" {
    interface ComponentCustomProperties {
      $primevue: ReturnType<typeof usePrimeVue>,
    }
};
Better would be if the primevue team add this to primevue/config/PrimeVue.d.ts:

Code: Select all

declare module "@vue/runtime-core" {
    interface ComponentCustomProperties {
      $primevue: { config: PrimeVueConfiguration },
    }
};

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests