-
-
Notifications
You must be signed in to change notification settings - Fork 261
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(types): rewrite component TypeScript definitions #385
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/carbon-svelte/carbon-components-svelte/iu056uky3 |
Wow, nice job! 👏 Just asking… Will union types also be rewritten to TS syntax? (As do the Before: /**
* Specify alignment of accordion item chevron icon
* @type {"start" | "end"}
*/
export let align = "end"; After: /** Specify alignment of accordion item chevron icon */
export let align: "start" | "end" = "end"; |
@albertms10 That's good thinking but unfortunately that would make the uncompiled Svelte components TS only. |
src/Button/Button.svelte
Outdated
export let hasIconOnly = false; | ||
|
||
/** | ||
* Specify the icon from `carbon-icons-svelte` to render | ||
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [icon] | ||
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of typing the generic icon prop with the Add16
icon default
type, wouldn’t it be cleaner to use the typeof CarbonIcon
class?—it applies to the rest of icon imports.
/**
* Specify the icon from `carbon-icons-svelte` to render
* @type {typeof import("carbon-icons-svelte").CarbonIcon}
*/
export let icon = undefined;
Although in this way you can’t restrict the icon size to e.g. 16
… 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion. The icon size should not matter.
Replaces PUBLIC_API.json with COMPONENT_API.json generated by sveld.
This PR rewrites the TypeScript definitions from scratch.
Purpose
$$restProps
is spread to a native HTML Element (Fix IntrinsicAttributes error in TypeScript definitions #304 )Refactor
typeof import("carbon-icons-svelte/lib/Add16").default
toimport("carbon-icons-svelte").CarbonIcon
id
,ref
props where applicableDocs
$$restProps
Todo
any
)some interfaces should be exported for the consumer (i.e. DataTable(defer)headers
in DataTable: typings for headers and rows #364 )svelte-check
to validate TS definitions in the CIErrors
svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["div"]>
; an intersection will cause errors$$restProps
(or if it's ambiguous likeTag
) should conservatively allow any attributes