I encountered this error in Typescript while doing something pretty straightforward. In my component file:
export class BookDownloadModalComponent {
versions!: [];
"versions" is an array which I'm loading from an API. In my template I did the following (this is Angular, btw):
<div *ngFor="let bookversion of versions" class="w-full">
{{ bookversion.version }}
</div>
This gave me this error:
TS2339: Property 'version' does not exist on type 'never'.
You have to define the array as an array of any type. This becomes:
export class BookDownloadModalComponent {
versions!: any[];
By default, TypeScript defines empty arrays as never[]
. That is an array that always will be empty. A bizarre thing of TS. More info here.