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

SlChangeEvent with unknown type #1787

Open
adamPrzybyszExt opened this issue Feb 10, 2025 · 10 comments
Open

SlChangeEvent with unknown type #1787

adamPrzybyszExt opened this issue Feb 10, 2025 · 10 comments
Labels
bug Something isn't working development

Comments

@adamPrzybyszExt
Copy link

Provide a general summary of the issue here

sl-change /slChange event throws mismatch types error. I don't see any possibility to omit this (except using $any; maybe I miss something) but (slChange)="onChange($event.detail)" nor (slChange)="onChange($event)" won't help. In component's method we expect boolean, not unknown.

🤔 Expected Behavior?

No mismatch types error using any events: change, select etc.

😯 Current Behavior

Throws error on valid code.

💁 Possible Solution

  • Change event value type to any.
  • Make more precise event value e.g. boolean for checkbox.

🖥️ Steps to Reproduce

  1. Add sl-checkbox to template
  2. Bind sl-checkbox event with method in component.
  3. In method: expect CustomEvent<boolean> or boolean.

What browsers are you seeing the problem on? (only for bugs in code)

Chrome

If other, please specify.

No response

What operating system are you using?

Windows 10

👤 Your name

Adam Przybysz

🧢 Your product/team

ETSL

🎨 Your Theme(s)

Editorial Suite

@adamPrzybyszExt adamPrzybyszExt added bug Something isn't working development triage An issue needed triage labels Feb 10, 2025
@github-project-automation github-project-automation bot moved this to 📥 Incoming in SL Design System Team Feb 10, 2025
@DanielleRameau DanielleRameau moved this from 📥 Incoming to ⏳ Waiting for input in SL Design System Team Feb 11, 2025
@jpzwarte
Copy link
Member

@adamPrzybyszExt It's unclear exactly what typing error you're running into. Can you provide more code?

@adamPrzybyszExt
Copy link
Author

Image

Image

@adamPrzybyszExt
Copy link
Author

Image

@jpzwarte
Copy link
Member

What about just passing $event and doing onChange(event: SlChangeEvent<boolean>) ?

@jpzwarte
Copy link
Member

The "problem" here is that the SlChangeEvent is not checkbox specific. And even then, the value of a checkbox may be something other than a boolean.

@adamPrzybyszExt
Copy link
Author

The same situation. Btw SlChangeEvent is not exported in shared/index.d.ts

Image

Image

@jpzwarte
Copy link
Member

The same situation. Btw SlChangeEvent is not exported in shared/index.d.ts

It's exported from @sl-design-system/shared/events.js.

@jpzwarte
Copy link
Member

jpzwarte commented Feb 12, 2025

I think your most practical solution would then be to do $event as SlChangeEvent<boolean>?

I don't see how this can be fixed, since Checkbox has a generic type for the value.

@adamPrzybyszExt
Copy link
Author

adamPrzybyszExt commented Feb 12, 2025

In our situation the only workaround is using $any() in template but imagine how many of these will be needed in our app. Why don't just change unknown to any?

@jpzwarte
Copy link
Member

Yeah, perhaps that is better. I'll have a look at that option.

@DanielleRameau DanielleRameau moved this from ⏳ Waiting for input to 👩‍🏭 Refining in SL Design System Team Feb 13, 2025
@DanielleRameau DanielleRameau moved this from 👩‍🏭 Refining to 🗃️ Backlog in SL Design System Team Feb 13, 2025
@DanielleRameau DanielleRameau removed the triage An issue needed triage label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working development
Projects
Status: 🗃️ Backlog
Development

No branches or pull requests

3 participants