Skip to content

Commit

Permalink
Revert "fix(typescript): set relations fields as optional (#19)"
Browse files Browse the repository at this point in the history
This reverts commit 231b28f0afb330c71f2e06697b25d146704888f6.

See maltejur/directus-extension-generate-types#24
  • Loading branch information
arnulfoacevedo committed Apr 6, 2023
1 parent f2b0b40 commit ce67270
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/generateTypes/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function generateTsTypes(
if (field.meta?.interface?.startsWith("presentation-")) return;
ret += " ";
ret += field.field.includes("-") ? `"${field.field}"` : field.field;
if (field.relation || field.schema?.is_nullable) ret += "?";
if (field.schema?.is_nullable) ret += "?";
ret += ": ";
ret += getType(field, useIntersectionTypes);
ret += ";\n";
Expand Down Expand Up @@ -63,7 +63,7 @@ function getType(field: Field, useIntersectionTypes = false) {
: "any";
if (field.relation.type === "many") type += "[]";
}
if (field.relation || field.schema?.is_nullable) {
if (field.schema?.is_nullable) {
if (field.relation && useIntersectionTypes) {
type = `(${type}) | null`;
} else {
Expand Down

0 comments on commit ce67270

Please sign in to comment.