Skip to content

Commit 1d369db

Browse files
committed
fix: serialized info override on field overlap
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 52899e4 commit 1d369db

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/stringify-position.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ function stringifyPosition(
9999
info?: unknown,
100100
options?: Options | null
101101
): string {
102-
/**
103-
* Serialized positional info.
104-
*
105-
* @var {string} serialized
106-
*/
107-
let serialized: string = ''
108-
109102
if (typeof info === 'object' && info) {
110103
/**
111104
* Info passed around.
@@ -115,23 +108,23 @@ function stringifyPosition(
115108
const state: State = { offsets: options?.offsets ?? false }
116109

117110
// range
118-
if (Array.isArray(info)) serialized = range(<Range>info, state)
111+
if (Array.isArray(info)) return range(<Range>info, state)
119112

120113
// node
121114
if ('position' in info || 'type' in info) {
122-
serialized = position((<NodeLike>info).position, state)
115+
return position((<NodeLike>info).position, state)
123116
}
124117

125118
// position
126119
if ('end' in info || 'start' in info) {
127-
serialized = position(<PositionLike>info, state)
120+
return position(<PositionLike>info, state)
128121
}
129122

130123
// point
131-
if ('column' in info || 'line' in info) serialized = point(<PointLike>info)
124+
if ('column' in info || 'line' in info) return point(<PointLike>info)
132125
}
133126

134-
return serialized
127+
return ''
135128
}
136129

137130
export default stringifyPosition

0 commit comments

Comments
 (0)