-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Add TypeScript demos for Simple and Spanning Table #14985
Conversation
I don't know what to do with spread operator in Source: |
@hopelessmuffins Have made a new commit. Let me know what you think of the simplification proposal. |
No bundle size changes comparing d1a7d76...ae3fc37 |
Yep that works - I was wanting to change the |
} | ||
|
||
function subtotal(items) { | ||
return items.map(({ price }) => price).reduce((sum, i) => sum + i, 0); | ||
} | ||
|
||
const rows = [ | ||
['Paperclips (Box)', 100, 1.15], | ||
['Paper (Case)', 10, 45.99], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what to do with spread operator in
SpanningTable.tsx
because TypeScript considers the spread operator incompatible with the function signature ofcreateRow
.Source:
Microsoft/TypeScript#4130
This was an issue with type widening. TypeScript inferred a nested array (string | number)[][]
instead of an array of tuples [string, number, number][]
. With TypeScript 3.4 we could've written ['Paper (Case)', 10, 45.99] as const
to fix this issue.
function createData(name, calories, fat, carbs, protein) { | ||
id += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good change. The previous approach resulted in re-mounting of the TableRow
on every render call of SimpleTable
.
@jasondashwang Much appreciated, thanks! |
This is my first time contributing to this project - before I continue adding TS demos, I want to make sure I am doing it correctly with my first two examples - SimpleTable and SpanningTable.