@defold-typescript/transpiler 0.18.4 → 0.18.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -652,7 +652,14 @@ function collectOutputs(transpiledFiles, diagnostics, userKeys) {
652
652
  const collectedDiagnostics = diagnostics.map((d) => {
653
653
  const fileName = d.file?.fileName;
654
654
  const message = flattenDiagnosticMessage(d.messageText);
655
- return fileName !== undefined && userKeys.has(fileName) ? { file: fileName, message } : { message };
655
+ if (fileName === undefined || !userKeys.has(fileName)) {
656
+ return { message };
657
+ }
658
+ if (d.file === undefined || d.start === undefined) {
659
+ return { file: fileName, message };
660
+ }
661
+ const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
662
+ return { file: fileName, message, line: line + 1, column: character + 1 };
656
663
  });
657
664
  const scanned = new Set;
658
665
  let timersImported = false;
@@ -7,6 +7,8 @@ export interface TranspileResult {
7
7
  export interface TranspileDiagnostic {
8
8
  readonly file?: string;
9
9
  readonly message: string;
10
+ readonly line?: number;
11
+ readonly column?: number;
10
12
  readonly category?: "warning";
11
13
  }
12
14
  export interface TranspileProjectInput {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defold-typescript/transpiler",
3
- "version": "0.18.4",
3
+ "version": "0.18.5",
4
4
  "description": "TypeScript-to-Lua build pipeline tuned for Defold's runtime.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@defold-typescript/types": "0.18.4",
38
+ "@defold-typescript/types": "0.18.5",
39
39
  "@typescript-to-lua/language-extensions": "1.19.0",
40
40
  "typescript-to-lua": "^1.36.0"
41
41
  }
package/src/transpile.ts CHANGED
@@ -23,6 +23,11 @@ export interface TranspileResult {
23
23
  export interface TranspileDiagnostic {
24
24
  readonly file?: string;
25
25
  readonly message: string;
26
+ // 1-based source position of the offending expression. Populated only for
27
+ // user-file diagnostics that carry a TS position; absent means a positionless
28
+ // project diagnostic (no `file`/`start`).
29
+ readonly line?: number;
30
+ readonly column?: number;
26
31
  // Present only on advisory diagnostics (e.g. the deprecated direct
27
32
  // `go.property` call). Absent means a hard failure, so `collectFailures`
28
33
  // keeps treating uncategorized diagnostics as fatal.
@@ -204,9 +209,14 @@ export function collectOutputs(
204
209
  const collectedDiagnostics: TranspileDiagnostic[] = diagnostics.map((d) => {
205
210
  const fileName = d.file?.fileName;
206
211
  const message = flattenDiagnosticMessage(d.messageText);
207
- return fileName !== undefined && userKeys.has(fileName)
208
- ? { file: fileName, message }
209
- : { message };
212
+ if (fileName === undefined || !userKeys.has(fileName)) {
213
+ return { message };
214
+ }
215
+ if (d.file === undefined || d.start === undefined) {
216
+ return { file: fileName, message };
217
+ }
218
+ const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
219
+ return { file: fileName, message, line: line + 1, column: character + 1 };
210
220
  });
211
221
 
212
222
  // Advisory scan of the user TypeScript AST for the deprecated direct