osury 0.12.0 → 0.13.0
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/bin/osury.mjs +8 -1
- package/package.json +1 -1
- package/src/Codegen.res.mjs +10 -0
package/bin/osury.mjs
CHANGED
|
@@ -86,8 +86,15 @@ function generate(inputPath, outputPath) {
|
|
|
86
86
|
const dictShimPath = path.join(outputDir || ".", "Dict.gen.tsx");
|
|
87
87
|
fs.writeFileSync(dictShimPath, Codegen.generateDictShim());
|
|
88
88
|
|
|
89
|
+
// Write Nullable module and shim for @genType (T | null mapping)
|
|
90
|
+
const nullableModulePath = path.join(outputDir || ".", "Nullable.res");
|
|
91
|
+
fs.writeFileSync(nullableModulePath, Codegen.generateNullableModule());
|
|
92
|
+
|
|
93
|
+
const nullableShimPath = path.join(outputDir || ".", "Nullable.gen.ts");
|
|
94
|
+
fs.writeFileSync(nullableShimPath, Codegen.generateNullableShim());
|
|
95
|
+
|
|
89
96
|
console.log(`Generated ${result._0.length} types to ${outputPath}`);
|
|
90
|
-
console.log(`Generated
|
|
97
|
+
console.log(`Generated: ${dictShimPath}, ${nullableModulePath}, ${nullableShimPath}`);
|
|
91
98
|
} else {
|
|
92
99
|
console.error("Parse errors:");
|
|
93
100
|
result._0.forEach((err) => {
|
package/package.json
CHANGED
package/src/Codegen.res.mjs
CHANGED
|
@@ -790,6 +790,15 @@ export type t<T> = T | null;
|
|
|
790
790
|
`;
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
+
function generateNullableModule() {
|
|
794
|
+
return `// Generated by osury - Nullable type for JSON Schema null support
|
|
795
|
+
// Maps to T | null in TypeScript (not T | undefined like option<T>)
|
|
796
|
+
|
|
797
|
+
@genType.import(("./Nullable.gen.ts", "t"))
|
|
798
|
+
type t<'a> = option<'a>
|
|
799
|
+
`;
|
|
800
|
+
}
|
|
801
|
+
|
|
793
802
|
export {
|
|
794
803
|
reservedKeywords,
|
|
795
804
|
isReservedKeyword,
|
|
@@ -823,5 +832,6 @@ export {
|
|
|
823
832
|
generateModule,
|
|
824
833
|
generateDictShim,
|
|
825
834
|
generateNullableShim,
|
|
835
|
+
generateNullableModule,
|
|
826
836
|
}
|
|
827
837
|
/* No side effect */
|