@param {Node | Comment} node @return {number}
(node)
| 9 | @return {number} |
| 10 | */ |
| 11 | function locStart(node) { |
| 12 | // @ts-expect-error -- safe |
| 13 | const start = node.range?.[0] ?? node.start; |
| 14 | |
| 15 | /* c8 ignore next 3 */ |
| 16 | if (process.env.NODE_ENV !== "production" && !isIndex(start)) { |
| 17 | throw new TypeError("Can't not locate node."); |
| 18 | } |
| 19 | |
| 20 | // Handle nodes with decorators. They should start at the first decorator |
| 21 | // @ts-expect-error -- safe |
| 22 | const firstDecorator = (node.declaration?.decorators ?? node.decorators)?.[0]; |
| 23 | if (firstDecorator) { |
| 24 | return Math.min(locStart(firstDecorator), start); |
| 25 | } |
| 26 | |
| 27 | return start; |
| 28 | } |
| 29 | |
| 30 | export { locStart }; |
no test coverage detected
searching dependent graphs…