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

preset not support for typescript #6

Open
raibann opened this issue Dec 26, 2023 · 2 comments
Open

preset not support for typescript #6

raibann opened this issue Dec 26, 2023 · 2 comments

Comments

@raibann
Copy link

raibann commented Dec 26, 2023

When I use typescript vue 3 is not work for presset.

@reinaldofox
Copy link

How about if PrimeVue/Tailwind starts supporting Typescript?

@ben-laird
Copy link

ben-laird commented Feb 22, 2024

Bumping this. Downloading a preset directory can be nice to customize styles of components, but it's unclear why it's necessary, especially considering all the files are raw JavaScript and not Vue files. On top of that, these component files do not come with type definitions, making actual customization difficult. Adding scoped .d.ts files to the preset directory or changing the .js files to .ts files with types would be highly beneficial.

EDIT - Workaround: I monkey patched a TS declaration file you can place inside your preset directory.

// @/presets/index.d.ts (probably @/presets/lara/index.d.ts if you follow the docs to the letter)

import type { PrimeVuePTOptions } from "primevue/config";
import type { PassThrough } from "primevue/ts-helpers";

declare module "index.js" {
  export = PassThrough<PrimeVuePTOptions>;
}

Theoretically you can also do this to every .js file you have in your preset directory. Another solution could be changing the extension to .ts and using their provided types. They do exist, you just have to dig a bit.

import { CheckboxPassThroughOptions } from "primevue/checkbox";
import { PassThrough } from "primevue/ts-helpers";

export default {
   // ...
} satisfies PassThrough<CheckboxPassThroughOptions>;

Might make a PR when I have time with a starter project that employs this strategy. PrimeVue is a really good package, and these starter repos illustrate their vision in the package well, passing around the types just needs a bit of work is all. Hopefully this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants