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

refactor: migrate helpers.options to typescript #10753

Merged
merged 2 commits into from
Nov 4, 2022

Conversation

luckened
Copy link
Contributor

@luckened luckened commented Oct 5, 2022

Refactor src/helpers/helpers.options.js to typescript and apply required changes

@@ -120,7 +126,7 @@ export function toFont(options, fallback) {
let style = valueOrDefault(options.style, fallback.style);
if (style && !('' + style).match(FONT_STYLE)) {
console.warn('Invalid font style specified: "' + style + '"');
style = '';
style = 'inherit';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this one

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to restore it, or try undefined

Suggested change
style = 'inherit';
style = undefined;

maybe this will fix tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty string wont work, tried undefined but ubuntu test is still broken

@luckened
Copy link
Contributor Author

luckened commented Oct 5, 2022

@etimberg another one

@LeeLenaleee LeeLenaleee added the type: types Typescript type changes label Oct 6, 2022
@LeeLenaleee LeeLenaleee added this to the Version 4.0 milestone Oct 6, 2022
@luckened luckened force-pushed the tsmigration branch 3 times, most recently from cbe29c6 to a8f5642 Compare October 15, 2022 21:56
@luckened luckened force-pushed the tsmigration branch 3 times, most recently from 46ea8ec to 568749c Compare October 18, 2022 19:03
Comment on lines 99 to 107
const obj: ChartArea = {
...toTRBL(value),
width: 0,
height: 0,
top: 0,
left: 0,
right: 0,
bottom: 0
};
Copy link
Collaborator

@dangreen dangreen Oct 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem is here

Suggested change
const obj: ChartArea = {
...toTRBL(value),
width: 0,
height: 0,
top: 0,
left: 0,
right: 0,
bottom: 0
};
const obj: ChartArea = {
...toTRBL(value),
width: 0,
height: 0
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! 🎉

etimberg
etimberg previously approved these changes Oct 19, 2022
dangreen
dangreen previously approved these changes Oct 19, 2022
Comment on lines 7 to 8
const LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
const FONT_STYLE = new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
const LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
const FONT_STYLE = new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);
const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etimberg
etimberg previously approved these changes Oct 20, 2022
dangreen
dangreen previously approved these changes Oct 31, 2022
kurkle
kurkle previously approved these changes Oct 31, 2022
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of nits

LeeLenaleee
LeeLenaleee previously approved these changes Oct 31, 2022
@etimberg
Copy link
Member

@luckened for the nits do you want to address them in this PR or a followup?

}

return size * value;
}

const numberOrZero = v => +v || 0;
const numberOrZero = (v: number) => +v || 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const numberOrZero = (v: number) => +v || 0;
const numberOrZero = (v: unknown) => +v || 0;

export function toPadding(value) {
const obj = toTRBL(value);
export function toPadding(value?: number | TRBL): ChartArea {
const obj: ChartArea = {...toTRBL(value), width: 0, height: 0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const obj: ChartArea = {...toTRBL(value), width: 0, height: 0};
const obj = toTRBL(value) as ChartArea;

@luckened luckened dismissed stale reviews from LeeLenaleee, kurkle, dangreen, and etimberg via a5e1d42 November 3, 2022 16:31
@luckened
Copy link
Contributor Author

luckened commented Nov 3, 2022

@etimberg commited the nits, better to do them right away

@etimberg etimberg merged commit 24745fa into chartjs:master Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: types Typescript type changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants