Skip to content

Commit a84710a

Browse files
ymc9claude
andcommitted
fix(sdk): respect @@strict inherited from mixins in type def generation
The strict flag check used hasAttribute, which only inspects attributes declared directly on the type def, while the attributes array is built with getAllAttributes (including mixins). A type def inheriting @@strict from a mixin thus never got \`strict: true\` in the generated schema. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a46d1a6 commit a84710a

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/cli/test/ts-schema-gen.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,27 @@ type Profile {
872872
},
873873
});
874874
});
875+
876+
it('supports @@strict inherited from mixins', async () => {
877+
const { schema } = await generateTsSchema(`
878+
model User {
879+
id String @id @default(uuid())
880+
profile Profile? @json
881+
}
882+
883+
type Strict {
884+
@@strict
885+
}
886+
887+
type Profile with Strict {
888+
bio String
889+
}
890+
`);
891+
892+
expect(schema.typeDefs).toMatchObject({
893+
Profile: {
894+
strict: true,
895+
},
896+
});
897+
});
875898
});

packages/sdk/src/ts-schema-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export class TsSchemaGenerator {
546546
: []),
547547
];
548548

549-
if (hasAttribute(td, '@@strict')) {
549+
if (getAllAttributes(td).some((attr) => attr.decl.$refText === '@@strict')) {
550550
fields.push(ts.factory.createPropertyAssignment('strict', ts.factory.createTrue()));
551551
}
552552

0 commit comments

Comments
 (0)