Skip to content

Instantly share code, notes, and snippets.

@leandrojo
Created February 19, 2020 12:46
Show Gist options
  • Select an option

  • Save leandrojo/1accdc851b951162a7719658ca178dde to your computer and use it in GitHub Desktop.

Select an option

Save leandrojo/1accdc851b951162a7719658ca178dde to your computer and use it in GitHub Desktop.
Trecho em Typescript 101
import React from 'react';
import TableCommunity from 'rc-table';
import { GetComponentProps } from 'rc-table/lib/interface';
interface Props {
columns: Array<{
[key: string]: any;
}>;
data: object[];
scroll?: object;
style?: object;
onRow?: GetComponentProps<object> | undefined;
}
const Table = ({ columns, data, ...props }: Props) => (
<TableCommunity
columns={columns}
components={{
header: {
cell: Header,
},
body: {
cell: Cell,
row: Row,
},
}}
data={data}
{...props}
/>
);
@leandrojo
Copy link
Author

import { GetComponentProps } from 'rc-table/lib/interface';

Importando "tipagem" a partir de uma terceira parte. Seria essa uma abordagem comum?

interface Props {}

Sempre que quero intermediar um componente, apenas para criar definições de estilo ou tratamento de dados, etc, eu estou tendo dificuldades em satisfazer a tipagem exatamente como esperado. Tem alguma dica para esses casos?

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