agency-lang 0.0.78 → 0.0.80
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.
|
@@ -31,6 +31,7 @@ export declare class AgencyGenerator extends BaseGenerator {
|
|
|
31
31
|
protected generateImports(): string;
|
|
32
32
|
protected preprocess(): string;
|
|
33
33
|
protected postprocess(): string;
|
|
34
|
+
private stringifyProp;
|
|
34
35
|
protected aliasedTypeToString(aliasedType: VariableType): string;
|
|
35
36
|
protected processTypeAlias(node: TypeAlias): string;
|
|
36
37
|
protected processTypeHint(node: TypeHint): string;
|
|
@@ -29,18 +29,34 @@ export class AgencyGenerator extends BaseGenerator {
|
|
|
29
29
|
postprocess() {
|
|
30
30
|
return "";
|
|
31
31
|
}
|
|
32
|
+
stringifyProp(prop) {
|
|
33
|
+
// if value is a union containing undefined, render as ?:
|
|
34
|
+
const isUnionWithUndefined = prop.value.type === "unionType" &&
|
|
35
|
+
prop.value.types.some((t) => t.type === "primitiveType" && t.value === "undefined");
|
|
36
|
+
if (isUnionWithUndefined) {
|
|
37
|
+
const nonUndefinedTypes = prop.value.types.filter((t) => !(t.type === "primitiveType" && t.value === "undefined"));
|
|
38
|
+
const unionWithoutUndefined = nonUndefinedTypes.length === 1
|
|
39
|
+
? nonUndefinedTypes[0]
|
|
40
|
+
: { type: "unionType", types: nonUndefinedTypes };
|
|
41
|
+
let str = `${prop.key}?: ${variableTypeToString(unionWithoutUndefined, this.typeAliases)}`;
|
|
42
|
+
if (prop.description) {
|
|
43
|
+
str += ` # ${prop.description}`;
|
|
44
|
+
}
|
|
45
|
+
return str;
|
|
46
|
+
}
|
|
47
|
+
let str = `${prop.key}: ${variableTypeToString(prop.value, this.typeAliases)}`;
|
|
48
|
+
if (prop.description) {
|
|
49
|
+
str += ` # ${prop.description}`;
|
|
50
|
+
}
|
|
51
|
+
return str;
|
|
52
|
+
}
|
|
32
53
|
aliasedTypeToString(aliasedType) {
|
|
33
54
|
if (aliasedType.type === "objectType") {
|
|
34
55
|
this.increaseIndent();
|
|
35
56
|
let result = "{\n" +
|
|
36
57
|
aliasedType.properties
|
|
37
58
|
.map((prop) => {
|
|
38
|
-
|
|
39
|
-
str += this.indentStr(`${prop.key}: ${this.aliasedTypeToString(prop.value)}`);
|
|
40
|
-
if (prop.description) {
|
|
41
|
-
str += ` # ${prop.description}`;
|
|
42
|
-
}
|
|
43
|
-
return str;
|
|
59
|
+
return this.indentStr(this.stringifyProp(prop));
|
|
44
60
|
})
|
|
45
61
|
.join(";\n") +
|
|
46
62
|
"\n";
|
package/dist/lib/cli/commands.js
CHANGED
|
@@ -151,8 +151,8 @@ export function compile(config, inputFile, _outputFile, options) {
|
|
|
151
151
|
});
|
|
152
152
|
const generatedCode = generateTypeScript(parsedProgram, config);
|
|
153
153
|
if (options?.ts) {
|
|
154
|
-
// TypeScript output —
|
|
155
|
-
fs.writeFileSync(outputFile, generatedCode, "utf-8");
|
|
154
|
+
// TypeScript output — add @ts-nocheck so type errors don't block compilation
|
|
155
|
+
fs.writeFileSync(outputFile, "// @ts-nocheck\n" + generatedCode, "utf-8");
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
158
|
// JavaScript output — strip types with esbuild
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agency-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "The Agency language",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"nanoid": "^5.1.6",
|
|
68
68
|
"ora": "^9.3.0",
|
|
69
69
|
"prompts": "^2.4.2",
|
|
70
|
-
"smoltalk": "^0.0.
|
|
70
|
+
"smoltalk": "^0.0.63",
|
|
71
71
|
"tarsec": "^0.1.8",
|
|
72
72
|
"termcolors": "github:egonSchiele/termcolors",
|
|
73
73
|
"typestache": "^0.4.4",
|