primevue
primevue copied to clipboard
v4.0.0-beta3: ../primevue/themes/index.d.ts' is not a module when writing and building the app.
Describe the bug
When using definePreset we get this warning in vscode:
File '/ProjectPath.././node_modules/primevue/themes/index.d.ts' is not a module.ts(2306). If we ignore the warning this works in development environment. If we're trying to build the app we get this error:
src/main.ts(8,30): error TS2306: File '/opt/buildhome/repo/node_modules/primevue/themes/index.d.ts' is not a module.
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import PrimeVue from 'primevue/config'
import Aura from 'primevue/themes/aura'
import { definePreset } from 'primevue/themes' //here is the issue
import Ripple from 'primevue/ripple'
import StyleClass from 'primevue/styleclass'
const app = createApp(App)
const CustomPreset = definePreset(Aura, {
semantic: {
primary: {
50: '{rose.50}'
}
}
})
app.use(router)
app.use(PrimeVue, {
ripple: true,
theme: {
preset: CustomPreset,
options: {
prefix: 'p',
darkModeSelector: 'system',
cssLayer: false
}
}
})
app.directive('ripple', Ripple).directive('styleclass', StyleClass)
app.mount('#app')
I didn't find any workaround yet. I can't create a reproducer right now, I will try to add it later. StackBlitz cannot process my request at the moment.
Reproducer
https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-asdii5?file=src%2Fmain.ts (Made by @sceee. Thank you!)
PrimeVue version
4.0.0-beta3
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
I didn't find any workaround yet. I can't create a reproducer right now, I will try to add it later. StackBlitz cannot process my request at the moment.
Thanks a lot! A stackblitz link really helps us a lot.
Hi @mertsincan @44m0n I think this is just the same issue as #5521 and #5615 . They have been added to the (now closed) 4.0.0-beta.3 milestone but are not closed and fixed in 4.0.0-beta.3. Any they have stackblitz repros.
Edit:
Here is a modified Stackblitz repro using 4.0.0-beta.3:
https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-asdii5?file=src%2Fmain.ts
If you hover line 3 (import { definePreset } from 'primevue/themes';), you can see the error.
Sorry for the confusion! I set a new milestone for them. I'll check and get back to you.
For now, could you please try import { definePreset } from 'primevue/themes/actions'; instead of import { definePreset } from 'primevue/themes';. I'll fix this issue in RC1.
Thanks @mertsincan , for now I just ignored this error using
// @ts-expect-error Remove once types are fixed
import { definePreset } from 'primevue/themes'
but that's obviously not a good "solution" you want to have in your code 😃
For now, could you please try
import { definePreset } from 'primevue/themes/actions';instead ofimport { definePreset } from 'primevue/themes';. I'll fix this issue in RC1.
FYI - i have the same problem in beta4, your suggestion: import { definePreset } from 'primevue/themes/actions' fixes the error for me. Thanks!
Fixed for 4.0.0-rc.1. https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-ijv4ds?file=src%2Fmain.ts
Also please use '@primevue/themes' and '@primevue/themes/aura'
Best Regards,