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

Update index.ts #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update index.ts #35

wants to merge 2 commits into from

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 👍

src/index.ts Outdated Show resolved Hide resolved
@@ -88,7 +88,7 @@ export function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {
return;
}

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

@@ -119,7 +119,7 @@ export function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {
/**
* 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

@@ -136,7 +136,7 @@ export function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {
*/
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"

@@ -176,6 +176,7 @@ export function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {
* 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

@@ -74,7 +74,7 @@ export function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {
/**
* 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.

None yet

3 participants