title: TypeScript & Sequelize: Pass in generic Model
body: <p>I have this code</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Model, DataTypes, Sequelize } from "sequelize";
  
  class User extends Model {
      public id!: number;
      public firstName!: string;
      public readonly createdAt!: Date;
      public readonly updatedAt!: Date;
  }
  
  function async InitAndDefineModel(model: Model): void {
      const sequelize = new Sequelize({
          dialect: "sqlite",
          storage: ":memory:",
      });
      model.init{
          firstName: {
              allowNull: false,
              type: DataTypes.STRING,
          },
      },
      {
          sequelize,
      });
      const tables = await sequelize.showAllSchemas({});
      console.log(tables);
  }
  
  InitAndDefineModel(User);
  </code></pre>
  
  <p>The console.log statement returns:</p>
  
  <pre><code>// [ { name: 'Users' } ]
  </code></pre>
  
  <p>So I know the code works, however, TypeScript complains that:</p>
  
  <pre><code>Property 'init' is a static member of type 'Model&lt;any, any&gt;'ts(2576)
  </code></pre>
  
  <p>on the <code>model.init(...)</code> call.</p>
  
  <p>I think TS thinks I'm passing in a Model object directory. I guess I need to tell it it's a type of Model, or the object passed in was extended from it.
  How do I tell TypeScript that the argument <code>model: Model</code> is valid? I tried to use <code>model: Model&lt;T&gt;</code> and `model: T any other variations, but to no avail.</p>