I'm a JS Subject Matter Expert (SME) that has spent the past few years spearheading curricula and teaching initiatives at colleges and bootcamps, in person and virtually.
I am finding that combining this with an interface (shared with the UI) helps to keep them in sync. The interface will cause errors if your model is missing any fields
classBlogPostextendsModelimplementsIBlog{...}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a hack, probably not recommended, but this can work:
Upside,
You can add your database columns as part of the model and your IDE should pick them up
Downside
Because of the
[k: string]: any
property, Typescript will not warn if an undefined property was accessed on instances of BlogPost.I.e.
The code above will fly with Typescript, instead of it previously highlighting
post.undefined_property
...Very nice explanation. Looking 👀 forward to hearing more in the future. Welcome!
I am finding that combining this with an interface (shared with the UI) helps to keep them in sync. The interface will cause errors if your model is missing any fields