Skip to content
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

chore: add generic typing to table component #259

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

jared-dickman
Copy link
Collaborator

Instructions

  1. PR target branch should be against main
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Adds generic template type for use in platforms

Testing Plan

  • Was this tested locally? If not, explain why.
  • {explain how this has been tested, and what, if any, additional testing should be done}

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@jared-dickman jared-dickman requested a review from tibuurcio June 3, 2024 16:34

export type { ColumnType, ExpandableConfig, ColumnsType, TableProps }

export const Table = (props: ITableProps) => {
export const Table = <RecordType extends AnyObject = any>(props: ITableProps<RecordType>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy AnyObject that has any as a default. That's too many any's 😄

Jokes aside, can we do the same as Antd and use AnyObject = AnyObject?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing, i got this from node_modules/antd/es/table/InternalTable.d.ts:10 but your link seems legit
image

Copy link
Contributor

@ajenkins-mparticle ajenkins-mparticle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was playing in Nancy and I found I needed this two Fridays ago. LGTM

@@ -1,17 +1,18 @@
import { Table as AntTable } from 'antd'
import { type TableProps as AntTableProps } from 'antd'
import { type AnyObject } from 'antd/lib/_util/type'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter if we mix imports from antd/es and antd/lib? I know this is only a type, I'm wondering how this transpiles, though. I was reading about type imports the other day and I think this transpiles to:

import { } from 'antd/lib/_util/type

This is minor, just asking if you knew how it all works, I don't really.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also dont really 😩 but we seem to mostly use /es
ive changed this and the one other /lib import to be consistent with the rest of the project

image

@jared-dickman jared-dickman merged commit 94a6732 into main Jun 5, 2024
10 of 11 checks passed
@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 1.17.0-ups-configurable-cookie.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 1.17.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 1.16.2-query-select-number.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants