Skip to content

Commit e98f8fd

Browse files
committed
Refactor internals so typescript can understand things
1 parent b9b6cc5 commit e98f8fd

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

index.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
var own = {}.hasOwnProperty
2-
31
/**
4-
* @typedef {Record<string, unknown> & {type: string, position?: Position|undefined}} NodeLike
5-
* @typedef {import('unist').Position} Position
62
* @typedef {import('unist').Point} Point
3+
* @typedef {import('unist').Position} Position
4+
* @typedef {Record<string, unknown> & {type: string, position?: Position|undefined}} NodeLike
75
*/
86

97
/**
@@ -20,20 +18,17 @@ export function stringifyPosition(value) {
2018
}
2119

2220
// Node.
23-
if (own.call(value, 'position') || own.call(value, 'type')) {
24-
// @ts-expect-error looks like a node.
21+
if ('position' in value || 'type' in value) {
2522
return position(value.position)
2623
}
2724

2825
// Position.
29-
if (own.call(value, 'start') || own.call(value, 'end')) {
30-
// @ts-expect-error looks like a position.
26+
if ('start' in value || 'end' in value) {
3127
return position(value)
3228
}
3329

3430
// Point.
35-
if (own.call(value, 'line') || own.call(value, 'column')) {
36-
// @ts-expect-error looks like a point.
31+
if ('line' in value || 'column' in value) {
3732
return point(value)
3833
}
3934

0 commit comments

Comments
 (0)