Skip to content

Commit 6b3de71

Browse files
committed
Change JSDoc comments to use consistent TypeScript syntax
1 parent 81378c8 commit 6b3de71

File tree

17 files changed

+67
-70
lines changed

17 files changed

+67
-70
lines changed

jsx-runtime.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export { Fragment } from "./src/core.js";
66
* @param {any} type
77
* @param {any} props
88
* @param {any} [key]
9-
* @returns
109
*/
1110
export const jsx = (type, props, key) => {
1211
if (props == undefined) {

src/css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { options } from "./options.js";
44
/**
55
* It is used only if the browser supports adoptedStyleSheets.
66
* caches the CSSStyleSheet using the css as a reference to the instance
7-
* @type {{[id:string]:import("core").Sheet}}
7+
* @type {{ [id: string]: import("core").Sheet }}
88
*/
99
const SHEETS = {};
1010

1111
/**
1212
* Create a Style from a string
1313
* @param {TemplateStringsArray} template
14-
* @param {...any} args
14+
* @param {any[]} args
1515
*/
1616
export function css(template, ...args) {
1717
const cssText = (template.raw || template).reduce(

src/element/custom-element.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export { Any, createType } from "./set-prototype.js";
88
let ID = 0;
99

1010
/**
11-
* @param {Element & {dataset?:object}} node
12-
* @returns {string|number}
11+
* @param {Element & { dataset?: object }} node
12+
* @returns {string | number}
1313
*/
1414
const getHydrateId = (node) => {
1515
const id = (node?.dataset || {})?.hydrate || "";
@@ -24,11 +24,11 @@ const getHydrateId = (node) => {
2424
*/
2525
export const c = (component, base) => {
2626
/**
27-
* @type {import("./set-prototype").Attrs}
27+
* @type {import("./set-prototype.js").Attrs}
2828
*/
2929
const attrs = {};
3030
/**
31-
* @type {import("./set-prototype").Values}
31+
* @type {import("./set-prototype.js").Values}
3232
*/
3333
const values = {};
3434

@@ -194,8 +194,8 @@ export const c = (component, base) => {
194194
/**
195195
* @this {import("dom").AtomicoThisInternal}
196196
* @param {string} attr
197-
* @param {(string|null)} oldValue
198-
* @param {(string|null)} value
197+
* @param {string | null} oldValue
198+
* @param {string | null} value
199199
*/
200200
attributeChangedCallback(attr, oldValue, value) {
201201
if (attrs[attr]) {

src/element/set-prototype.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { isFunction, isObject } from "../utils.js";
22
import { PropError } from "./errors.js";
33

44
export const CUSTOM_TYPE_NAME = "Custom";
5+
56
/**
67
* The Any type avoids the validation of prop types
78
* @type {null}
@@ -16,11 +17,11 @@ const TRUE_VALUES = { true: 1, "": 1, 1: 1 };
1617
/**
1718
* Constructs the setter and getter of the associated property
1819
* only if it is not defined in the prototype
19-
* @param {Object} prototype - CustomElement prototype
20-
* @param {string} prop - Name of the reactive property to associate with the customElement
21-
* @param {any} schema - Structure to be evaluated for the definition of the property
22-
* @param {Attrs} attrs - Dictionary of attributes to properties
23-
* @param {Values} values - Values to initialize the customElements
20+
* @param {object} prototype CustomElement prototype
21+
* @param {string} prop Name of the reactive property to associate with the customElement
22+
* @param {any} schema Structure to be evaluated for the definition of the property
23+
* @param {Attrs} attrs Dictionary of attributes to properties
24+
* @param {Values} values Values to initialize the customElements
2425
*/
2526
export function setPrototype(prototype, prop, schema, attrs, values) {
2627
/** @type {Schema} */
@@ -103,8 +104,8 @@ export function setPrototype(prototype, prop, schema, attrs, values) {
103104

104105
/**
105106
* Dispatch an event
106-
* @param {Element} node - DOM node to dispatch the event
107-
* @param {InternalEvent & InternalEventInit} event - Event to dispatch on node
107+
* @param {Element} node DOM node to dispatch the event
108+
* @param {InternalEvent & InternalEventInit} event Event to dispatch on node
108109
*/
109110
export const dispatchEvent = (
110111
node,
@@ -113,7 +114,7 @@ export const dispatchEvent = (
113114

114115
/**
115116
* Transform a Camel Case string to a Kebab case
116-
* @param {string} prop - string to apply the format
117+
* @param {string} prop string to apply the format
117118
* @returns {string}
118119
*/
119120
export const getAttr = (prop) => prop.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -160,9 +161,8 @@ export const transformValue = (type, value) =>
160161
new type(value);
161162

162163
/**
163-
* @param {import("schema").TypeCustom<(...args:any)=>any>} TypeCustom
164-
* @param {*} value
165-
* @returns
164+
* @param {import("schema").TypeCustom<(...args: any[]) => any>} TypeCustom
165+
* @param {any} value
166166
*/
167167
export const mapValue = ({ map }, value) => {
168168
try {
@@ -176,7 +176,7 @@ export const mapValue = ({ map }, value) => {
176176
* Filter the values based on their type
177177
* @param {any} type
178178
* @param {any} value
179-
* @returns {{error?:boolean,value:any}}
179+
* @returns {{ error?: boolean, value: any }}
180180
*/
181181
export const filterValue = (type, value) =>
182182
type == null || value == null
@@ -202,9 +202,9 @@ export const filterValue = (type, value) =>
202202
: { value, error: true };
203203

204204
/**
205-
* @param {(...args:any[])=>any} map
206-
* @param {(...args:any[])=>any} [serialize]
207-
* @returns {import("schema").TypeCustom<(...args:any)=>any>}
205+
* @param {(...args: any[]) => any} map
206+
* @param {(...args: any[]) => any} [serialize]
207+
* @returns {import("schema").TypeCustom<(...args: any[]) => any>}
208208
*/
209209
export const createType = (map, serialize) => ({
210210
name: CUSTOM_TYPE_NAME,
@@ -218,33 +218,33 @@ export const createType = (map, serialize) => ({
218218
*/
219219

220220
/**
221-
* @typedef {Object} InternalEventInit
222-
* @property {typeof CustomEvent|typeof Event} [base] - Optional constructor to initialize the event
223-
* @property {boolean} [bubbles] - indicating whether the event bubbles. The default is false.
224-
* @property {boolean} [cancelable] - indicating whether the event will trigger listeners outside of a shadow root.
225-
* @property {boolean} [composed] - indicating whether the event will trigger listeners outside of a shadow root.
226-
* @property {any} [detail] - indicating whether the event will trigger listeners outside of a shadow root.
221+
* @typedef {object} InternalEventInit
222+
* @property {typeof CustomEvent | typeof Event} [base] Optional constructor to initialize the event
223+
* @property {boolean} [bubbles] indicating whether the event bubbles. The default is false.
224+
* @property {boolean} [cancelable] indicating whether the event will trigger listeners outside of a shadow root.
225+
* @property {boolean} [composed] indicating whether the event will trigger listeners outside of a shadow root.
226+
* @property {any} [detail] indicating whether the event will trigger listeners outside of a shadow root.
227227
*/
228228

229229
/**
230230
* Interface used by dispatchEvent to automate event firing
231-
* @typedef {Object} InternalEvent
232-
* @property {string} type - type of event to dispatch.
231+
* @typedef {object} InternalEvent
232+
* @property {string} type type of event to dispatch.
233233
*/
234234

235235
/**
236-
* @typedef {Object<string, {prop:string,type:Function}>} Attrs
236+
* @typedef {{ [attr: string]: { prop: string, type: Function } }} Attrs
237237
*/
238238

239239
/**
240-
* @typedef {Object<string, any>} Values
240+
* @typedef {{ [prop: string]: any }} Values
241241
*/
242242

243243
/**
244-
* @typedef {Object} Schema
245-
* @property {any} [type] - data type to be worked as property and attribute
246-
* @property {string} [attr] - allows customizing the name as an attribute by skipping the camelCase format
247-
* @property {boolean} [reflect] - reflects property as attribute of node
248-
* @property {InternalEvent & InternalEventInit} [event] - Allows to emit an event every time the property changes
249-
* @property {any} [value] - defines a default value when instantiating the component
244+
* @typedef {object} Schema
245+
* @property {any} [type] data type to be worked as property and attribute
246+
* @property {string} [attr] allows customizing the name as an attribute by skipping the camelCase format
247+
* @property {boolean} [reflect] reflects property as attribute of node
248+
* @property {InternalEvent & InternalEventInit} [event] Allows to emit an event every time the property changes
249+
* @property {any} [value] defines a default value when instantiating the component
250250
*/

src/hooks/create-hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ID = Symbol.for("atomico.hooks");
55
globalThis[ID] = globalThis[ID] || {};
66

77
/**
8-
* @type {{c:import("internal/hooks").SCOPE}}
8+
* @type {{ c: import("internal/hooks").SCOPE }}
99
*/
1010
let SCOPE = globalThis[ID];
1111

src/hooks/custom-hooks/use-suspense.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const useSuspense = (fps = 8) => {
5858
const [status, setStatus] = useState({ pending: true });
5959

6060
/**
61-
* @param {()=>any} callback
61+
* @param {() => any} callback
6262
* @param {number} deep
6363
*/
6464
const delay = (callback, deep) =>

src/hooks/use-effect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isEqualArray, isFunction } from "../utils.js";
99
/**
1010
* useLayoutEffect and useEffect have a similar algorithm
1111
* in that the position of the callback varies.
12-
* @param {IdLayoutEffect|IdEffect|IdInsertionEffect} type
12+
* @param {IdLayoutEffect | IdEffect | IdInsertionEffect} type
1313
* @return {import("internal/hooks").UseAnyEffect}
1414
*/
1515
const createEffect = (type) => (currentEffect, currentArgs) => {

src/render.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const Fragment = () => {};
5656
export function RENDER(node, id, hydrate) {
5757
return diff(this, node, id, hydrate);
5858
}
59+
5960
/**
6061
* @type {import("vnode").H}
6162
*/
@@ -226,7 +227,7 @@ function diff(newVnode, node, id = ID, hydrate = false, isSvg = false) {
226227
return node;
227228
}
228229
/**
229-
* @param {Element|ShadowRoot} parent
230+
* @param {Element | ShadowRoot} parent
230231
* @param {boolean} [hydrate]
231232
* @return {import("vnode").Fragment}
232233
*/
@@ -269,7 +270,7 @@ function createFragment(parent, hydrate) {
269270
* it allows rendering the children of the virtual-dom
270271
* @param {any} children
271272
* @param {import("vnode").Fragment} fragment
272-
* @param {Element|ShadowRoot} parent
273+
* @param {Element | ShadowRoot} parent
273274
* @param {any} id
274275
* @param {boolean} [hydrate]
275276
* @param {boolean} [isSvg]
@@ -379,8 +380,8 @@ export function renderChildren(children, fragment, parent, id, hydrate, isSvg) {
379380

380381
/**
381382
* @param {Element} node
382-
* @param {Object} props
383-
* @param {Object} nextProps
383+
* @param {object} props
384+
* @param {object} nextProps
384385
* @param {boolean} isSvg
385386
* @param {import("vnode").Handlers} handlers
386387
*/
@@ -515,7 +516,7 @@ export function setEvent(node, type, nextHandler, handlers) {
515516
}
516517

517518
/**
518-
* @param {*} style
519+
* @param {any} style
519520
* @param {string} key
520521
* @param {string} value
521522
*/

src/tests/internal/set-prototype.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe("internal: setPrototype", () => {
151151
it("declare basic", () => {
152152
class MyElement extends HTMLElement {}
153153
/**
154-
* @type {Object<string,string>}
154+
* @type {import("../../element/set-prototype.js").Attrs}
155155
*/
156156
const attrs = {};
157157
const values = {};
@@ -164,7 +164,7 @@ describe("internal: setPrototype", () => {
164164
it("declare shema", () => {
165165
class MyElement extends HTMLElement {}
166166
/**
167-
* @type {Object<string,string>}
167+
* @type {import("../../element/set-prototype.js").Attrs}
168168
*/
169169
const attrs = {};
170170
const values = {};

src/tests/render-children.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from "@esm-bundle/chai";
22
import { renderChildren } from "../render.js";
33
import { html } from "../../html.js";
44
/**
5-
* @param {import("../render").Fragment} fragment
5+
* @param {import("vnode").Fragment} fragment
66
* @returns {Node[]}
77
*/
88
const fragmentToChildNodes = ({ markStart, markEnd }) => {
@@ -13,14 +13,12 @@ const fragmentToChildNodes = ({ markStart, markEnd }) => {
1313
return list;
1414
};
1515
/**
16-
*
1716
* @param {number} min
1817
* @param {number} max
1918
* @returns {number}
2019
*/
2120
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
2221
/**
23-
*
2422
* @param {number} size
2523
* @returns {number[]}
2624
*/
@@ -79,7 +77,6 @@ describe("src/render#children", () => {
7977
const id = Symbol("id");
8078
let fragment;
8179
/**
82-
*
8380
* @param {number} size
8481
*/
8582
let update = (size) => {

0 commit comments

Comments
 (0)