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
});
Turns out that all along I was just missing "strictNullChecks": true,
in my jsconfig.json
.