error TS2339: Property 'name' does not exist on type 'unknown'
See original GitHub issueHi,
When I try to build (with Ivy) the example “Custom template for all selected items using ng-multi-label-tmp” I’ve got this error :
error TS2339: Property 'avatar_url' does not exist on type 'unknown'
If I disable Ivy, it compiles. Is there a way to allow this example to compile ? It seems like let-items=“items” in the declaration of ng-multi-label-tmp doesn’t keep the type of [items]
I use this example in my project and would like to build it using Ivy. Here is my code :
<div class="col-12 col-sm-6 col-md-4 col-xl p-2" *ngFor="let filter of filters">
<ng-select
[placeholder]="filter.name"
[items]="filter.items"
bindLabel="name"
bindValue="filter"
groupBy="groupValue"
[selectableGroup]="true"
[selectableGroupAsModel]="false"
[multiple]="true"
[closeOnSelect]="false"
(change)="applyChange()"
[(ngModel)]="userSelections[filter.name]"
class="input-xs"
>
<ng-template ng-optgroup-tmp let-item="item">
{{item.groupValue || ''}}
</ng-template>
<ng-template ng-option-tmp let-item="item" let-item$="item$" let-index="index">
<input id="item-{{index}}" type="checkbox" [ngModel]="item$.selected"/> {{item.name}}
</ng-template>
<ng-template ng-multi-label-tmp let-items="items" let-clear="clear">
<div class="ng-value" *ngFor="let item of items | slice:0:filter.maxItems">
<span *ngIf="items.length < filter.maxItems">
<span class="ng-value-label">{{item.name}}</span>
<span class="ng-value-icon right" (click)="clear(item)" aria-hidden="true">×</span>
</span>
</div>
<div class="ng-value" *ngIf="items.length > filter.maxItems">
<span class="ng-value-label">{{items.length - filter.maxItems}} de plus...</span>0
</div>
</ng-template>
</ng-select>
</div>
Thanks for your help.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:5
Top Results From Across the Web
error TS2339: Property 'x' does not exist on type 'Y'
I'm getting error (using TypeScript 1.7.5):. error TS2339: Property 'main' does not exist on type 'Images'. Of course I could get rid of...
Read more >Property does not exist on type 'unknown'. : r/typescript - Reddit
The error is telling you that you have a value of type unknown , but you are trying to assign it to a...
Read more >How to resolve the error ' Error:(54,6) TS2339:property 'name ...
FIrst - what the error message means - It means that the object doesn't have a property(field/attribute/variable) or method(function) by that name at...
Read more >Typescript Type System: How Does it Really Work? Type ...
Let's have a look at the error message we get: Error:(54, 6) TS2339:Property 'name' does not exist on type '{}'. So what is ......
Read more >Fix - Property does not exist on type '{}' in TypeScript
To fix the error “Property does not exist on type '{}'” in Typescript and when working with node, remember to access only object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
you can try item[“name”]. I don’t know but it’s works
Same here, any updates on this? Btw if someone is struggling with this, dirty solution would be usage of
{{$any(item).name}}
. It will make compiler happy again.example: