sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

There is problems with this example code. It wil render an error - Element implicitly has an 'any' type because expression of type 'string' can't be used to index type

Open hdsoftware opened this issue 2 years ago • 1 comments

Im new to this topicks and when the tutor contains coding errors, it makes me struggle hard to understand where the problems are and how to solve them. Its important to make sure the code in the tutors actually works. After a lot of googelin, I found this article: https://bobbyhadz.com/blog/typescript-element-implicitly-has-any-type-expression wich eventually led to the following solution:

In the ListItemsWebParts.ts, class ListItemsWebPart, method LoadItems

Change resolve(items[wp.properties.listName]); to resolve(items[wp.properties.listName as keyof typeof items]);

And now it finally works...

I cant say for sure that this was a valid solution or not, but at least it made my day :D

Regards ....


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

hdsoftware avatar Sep 16 '22 08:09 hdsoftware

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Sep 16 '22 08:09 ghost