I'm working on a full-stack app:
- Backend: Node, Typescript, TypeORM
- Frontend: Typescript, Vue (using Vue CLI and class components)
I'm trying to share my models with the frontend using TypeORM's shim for webpack. This is largely working. However, when I use an entity type in a component method signature, I get an error:
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { Family } from "@/entity/Family";
@Component()
export default class MyComponent extends Vue {
newFamily: Family | null = null; // <-- *Using Family here compiles and works.*
@Watch("newFamily")
onNewFamilyChanged(val: Family, oldVal: Family): void { // <-- *This throws the error below.*
...
}
Error:
This dependency was not found:
* typeorm in ./src/entity/Family.ts
To install it, you can run: npm install --save typeorm
If I switch the Family argument types on onNewFamilyChanged to any, then everything works again. I'm not sure where to go from here, but I suspect some processing or transformation carried out by vue-class-component is bypassing the shim?