primevue icon indicating copy to clipboard operation
primevue copied to clipboard

v4.0.0-beta3: ../primevue/themes/index.d.ts' is not a module when writing and building the app.

Open 44m0n opened this issue 1 year ago • 5 comments

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

44m0n avatar May 16 '24 13:05 44m0n

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.

mertsincan avatar May 16 '24 15:05 mertsincan

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.

sceee avatar May 17 '24 05:05 sceee

Sorry for the confusion! I set a new milestone for them. I'll check and get back to you.

mertsincan avatar May 17 '24 07:05 mertsincan

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.

mertsincan avatar May 17 '24 09:05 mertsincan

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 😃

sceee avatar May 17 '24 09:05 sceee

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.

FYI - i have the same problem in beta4, your suggestion: import { definePreset } from 'primevue/themes/actions' fixes the error for me. Thanks!

bobby-driggs avatar Jun 05 '24 16:06 bobby-driggs

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,

mertsincan avatar Jun 14 '24 08:06 mertsincan