Skip to content

Conversation

sh1AD1ded
Copy link

fix TS errors

fix TS errors
@sh1AD1ded
Copy link
Author

Ty for writing this module. Could you please accept @hracik changes for multiple classes on button and these TS error fixes and then release an updated version? Unfortunately, at the moment the latest version 0.3.1 has no 'class' on supportedAttributes.

Copy link
Owner

@jcsmorais jcsmorais 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 small nitpick, other than that I don't see why the other changes are needed as I'm not getting any typescript errors; @sh1AD1ded mind elaborating on why/if those are actually needed?

Thanks for your contribution 👍

}

const index = parseInt(target.dataset.index, 10);
const index = parseInt(target.dataset.index as string, 10);
Copy link
Author

Choose a reason for hiding this comment

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

@jcsmorais index could be undefined, that's why I get TS error -->
grafik

* Set given button's attributes.
*/
function setButtonsAttributes(button: HTMLButtonElement, attributes?: ShortcutButtonsFlatpickr.Attributes) {
function setButtonsAttributes(button: HTMLButtonElement, attributes: ShortcutButtonsFlatpickr.Attributes) {
Copy link
Author

Choose a reason for hiding this comment

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

@jcsmorais your are checking for undefined before calling this function, no need for attributes to be optional
grafik

onReady: () => {
wrapper = document.createElement('div');
wrapper.classList.add('shortcut-buttons-flatpickr-wrapper', cfg.theme);
wrapper.classList.add('shortcut-buttons-flatpickr-wrapper', cfg.theme as string);
Copy link
Author

Choose a reason for hiding this comment

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

@jcsmorais theme is defined as string | undefined (gives TS error) but you're always setting a default theme, therefore it's never undefined at this point, simpliest way is to use "as string"

* Clean up before flatpickr is destroyed.
*/
onDestroy: () => {
if (typeof wrapper === 'undefined') return;
Copy link
Author

Choose a reason for hiding this comment

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

@jcsmorais changed this alike your suggestion

* Element that wraps this plugin's dependent elements.
*/
let wrapper: HTMLElement;
let wrapper: HTMLElement | undefined;
Copy link
Author

Choose a reason for hiding this comment

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

@jcsmorais can be undefined bc its set to undefined onDestroy(), I get TS errors if it's not defined that way

@thekikao
Copy link

+1 because

at the moment the latest version 0.3.1 has no 'class' on supportedAttributes.

@sh1AD1ded
Copy link
Author

@jcsmorais should I check in something?

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

Successfully merging this pull request may close these issues.

3 participants