@pronto-tools-and-more/type-checker 12.20.0 → 12.21.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/type-checker",
3
- "version": "12.20.0",
3
+ "version": "12.21.0",
4
4
  "description": "",
5
5
  "main": "src/typeCheckerMain.js",
6
6
  "type": "module",
@@ -1,9 +1,27 @@
1
+ const getPosition = (text, start) => {
2
+ let lineCount = 0;
3
+ for (let i = 0; i < start; i++) {
4
+ if (text[i] === "\n") {
5
+ lineCount++;
6
+ }
7
+ }
8
+
9
+ return {
10
+ rowIndex: lineCount + 1,
11
+ columnIndex: 0,
12
+ };
13
+ };
14
+
1
15
  export const formatError = (error) => {
2
16
  const { file, start, length, messageText } = error;
17
+ const text = file?.text || "";
18
+ const { rowIndex, columnIndex } = getPosition(text, start);
3
19
  return {
4
20
  message: messageText,
5
21
  start,
6
22
  length,
7
23
  fileName: file?.fileName || "",
24
+ rowIndex,
25
+ columnIndex,
8
26
  };
9
27
  };