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

TypeScript: Improve definitions on all components #2734

Closed
mertsincan opened this issue Apr 10, 2022 · 7 comments
Closed

TypeScript: Improve definitions on all components #2734

mertsincan opened this issue Apr 10, 2022 · 7 comments
Assignees
Labels
Type: Breaking Change Issue contains a breaking change related to a specific component Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@mertsincan
Copy link
Member

Ref; https://github.com/primefaces/primevue/blob/master/src/components/accordion/Accordion.d.ts

Notes:

A general study can be made on this subject and help users read the codes better.

@mertsincan mertsincan added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Type: Breaking Change Issue contains a breaking change related to a specific component labels Apr 10, 2022
@mertsincan mertsincan self-assigned this Apr 10, 2022
@mertsincan mertsincan added this to the 9.0.0 milestone Apr 10, 2022
@Named-export
Copy link

How are the typescript definitions generated? By hand?

@melloware
Copy link
Member

How are the typescript definitions generated? By hand?

Yes currently by hand when we make changes in the components we update the TS definition.

@kalinkrustev
Copy link
Contributor

mertsincan added this to the 9.0.0 milestone 5 days ago

Does this mean version 9 will be based on TypeScript? Sounds cool !!!

@melloware
Copy link
Member

I am not sure is going to be written in TypeScript just that the definitions get an overhaul and documented similar to how PrimeVue is doing it.

@melloware melloware added the Typescript Issue or pull request is *only* related to TypeScript definition label Apr 21, 2022
@melloware melloware changed the title Improve TS definitions on all components TypeScript: Improve definitions on all components Apr 22, 2022
@gordolio
Copy link

Honestly, most of the issues that I experience with primereact are related to the type definitions being missing or incorrect. This happens most often with events. I often need to place a breakpoint in an event just to see what arguments are passed in.

IMHO, the lasting fix for this would be to have a typescript-first approach. Change the extensions of all the js source files to be ts, add the noImplicitAny: true option, and let the typescript compiler show what needs to be fixed.

Then future improvements will have a much reduced chance of regression in missing/incorrect type definitions.

@gordolio
Copy link

Additional improvements could be made by makingoptions on various components into generics.. options: T[], then definitions like this could be used: optionLabel?: keyof T, optionValue?: keyof T, etc.

@melloware
Copy link
Member

@gordolio its easier said than done if you look at this attempt at a PR which worked but we had to roll it back because it was too burdensome: https://github.com/primefaces/primereact/pull/3199/files

@melloware melloware modified the milestones: 9.0.0, 8.7.4 Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Breaking Change Issue contains a breaking change related to a specific component Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

No branches or pull requests

5 participants