Skip to content

Commit 2ea59ed

Browse files
committed
Fix types to allow literal nodes
1 parent 433e10d commit 2ea59ed

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/**
22
* @typedef {import('unist').Position} Position
3+
* @typedef {import('unist').Node} Node
4+
* @typedef {Record<string, unknown> & {type: string, position?: PositionLike|undefined}} NodeLike
35
* @typedef {import('unist').Point} Point
46
*
57
* @typedef {Partial<Point>} PointLike
68
*
7-
* @typedef {Object} PositionLike
9+
* @typedef PositionLike
810
* @property {PointLike} [start]
911
* @property {PointLike} [end]
10-
*
11-
* @typedef {Object} NodeLike
12-
* @property {PositionLike} [position]
1312
*/
1413

1514
export const pointStart = point('start')

test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import test from 'tape'
22
import {position, pointStart, pointEnd} from './index.js'
33

44
const properties = {
5+
type: 'a',
56
position: {
67
start: {line: 1, column: 1, offset: 0},
78
end: {line: 1, column: 2, offset: 1}
89
}
910
}
1011

11-
const noFields = {position: {start: {}, end: {}}}
12+
const noFields = {type: 'b', position: {start: {}, end: {}}}
1213

13-
const noPoints = {position: {}}
14+
const noPoints = {type: 'c', position: {}}
1415

15-
const noPosition = {}
16+
const noPosition = {type: 'd'}
1617

1718
const generated = {line: null, column: null, offset: null}
1819

0 commit comments

Comments
 (0)