0

I inherited code, and I am trying to get it transpiled and eventually running. Within a components/TableAsset.tsx I found the following lines

import { Table } from "antd";
const { Column, ColumnGroup } = Table;
class MyTable extends Table<Interfaces.ViewEntry> { }

This gives various typescript errors, which I do not understand. But what might have actually be intended with this piece of code? How would you write it in today's Typescript 3.x?

B--rian
  • 5,578
  • 10
  • 38
  • 89

1 Answers1

3

But what might have actually be intended with this piece of code?

That code:

1. Imports a named export called Table from "antd":

import { Table } from "antd";

2. Uses destructuring to assign Table.Column and Table.ColumnGroup to the constants Column and ColumnGroup, respectively:

const { Column, ColumnGroup } = Table;

3. Creates a class that extends Table, providing Interfaces.ViewEntry for Table's generic parameter (more: generics):

class MyTable extends Table<Interfaces.ViewEntry> { }

How would you write it in today's Typescript 3.x?

That code is just fine for TypeScript 3.x.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875