@defold-typescript/transpiler 0.18.4 → 0.18.6
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 +13 -1
- package/dist/transpile.d.ts +2 -0
- package/package.json +2 -2
- package/src/transpile.ts +23 -3
package/dist/index.js
CHANGED
|
@@ -624,6 +624,11 @@ export type { ScriptProperties, ScriptProperty } from "./src/lifecycle.js";
|
|
|
624
624
|
files[`node_modules/@defold-typescript/types/generated/${entry}`] = readAmbient(`generated/${entry}`);
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
+
for (const entry of readdirSync(path.join(TYPES_PKG_ROOT, "src"))) {
|
|
628
|
+
if (entry.endsWith(".d.ts")) {
|
|
629
|
+
files[`node_modules/@defold-typescript/types/src/${entry}`] = readAmbient(`src/${entry}`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
627
632
|
return files;
|
|
628
633
|
}
|
|
629
634
|
var AMBIENT_FILES = buildAmbientFiles();
|
|
@@ -652,7 +657,14 @@ function collectOutputs(transpiledFiles, diagnostics, userKeys) {
|
|
|
652
657
|
const collectedDiagnostics = diagnostics.map((d) => {
|
|
653
658
|
const fileName = d.file?.fileName;
|
|
654
659
|
const message = flattenDiagnosticMessage(d.messageText);
|
|
655
|
-
|
|
660
|
+
if (fileName === undefined || !userKeys.has(fileName)) {
|
|
661
|
+
return { message };
|
|
662
|
+
}
|
|
663
|
+
if (d.file === undefined || d.start === undefined) {
|
|
664
|
+
return { file: fileName, message };
|
|
665
|
+
}
|
|
666
|
+
const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
|
|
667
|
+
return { file: fileName, message, line: line + 1, column: character + 1 };
|
|
656
668
|
});
|
|
657
669
|
const scanned = new Set;
|
|
658
670
|
let timersImported = false;
|
package/dist/transpile.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.18.6",
|
|
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.
|
|
38
|
+
"@defold-typescript/types": "0.18.6",
|
|
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.
|
|
@@ -160,6 +165,16 @@ function buildAmbientFiles(): Record<string, string> {
|
|
|
160
165
|
);
|
|
161
166
|
}
|
|
162
167
|
}
|
|
168
|
+
// Seed every hand-authored `src/*.d.ts` augmentation (overloads + guards) so
|
|
169
|
+
// the virtual program mirrors index.d.ts's `import "./src/*"` set. Enumerated
|
|
170
|
+
// rather than hard-listed so a new augmentation (e.g. socket-types,
|
|
171
|
+
// vmath-overloads) can't silently drop out of the transpiler surface while
|
|
172
|
+
// still type-checking under the editor's index.d.ts.
|
|
173
|
+
for (const entry of readdirSync(path.join(TYPES_PKG_ROOT, "src"))) {
|
|
174
|
+
if (entry.endsWith(".d.ts")) {
|
|
175
|
+
files[`node_modules/@defold-typescript/types/src/${entry}`] = readAmbient(`src/${entry}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
163
178
|
return files;
|
|
164
179
|
}
|
|
165
180
|
|
|
@@ -204,9 +219,14 @@ export function collectOutputs(
|
|
|
204
219
|
const collectedDiagnostics: TranspileDiagnostic[] = diagnostics.map((d) => {
|
|
205
220
|
const fileName = d.file?.fileName;
|
|
206
221
|
const message = flattenDiagnosticMessage(d.messageText);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
222
|
+
if (fileName === undefined || !userKeys.has(fileName)) {
|
|
223
|
+
return { message };
|
|
224
|
+
}
|
|
225
|
+
if (d.file === undefined || d.start === undefined) {
|
|
226
|
+
return { file: fileName, message };
|
|
227
|
+
}
|
|
228
|
+
const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
|
|
229
|
+
return { file: fileName, message, line: line + 1, column: character + 1 };
|
|
210
230
|
});
|
|
211
231
|
|
|
212
232
|
// Advisory scan of the user TypeScript AST for the deprecated direct
|