diff --git a/linter/eslint.js b/linter/eslint.js index d8cc7d57..f49ba457 100644 --- a/linter/eslint.js +++ b/linter/eslint.js @@ -37,6 +37,7 @@ const DEFAULT_CONFIG = { disallowTypeAnnotations: false, }, ], + "@typescript-eslint/consistent-type-imports": 0, "prettier-vue/prettier": [ "error", { diff --git a/stores/firestore/input.ts b/stores/firestore/input.ts index cf83d59b..405c1969 100755 --- a/stores/firestore/input.ts +++ b/stores/firestore/input.ts @@ -1,3 +1,4 @@ +import "reflect-metadata"; import { reactive } from "vue"; import { onInitialize } from "./entity"; import type { EntityMetaData } from "./entityMetadata"; @@ -14,9 +15,5 @@ export function Input(type: any, options: any = {}) { errors: [], }; }); - /* setPropertyMetadata(target, name, "input", { - type, - options, - });*/ }; } diff --git a/stores/firestore/var.ts b/stores/firestore/var.ts index 3c409e2e..40a66042 100644 --- a/stores/firestore/var.ts +++ b/stores/firestore/var.ts @@ -118,8 +118,19 @@ function isUnparsedEqual(a: any, b: any, type: any): boolean { return a === b; } -export function Var(type: any) { +export function Var(type?: any) { return function (target: EntityBase, name: string) { + if (type === undefined) { + const metadata = Reflect.getMetadata("design:type", target, name); + if (metadata === undefined) + throw new Error( + "Property type is not set for " + target.constructor.name + ":" + name + ); + + if (metadata.type === Array) type = Array.of(metadata.elementType); + else type = metadata; + } + onInitialize(target, function (this: any, metadata: EntityMetaData) { if (metadata.properties[name] === undefined) metadata.properties[name] = {}; diff --git a/tsconfig.json b/tsconfig.json index 8d1ba5c1..1d0da556 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -52,6 +52,7 @@ "stylelint.config.js", "index.ts", "vite.config.cjs", - "default-styles.ts" + "default-styles.ts", + "reflect-metadata.d.ts" ] } diff --git a/vite.config.cjs b/vite.config.cjs index bd7738aa..21c71ae0 100755 --- a/vite.config.cjs +++ b/vite.config.cjs @@ -12,6 +12,8 @@ const vueI18n = require("@intlify/unplugin-vue-i18n/vite"); const { VitePWA } = require("vite-plugin-pwa"); const { createHtmlPlugin } = require("vite-plugin-html"); const purgecss = require("rollup-plugin-purgecss"); +const { esbuildDecorators } = require("@anatine/esbuild-decorators"); +const { default: babel } = require("vite-plugin-babel"); const { VueUseComponentsResolver, VueUseDirectiveResolver, @@ -69,7 +71,6 @@ module.exports.define = function (config = {}) { logLevel: SILENT ? "error" : "info", clearScreen: false, cacheDir: cacheDir, - css: { devSourcemap: config.map !== undefined ? config.map : DEV, preprocessorOptions: { @@ -88,6 +89,13 @@ module.exports.define = function (config = {}) { "bulma", "addeus-common-library", ], + esbuildOptions: { + plugins: [ + esbuildDecorators({ + tsconfig: "./tsconfig.json", + }), + ], + }, }, resolve: { alias: [ @@ -103,6 +111,7 @@ module.exports.define = function (config = {}) { sourcemap: config.map !== undefined ? config.map : !DEV, outDir: outDir, emptyOutDir: true, + esbuild: false, //chunkSizeWarningLimit: 3000, rollupOptions: { maxParallelFileOps: Math.max(1, cpus().length - 1), @@ -199,6 +208,20 @@ module.exports.define = function (config = {}) { isProduction: !DEV, }), + babel({ + filter: /\.tsx?$/, + babelConfig: { + babelrc: false, + configFile: false, + presets: ["@babel/preset-typescript"], + plugins: [ + "babel-plugin-reactgenie", + ["@babel/plugin-proposal-decorators", { legacy: true }], + ["@babel/plugin-proposal-class-properties", { loose: true }], + ], + }, + }), + createHtmlPlugin({ minify: !DEV, inject: {