Issue
I'm trying to use .d.ts files to write type definitions for sequelize models in my JS. I have most of it working, however, all the properties are showing as optional in Model.create().
index.d.ts:
interface MyModelSchema extends Model<InferAttributes<MyModelSchema>, InferCreationAttributes<MyModelSchema>> {
id: CreationOptional<string>;
some_required_property: number;
some_optional_property?: number;
}
type MyModel = ModelStatic<MyModelSchema>;
declare const MyModel: MyModel;
index.js: (MyModel is showing the correct type)
// Properties on document are correctly marked as required
const document = MyModel.create({
// All properties are optional here
});
Solution
Turns out that all along I was just missing "strictNullChecks": true, in my jsconfig.json.
Answered By - asportnoy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.