Skip to content

Vue/TS How to add a generic T item to a reactive array of generic T items? #10534

Discussion options

You must be logged in to vote

I was able to get around the TypeScript error by forcing TypeScript to read the generic array as if it were a normal array of T objects:
public insert() { if (!this.hasUnsavedNewRow.value) { const newItem = new (this._ctor); (this.gridItems as T[]).unshift(newItem); } }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PumpkinVision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant