NuxtN
Nuxt2y ago
Insight

ERROR: Invalid assignment target when using a type in ref

I am attempting to use drizzle orm and I have a table and models that look like

export type Account = InferSelectModel<typeof TAccounts> & { createdAt: Date };
export type NewAccount = Omit<Account, 'id' | 'createdAt'>


In a component for a form for NewAccount I have const form = ref<NewAccount>(); and when I try to map that using v-model in the html of the page like below.

      <input
            v-model="form?.name"
            type="text"
            placeholder="Enter account name"
          />


I get the error:

[plugin:vite:vue] Transform failed with 1 error:
<project>/components/Form/NewAccount.vue:38:67: ERROR: Invalid assignment target

36 |    return (_openBlock(), _createElementBlock("div", _hoisted_1, [
37 |      _withDirectives(_createElementVNode("input", {
38 |        "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => (($setup.form?.name) = $event)),
   |              


I have tried using reactive and make things work but no matter what I do it doesn't work. Even if I take the drizzle orm out of it like
type Test = {
  name: string;
  age: number;
};

const form  = ref<Test>();


the same error occurs.
Was this page helpful?