1
1
/**
2
2
* @typedef {import('unist').Position } Position
3
3
* @typedef {import('unist').Node } Node
4
- * @typedef {Record<string, unknown> & {type: string, position?: PositionLike|undefined} } NodeLike
5
4
* @typedef {import('unist').Point } Point
6
- *
7
- * @typedef {Partial<Point> } PointLike
5
+ */
6
+
7
+ /**
8
+ * @typedef NodeLike
9
+ * @property {string } type
10
+ * @property {PositionLike | null | undefined } [position]
8
11
*
9
12
* @typedef PositionLike
10
- * @property {PointLike } [start]
11
- * @property {PointLike } [end]
13
+ * @property {PointLike | null | undefined } [start]
14
+ * @property {PointLike | null | undefined } [end]
15
+ *
16
+ * @typedef PointLike
17
+ * @property {number | null | undefined } [line]
18
+ * @property {number | null | undefined } [column]
19
+ * @property {number | null | undefined } [offset]
12
20
*/
13
21
14
22
export const pointStart = point ( 'start' )
@@ -17,8 +25,10 @@ export const pointEnd = point('end')
17
25
/**
18
26
* Get the positional info of `node`.
19
27
*
20
- * @param {NodeLike|Node } [node]
28
+ * @param {NodeLike | Node | null | undefined } [node]
29
+ * Node.
21
30
* @returns {Position }
31
+ * Position.
22
32
*/
23
33
export function position ( node ) {
24
34
return { start : pointStart ( node ) , end : pointEnd ( node ) }
@@ -27,15 +37,18 @@ export function position(node) {
27
37
/**
28
38
* Get the positional info of `node`.
29
39
*
30
- * @param {'start'|'end' } type
40
+ * @param {'start' | 'end' } type
41
+ * Side.
42
+ * @returns
43
+ * Getter.
31
44
*/
32
45
function point ( type ) {
33
46
return point
34
47
35
48
/**
36
- * Get the positional info of `node`.
49
+ * Get the point info of `node` at a bound side .
37
50
*
38
- * @param {NodeLike| Node } [node]
51
+ * @param {NodeLike | Node | null | undefined } [node]
39
52
* @returns {Point }
40
53
*/
41
54
function point ( node ) {
0 commit comments