diff --git a/types/lib/data-types.d.ts b/types/lib/data-types.d.ts index dd0eed60172d..2eb62626a331 100644 --- a/types/lib/data-types.d.ts +++ b/types/lib/data-types.d.ts @@ -52,6 +52,8 @@ export const ABSTRACT: AbstractDataTypeConstructor; interface AbstractDataTypeConstructor { key: string; warn(link: string, text: string): void; + new (): AbstractDataType; + (): AbstractDataType; } export interface AbstractDataType { @@ -336,7 +338,7 @@ interface DateDataTypeConstructor extends AbstractDataTypeConstructor { (options?: DateDataTypeOptions): DateDataType; } -export interface DateDataType extends AbstractDataTypeConstructor { +export interface DateDataType extends AbstractDataType { options: DateDataTypeOptions; } @@ -367,7 +369,6 @@ export const HSTORE: AbstractDataTypeConstructor; * A JSON string column. Only available in postgres. */ export const JSON: AbstractDataTypeConstructor; - /** * A pre-processed JSON data column. Only available in postgres. */ diff --git a/types/lib/query-interface.d.ts b/types/lib/query-interface.d.ts index ebbe9f138928..01c8eef3ca7e 100644 --- a/types/lib/query-interface.d.ts +++ b/types/lib/query-interface.d.ts @@ -497,7 +497,7 @@ export class QueryInterface { tableName: TableName, records: object[], options?: QueryOptions, - attributes?: string[] | string + attributes?: Record ): Promise; /** diff --git a/types/test/data-types.ts b/types/test/data-types.ts index 01d463f2135b..e3d43c75877a 100644 --- a/types/test/data-types.ts +++ b/types/test/data-types.ts @@ -1,7 +1,7 @@ import { expectTypeOf } from 'expect-type'; import { DataTypes } from 'sequelize'; -const { TINYINT, SMALLINT, MEDIUMINT, BIGINT, INTEGER } = DataTypes; +const { TINYINT, SMALLINT, MEDIUMINT, BIGINT, INTEGER, JSON, JSONB, CITEXT, MACADDR, TSVECTOR, CIDR, INET } = DataTypes; // TINYINT expectTypeOf(TINYINT()).toEqualTypeOf(); @@ -32,3 +32,31 @@ expectTypeOf(INTEGER()).toEqualTypeOf(); expectTypeOf(new INTEGER()).toEqualTypeOf(); expectTypeOf(INTEGER.UNSIGNED.ZEROFILL()).toEqualTypeOf(); expectTypeOf(new INTEGER.UNSIGNED.ZEROFILL()).toEqualTypeOf(); + +// JSON +expectTypeOf(new JSON()).toEqualTypeOf(); +expectTypeOf(JSON()).toEqualTypeOf(); + +// JSONB +expectTypeOf(new JSONB()).toEqualTypeOf(); +expectTypeOf(JSONB()).toEqualTypeOf(); + +// CITEXT +expectTypeOf(new CITEXT()).toEqualTypeOf(); +expectTypeOf(CITEXT()).toEqualTypeOf(); + +// MACADDR +expectTypeOf(new MACADDR()).toEqualTypeOf(); +expectTypeOf(MACADDR()).toEqualTypeOf(); + +// TSVECTOR +expectTypeOf(new TSVECTOR()).toEqualTypeOf(); +expectTypeOf(TSVECTOR()).toEqualTypeOf(); + +// CIDR +expectTypeOf(new CIDR()).toEqualTypeOf(); +expectTypeOf(CIDR()).toEqualTypeOf(); + +// INET +expectTypeOf(new INET()).toEqualTypeOf(); +expectTypeOf(INET()).toEqualTypeOf(); diff --git a/types/test/query-interface.ts b/types/test/query-interface.ts index 25454db082ff..58408c298add 100644 --- a/types/test/query-interface.ts +++ b/types/test/query-interface.ts @@ -67,6 +67,8 @@ async function test() { const bulkInsertRes: Promise = queryInterface.bulkInsert({ tableName: 'foo', as: 'bar', name: 'as' }, [{}], {}); + const bulkInsertResWithAttrs: Promise = queryInterface.bulkInsert('foo', [{}], {}, { bar: { type: DataTypes.JSON } }); + await queryInterface.bulkUpdate({ tableName: 'foo', delimiter: 'bar', as: 'baz', name: 'quz' }, {}, {}); await queryInterface.dropTrigger({ tableName: 'foo', as: 'bar', name: 'baz' }, 'foo', {});