-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ui): improve types #11085
feat(ui): improve types #11085
Conversation
@IlCallo You wrote me on Discord (https://discord.com/channels/415874313728688138/807654245640962059/901927932237348886) What I would like is to create types that are more enhanced. So instead of this (JSDoc comments omitted): export interface QOptionGroupProps {
size?: string | undefined;
modelValue: any;
options?:
| {
label: string;
value: any;
disable?: boolean;
[index: string]: any;
}[]
| undefined;
name?: string | undefined;
type?: "radio" | "checkbox" | "toggle" | undefined;
color?: string | undefined;
keepColor?: boolean | undefined;
dark?: boolean | undefined;
dense?: boolean | undefined;
leftLabel?: boolean | undefined;
inline?: boolean | undefined;
disable?: boolean | undefined;
"onUpdate:modelValue"?: (value: any) => void;
} I would like to create types like this: export interface QOptionGroupProps<Value = any> {
size?: string | undefined;
modelValue: Value;
options?:
| {
label: string;
value: Value;
disable?: boolean;
[index: string]: any;
}[]
| undefined;
name?: string | undefined;
type?: "radio" | "checkbox" | "toggle" | undefined;
color?: string | undefined;
keepColor?: boolean | undefined;
dark?: boolean | undefined;
dense?: boolean | undefined;
leftLabel?: boolean | undefined;
inline?: boolean | undefined;
disable?: boolean | undefined;
"onUpdate:modelValue"?: (value: Value) => void;
} And this is just one example... So what do I have to do to define such types? |
Another example for export interface QTableProps<
Row extends Record<string, any> = any,
K = Row extends Record<string, any> ? keyof Row : string,
Field = K | ((row: Row) => any)
> {
// ...
rows?: Row[] | undefined;
rowKey?: string | ((row: Row) => string) | undefined;
// ...
columns?:
| {
// ...
field: Field;
// ...
align?: "left" | "right" | "center";
// ...
sort?: (a: any, b: any, rowA: Row, rowB: Row) => number;
// ...
format?: (val: any, row: Row) => string;
style?: string | ((row: Row) => string);
classes?: string | ((row: Row) => string);
// ...
}[]
| undefined;
// ...
// And many more can be enhanced here
} I also would prefer to extract the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃憦
Co-authored-by: Yusuf Kandemir <yusuf.kandemir@outlook.com.tr>
Co-authored-by: Yusuf Kandemir <yusuf.kandemir@outlook.com.tr>
I think this PR is ready to get merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, nicely done 馃憦
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch (orv[X]
branch)fix: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
While starting to build an electron-quasar app, I experienced some lazy defined types and I want to improve the auto-completion in VSCode for TypeScript users like me.
https://github.com/Shinigami92/watchlist/blob/main/src/quasar.d.ts
So @yusufkandemir suggested that I can update these types by changing the json schema files.
This may be just the start from my side to make some contributions to Quasar 馃檶
Please feel free to push me in the right direction if I do anything wrong 馃檪