Skip to content

Commit 1ccbf52

Browse files
committed
fix: default value check
1 parent 8d7225b commit 1ccbf52

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

templates/cli/lib/commands/types.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
7878
outputDirectory = path.dirname(rawOutputPath);
7979
singleFileDestination = rawOutputPath;
8080
} else {
81-
throw new Error("Output path must be a directory for languages that generate multiple files.");
81+
throw new Error(`Invalid output path: ${rawOutputPath}. Output path must be a directory for languages that generate multiple files.`);
8282
}
8383
}
8484

templates/cli/lib/type-generation/languages/typescript.js.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class TypeScript extends LanguageMeta {
4040
if (attribute.array) {
4141
type += "[]";
4242
}
43+
if (!attribute.required && attribute.default === null) {
44+
type += " | null";
45+
}
4346
return type;
4447
}
4548

@@ -87,7 +90,7 @@ export enum <%- toPascalCase(attribute.key) %> {
8790
<% for (const collection of collections) { -%>
8891
export type <%- toPascalCase(collection.name) %> = Models.Document & {
8992
<% for (const attribute of collection.attributes) { -%>
90-
<%- toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>: <%- getType(attribute) %>;
93+
<%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>;
9194
<% } -%>
9295
}
9396

0 commit comments

Comments
 (0)