class Pair<T, U> {
constructor(public first: T, public second: U) {}
}
const pair = new Pair<string, number>("hello", 42);
In this example, the Pair class has two type parameters, T and U, which represent the types of the first and second values, respectively. When a new instance of the Pair class is created, the type arguments string and number are used to specify the types of the first and second values, respectively.
import { Model } from 'sequelize';
interface UserAttributes {
id: number;
name: string;
email: string;
}
interface UserCreationAttributes {
name: string;
email: string;
password: string;
}
class UserModel extends Model<UserAttributes, UserCreationAttributes> implements UserAttributes {
public id!: number;
public name!: string;
public email!: string;
}
In this example, UserModel extends the Model class provided by Sequelize, and specifies the type arguments UserAttributes and UserCreationAttributes. UserAttributes represents the type of the instance of the UserModel class, which is an object that represents a row in the users table in the database. UserCreationAttributes represents the type of the creation options that are required to create a new instance of the UserModel class.