Skip to content

Commit

Permalink
Issue #30: Reworking TypeScript types in JSDoc. Making Svelte compone…
Browse files Browse the repository at this point in the history
…nt a "newable" constructor type and also fixing the optional types by defining their defaults, so the generated .d.ts properly suffixes the "?" at the end of each optional field.
  • Loading branch information
patricknelson committed Dec 6, 2023
1 parent d8ec11f commit ef0b33a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,29 @@ function renderElements(timestamp) {
}


/**
* @typedef {new(...args: any[]) => any} Newable Type alias for a really generic class constructor
* @typedef {Newable} SvelteComponent Svelte component class constructor (basically a "newable" object)
*/

/**
* Please see README.md for usage information.
*
* @param {object} opts Custom element options
*
* @param {any} opts.component Svelte component instance to incorporate into your custom element.
* @param {string} opts.tagname Name of the custom element tag you'd like to define.
* @param {string[]?} opts.attributes Optional array of attributes that should be reactively forwarded to the component when modified.
* @param {boolean?} opts.shadow Indicates if we should build the component in the shadow root instead of in the regular ("light") DOM.
* @param {string?} opts.href URL to the CSS stylesheet to incorporate into the shadow DOM (if enabled).
* @param {SvelteComponent} opts.component The Svelte component *class* constructor to incorporate into your custom element (this is the imported component class, *not* an instance)
* @param {string} opts.tagname Name of the custom element tag you'd like to define.
* @param {string[]} [opts.attributes=[]] Optional array of attributes that should be reactively forwarded to the component when modified.
* @param {boolean} [opts.shadow=false] Indicates if we should build the component in the shadow root instead of in the regular ("light") DOM.
* @param {string} [opts.href=""] URL to the CSS stylesheet to incorporate into the shadow DOM (if enabled).
*
* Experimental:
* @param {boolean?} opts.hydratable Light DOM slot hydration (specific to svelte-retag): Enables pre-rendering of the
* @param {boolean} [opts.hydratable=false] Light DOM slot hydration (specific to svelte-retag): Enables pre-rendering of the
* web component (e.g. SSR) by adding extra markers (attributes & wrappers) during
* rendering to enable svelte-retag to find and restore light DOM slots when
* restoring interactivity.
*
* @param {boolean|string?} opts.debugMode Hidden option to enable debugging for package development purposes.
* @param {boolean|string} [opts.debugMode=false] Hidden option to enable debugging for package development purposes.
*/
export default function svelteRetag(opts) {
/**
Expand Down

0 comments on commit ef0b33a

Please sign in to comment.