adobe / adobe/spectrum-web-components

[Bug]: Wrong type definition for table.renderItem

Open
#5,422 1 comment 0 reactions 0 assignees View on GitHub
bug Component:Table SEV 4
Dominant language
TypeScript
Stars
1.5k
Forks
262
Avg merge
3d 10h
Merged PRs (30d)
68

Description

### Code of conduct

- [x] I agree to follow this project's code of conduct.

### Impacted component(s)

sp-table

### Expected behavior

When implementing the renderItem property for a virtualized table, the type definition expects me to implement
```
(property) Table.renderItem: (item: Record, index: number) => TemplateResult
```
the example at contradicts this, showing the ```Array``` that I found to actually work, while the implementation provided [in the package](https://github.com/adobe/spectrum-web-components/blob/7651b7d2e4bfc80095ab3608fbf1472be07e29d3/packages/table/src/Table.ts#L79) uses the TemplateResult containing an entire row, including the sp-table-row elements.

I expect the documentation, the type hinting I get from editors like visual studio or zed, and the example in the package's own implementation to all match. Minimally, I expect the type hinting for editors to match what (empirically) appears to be expected.

### Actual behavior

It appears to work best when I actually return an ```Array``` where the array contains the cells that go in the row.

### Screenshots

_No response_

### What browsers are you seeing the problem in?

Chrome

### How can we reproduce this issue?

1. Go to '...'
2. Click on '....'
3. Scroll to '....'
4. Check console
5. See error

### Sample code or abstract reproduction which illustrates the problem

tsc shows a warning on [this line](https://github.com/lschierer/EvonyTKRTips/blob/3d0bba2e48449958d390aa97456c4eaf938e95e7/packages/greenwood/src/components/generals/GeneralsTable.ts#L65) of my project. I do not have a minimal reproduction set up at this time, and my project is a bit involved for a casual reproduction.

Note the table *does* work. It would just be a much easier developer experience if I wasn't fighting the linter.

### Severity

SEV 4

### Logs taken while reproducing problem

_No response_

Contributor guide

Open the contributing guide

Research direction

Read packages/table/src/Table.ts around the renderItem definition and compare it with the virtualized-table sorting example in the component documentation. Reproduce the TypeScript warning using the linked GeneralsTable.ts usage if possible; done means the implementation, editor type hint, and documented example agree on the accepted renderItem return type.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.