CleverCloud / clever-components

Collection of Web Components by Clever Cloud
https://www.clever-cloud.com/doc/clever-components/
Apache License 2.0
221 stars 20 forks source link

cem(typedef): support `event target` and `union` in `@typedef` imports #1149

Open Galimede opened 2 months ago

Galimede commented 2 months ago

We'd like to allow users to use short union the @typedef imports like this:

/**
 * @typedef {import('../cc-input-date/cc-input-date.js').CcInputDate} CcInputDate
 * [...]
 * @typedef {'none'|'init'|'started'|'waiting'|'running'|'paused'|'completed'} ProgressState
 */

We'd also like to support event target:

/**
 * @typedef {import('./cc-addon-backups.types.js').ProviderId} ProviderId
 * @typedef {import('../cc-button/cc-button.js').CcButton} CcButton
 * @typedef {Event & { target: CcButton }} CcButtonClickEvent
 */

Currently, the plugin warns the user as it only checks for imports and can't figure out what to do with these cases.

pdesoyres-cc commented 1 month ago

I don't say supporting types union/intersection is not a good idea, but for the Event with target, we have a type for that in src/lib/events.types.d.ts