ソースを参照

refactor: Adds objectid sequelize typescript

Owen Diffey 4 ヶ月 前
コミット
2d15cad296
2 ファイル変更15 行追加1 行削除
  1. 1 1
      backend/src/modules/DataModule.ts
  2. 14 0
      backend/src/types/sequelize.d.ts

+ 1 - 1
backend/src/modules/DataModule.ts

@@ -26,7 +26,7 @@ export type ObjectIdType = string;
 // TODO move to a better spot
 // Strange behavior would result if we extended DataTypes.ABSTRACT because
 // it's a class wrapped in a Proxy by Utils.classToInvokable.
-class OBJECTID extends DataTypes.ABSTRACT.prototype.constructor {
+export class OBJECTID extends DataTypes.ABSTRACT.prototype.constructor {
 	// Mandatory: set the type key
 	static key = "OBJECTID";
 

+ 14 - 0
backend/src/types/sequelize.d.ts

@@ -0,0 +1,14 @@
+import * as associationsBase from "sequelize/types/associations/base";
+import * as dataTypes from "sequelize/types/data-types";
+import { OBJECTID as ObjectIdClass } from "@/modules/DataModule";
+
+declare module "sequelize/types/associations/base" {
+	export interface ForeignKeyOptions
+		extends associationsBase.ForeignKeyOptions {
+		type: dataTypes;
+	}
+}
+
+declare module "sequelize/types/data-types" {
+	export const OBJECTID = ObjectIdClass;
+}